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

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

Introduction

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

Prototype

public long getTotalSizeToReceive() 

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;
    }/*  w  w  w.j  a  v a2  s . c  o  m*/
    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();
}