Example usage for org.apache.cassandra.streaming StreamSummary StreamSummary

List of usage examples for org.apache.cassandra.streaming StreamSummary StreamSummary

Introduction

In this page you can find the example usage for org.apache.cassandra.streaming StreamSummary StreamSummary.

Prototype

public StreamSummary(TableId tableId, int files, long totalSize) 

Source Link

Usage

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  w  w w .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  w w  w.ja  va2 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());
}