List of usage examples for org.apache.cassandra.streaming ProgressInfo ProgressInfo
public ProgressInfo(InetAddressAndPort peer, int sessionIndex, String fileName, Direction direction, long currentBytes, long totalBytes)
From source file:io.cassandrareaper.service.StreamFactoryTest.java
License:Apache License
@Test public void testCountProgressPerTableWithTable() throws UnknownHostException { UUID cfid = UUID.randomUUID(); int files = 3; int totalSize = 2048; StreamSummary streamSummary = new StreamSummary(cfid, files, totalSize); InetAddress peer = InetAddress.getByName("127.0.0.1"); int index = 0; InetAddress connecting = InetAddress.getByName("127.0.0.2"); ImmutableSet<StreamSummary> receivingSummaries = ImmutableSet.of(streamSummary); ImmutableSet<StreamSummary> sendingSummaries = ImmutableSet.of(); SessionInfo sessionInfo = new SessionInfo(peer, index, connecting, receivingSummaries, sendingSummaries, StreamSession.State.STREAMING); String file1 = "/cass/data/keyspace1/standard1-af5311f0633a11e89d71710c22f847e7/lb-4-big-Data.db"; String file2 = "/cass/data/keyspace1/standard1-af5311f0633a11e89d71710c22f847e7/lb-5-big-Data.db"; sessionInfo.updateProgress(new ProgressInfo(peer, index, file1, ProgressInfo.Direction.OUT, 512, 1024)); sessionInfo.updateProgress(new ProgressInfo(peer, index, file2, ProgressInfo.Direction.OUT, 512, 1024)); UUID planId = UUID.randomUUID(); ImmutableSet<SessionInfo> sessionInfos = ImmutableSet.of(sessionInfo); StreamState streamState = new StreamState(planId, "descr", sessionInfos); io.cassandrareaper.core.StreamSession streamSession = StreamSessionFactory.fromStreamState(peer.toString(), streamState);// w w w . j a va 2s . co m assertEquals(1, streamSession.getStreams().size()); List<Stream.TableProgress> progressSent = streamSession.getStreams().values().asList().get(0) .getProgressSent(); assertEquals(1, progressSent.size()); Stream.TableProgress tableProgress = progressSent.get(0); assertEquals("keyspace1.standard1", tableProgress.getTable()); assertEquals(Long.valueOf(1024), tableProgress.getCurrent()); assertEquals(Long.valueOf(2048), tableProgress.getTotal()); }
From source file:io.cassandrareaper.service.StreamFactoryTest.java
License:Apache License
@Test public void testCountProgressPerTableWithMultipleTables() throws UnknownHostException { UUID cfid = UUID.randomUUID(); int files = 3; int totalSize = 2048; StreamSummary streamSummary = new StreamSummary(cfid, files, totalSize); InetAddress peer = InetAddress.getByName("127.0.0.1"); int index = 0; InetAddress connecting = InetAddress.getByName("127.0.0.2"); ImmutableSet<StreamSummary> receivingSummaries = ImmutableSet.of(streamSummary); ImmutableSet<StreamSummary> sendingSummaries = ImmutableSet.of(); SessionInfo sessionInfo = new SessionInfo(peer, index, connecting, receivingSummaries, sendingSummaries, StreamSession.State.STREAMING); String file1 = "/cass/data/keyspace1/standard1-af5311f0633a11e89d71710c22f847e7/lb-4-big-Data.db"; sessionInfo.updateProgress(new ProgressInfo(peer, index, file1, ProgressInfo.Direction.OUT, 32, 1024)); String file2 = "/cass/data/keyspace1/standard1-af5311f0633a11e89d71710c22f847e7/lb-5-big-Data.db"; sessionInfo.updateProgress(new ProgressInfo(peer, index, file2, ProgressInfo.Direction.OUT, 64, 1024)); String file3 = "/cass/data/keyspace1/counter1-af5311f0633a11e89d71710c22f847e7/lb-4-big-Data.db"; sessionInfo.updateProgress(new ProgressInfo(peer, index, file3, ProgressInfo.Direction.OUT, 512, 512)); String file4 = "/cass/data/keyspace1/counter1-af5311f0633a11e89d71710c22f847e7/lb-5-big-Data.db"; sessionInfo.updateProgress(new ProgressInfo(peer, index, file4, ProgressInfo.Direction.OUT, 128, 512)); UUID planId = UUID.randomUUID(); ImmutableSet<SessionInfo> sessionInfos = ImmutableSet.of(sessionInfo); StreamState streamState = new StreamState(planId, "descr", sessionInfos); io.cassandrareaper.core.StreamSession streamSession = StreamSessionFactory.fromStreamState(peer.toString(), streamState);//from w w w .j av a 2 s.com assertEquals(1, streamSession.getStreams().size()); List<Stream.TableProgress> progressSent = streamSession.getStreams().values().asList().get(0) .getProgressSent(); assertEquals(2, progressSent.size()); Stream.TableProgress standardTableProgess = progressSent.stream() .filter(ps -> ps.getTable().equals("keyspace1.standard1")).findFirst().get(); assertEquals(Long.valueOf(96), standardTableProgess.getCurrent()); assertEquals(Long.valueOf(2048), standardTableProgess.getTotal()); Stream.TableProgress counterTableProgress = progressSent.stream() .filter(ps -> ps.getTable().equals("keyspace1.counter1")).findFirst().get(); assertEquals(Long.valueOf(640), counterTableProgress.getCurrent()); assertEquals(Long.valueOf(1024), counterTableProgress.getTotal()); }
From source file:io.cassandrareaper.service.StreamManager.java
License:Apache License
private ProgressInfo parseProgressInfoPre2_1(CompositeData compositeData) { InetAddress peer = null;//from w ww. j a v a 2s . c om try { peer = InetAddress.getByName((String) compositeData.get("peer")); } catch (UnknownHostException e) { LOG.warn("Could not resolve host when parsing ProgressInfo {}", compositeData.toString()); } Preconditions.checkNotNull(peer); String fileName = (String) compositeData.get("fileName"); ProgressInfo.Direction direction = ProgressInfo.Direction.valueOf((String) compositeData.get("direction")); long currentBytes = (long) compositeData.get("currentBytes"); long totalBytes = (long) compositeData.get("totalBytes"); // sessionIndex is not present in the ProgressInfo of C* before 2.1 int sessionIndex = Integer.MIN_VALUE; return new ProgressInfo(peer, sessionIndex, fileName, direction, currentBytes, totalBytes); }