Example usage for org.apache.cassandra.streaming SessionInfo getTotalSizeSent

List of usage examples for org.apache.cassandra.streaming SessionInfo getTotalSizeSent

Introduction

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

Prototype

public long getTotalSizeSent() 

Source Link

Usage

From source file:io.cassandrareaper.service.StreamFactory.java

License:Apache License

public static Stream newStream(String host, SessionInfo sessionInfo, long timeStamp) {

    final String peer = sessionInfo.peer.toString().replaceAll("/", "");

    final long sizeSent = sessionInfo.getTotalSizeSent();
    final long sizeReceived = sessionInfo.getTotalSizeReceived();

    Stream.Direction direction = Stream.Direction.BOTH;
    if (sizeReceived == 0 && sizeSent != 0) {
        direction = Stream.Direction.IN;
    }//from  w  w  w  .j a  v  a  2  s  . c om
    if (sizeReceived != 0 && sizeSent == 0) {
        direction = Stream.Direction.OUT;
    }

    final String streamId = String.format("%s-%s-%s", host, direction, peer);

    final List<Stream.TableProgress> progressReceived = countProgressPerTable(sessionInfo.getReceivingFiles());
    final List<Stream.TableProgress> progressSent = countProgressPerTable(sessionInfo.getSendingFiles());

    return Stream.builder().withId(streamId).withHost(host).withPeer(peer).withDirection(direction)
            .withSizeToReceive(sessionInfo.getTotalSizeToReceive())
            .withSizeToSend(sessionInfo.getTotalSizeToSend()).withProgressSent(progressSent)
            .withProgressReceived(progressReceived).withSizeSent(sizeSent).withSizeReceived(sizeReceived)
            .withLastUpdated(timeStamp).withCompleted(sessionInfo.state == StreamSession.State.COMPLETE)
            .withSuccess(!sessionInfo.isFailed()).build();
}