List of usage examples for org.apache.cassandra.streaming StreamState StreamState
public StreamState(UUID planId, StreamOperation streamOperation, Set<SessionInfo> sessions)
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);/*from www. j a v a 2 s . c om*/ 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 ww w .jav a2 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 StreamState parseStreamStatePre2_1(CompositeData compositeData) throws ReaperException { UUID planId = UUID.fromString((String) compositeData.get("planId")); String description = (String) compositeData.get("description"); CompositeData[] sessionCompositeData = (CompositeData[]) compositeData.get("sessions"); Set<SessionInfo> sessions = Arrays.stream(sessionCompositeData).map(this::parseSessionInfoPre2_1) .collect(Collectors.toSet()); return new StreamState(planId, description, sessions); }