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

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

Introduction

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

Prototype

public Collection<ProgressInfo> getSendingFiles() 

Source Link

Usage

From source file:com.netflix.priam.resources.CassandraAdminResource.java

License:Apache License

@GET
@Path("/netstats")
public Response netstats() throws Exception {
    JMXNodeTool nodetool = getNodeTool();
    Map<String, Object> rootObj = Maps.newLinkedHashMap();
    rootObj.put("mode", nodetool.getOperationMode());

    // Collect Sending Netstats
    Set<StreamState> netstats = nodetool.getStreamStatus();

    for (StreamState streamState : netstats) {
        final Set<SessionInfo> streamSessions = streamState.sessions;
        for (SessionInfo streamSession : streamSessions) {
            final Collection<ProgressInfo> sendingFiles = streamSession.getSendingFiles();
            final Collection<ProgressInfo> receivingFiles = streamSession.getReceivingFiles();
            final String connectingHost = streamSession.connecting.getHostName();
            final Set<Collection<ProgressInfo>> streams = rootObj.containsKey(connectingHost)
                    ? (Set<Collection<ProgressInfo>>) rootObj.get(connectingHost)
                    : Sets.<Collection<ProgressInfo>>newHashSet();
            streams.add(sendingFiles);//from   ww  w  . j a v  a 2  s .co m
            streams.add(receivingFiles);
            rootObj.put(connectingHost, streams);
        }
    }

    return Response.ok(rootObj, MediaType.APPLICATION_JSON).build();
}

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   ww 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();
}