Search in sources :

Example 1 with SessionInfo

use of org.apache.cassandra.streaming.SessionInfo in project cassandra by apache.

the class StreamStateCompositeData method toCompositeData.

public static CompositeData toCompositeData(final StreamState streamState) {
    Map<String, Object> valueMap = new HashMap<>();
    valueMap.put(ITEM_NAMES[0], streamState.planId.toString());
    valueMap.put(ITEM_NAMES[1], streamState.description);
    CompositeData[] sessions = new CompositeData[streamState.sessions.size()];
    Lists.newArrayList(Iterables.transform(streamState.sessions, new Function<SessionInfo, CompositeData>() {

        public CompositeData apply(SessionInfo input) {
            return SessionInfoCompositeData.toCompositeData(streamState.planId, input);
        }
    })).toArray(sessions);
    valueMap.put(ITEM_NAMES[2], sessions);
    long currentRxBytes = 0;
    long totalRxBytes = 0;
    long currentTxBytes = 0;
    long totalTxBytes = 0;
    for (SessionInfo sessInfo : streamState.sessions) {
        currentRxBytes += sessInfo.getTotalSizeReceived();
        totalRxBytes += sessInfo.getTotalSizeToReceive();
        currentTxBytes += sessInfo.getTotalSizeSent();
        totalTxBytes += sessInfo.getTotalSizeToSend();
    }
    double rxPercentage = (totalRxBytes == 0 ? 100L : currentRxBytes * 100L / totalRxBytes);
    double txPercentage = (totalTxBytes == 0 ? 100L : currentTxBytes * 100L / totalTxBytes);
    valueMap.put(ITEM_NAMES[3], currentRxBytes);
    valueMap.put(ITEM_NAMES[4], totalRxBytes);
    valueMap.put(ITEM_NAMES[5], rxPercentage);
    valueMap.put(ITEM_NAMES[6], currentTxBytes);
    valueMap.put(ITEM_NAMES[7], totalTxBytes);
    valueMap.put(ITEM_NAMES[8], txPercentage);
    try {
        return new CompositeDataSupport(COMPOSITE_TYPE, valueMap);
    } catch (OpenDataException e) {
        throw Throwables.propagate(e);
    }
}
Also used : SessionInfo(org.apache.cassandra.streaming.SessionInfo)

Example 2 with SessionInfo

use of org.apache.cassandra.streaming.SessionInfo in project scylla-jmx by scylladb.

the class SessionInfoCompositeData method fromCompositeData.

public static SessionInfo fromCompositeData(CompositeData cd) {
    assert cd.getCompositeType().equals(COMPOSITE_TYPE);
    Object[] values = cd.getAll(ITEM_NAMES);
    InetAddress peer, connecting;
    try {
        peer = InetAddress.getByName((String) values[1]);
        connecting = InetAddress.getByName((String) values[2]);
    } catch (UnknownHostException e) {
        throw Throwables.propagate(e);
    }
    Function<CompositeData, StreamSummary> toStreamSummary = input -> StreamSummaryCompositeData.fromCompositeData(input);
    SessionInfo info = new SessionInfo(peer, (int) values[8], connecting, fromArrayOfCompositeData((CompositeData[]) values[3], toStreamSummary), fromArrayOfCompositeData((CompositeData[]) values[4], toStreamSummary), StreamSession.State.valueOf((String) values[5]), new HashMap<String, ProgressInfo>(), new HashMap<String, ProgressInfo>());
    Function<CompositeData, ProgressInfo> toProgressInfo = input -> ProgressInfoCompositeData.fromCompositeData(input);
    for (ProgressInfo progress : fromArrayOfCompositeData((CompositeData[]) values[6], toProgressInfo)) {
        info.updateProgress(progress);
    }
    for (ProgressInfo progress : fromArrayOfCompositeData((CompositeData[]) values[7], toProgressInfo)) {
        info.updateProgress(progress);
    }
    return info;
}
Also used : Arrays(java.util.Arrays) CompositeType(javax.management.openmbean.CompositeType) OpenDataException(javax.management.openmbean.OpenDataException) Iterables(com.google.common.collect.Iterables) ProgressInfo(org.apache.cassandra.streaming.ProgressInfo) Function(com.google.common.base.Function) Collection(java.util.Collection) SimpleType(javax.management.openmbean.SimpleType) CompositeData(javax.management.openmbean.CompositeData) Throwables(com.google.common.base.Throwables) HashMap(java.util.HashMap) UUID(java.util.UUID) UnknownHostException(java.net.UnknownHostException) StreamSummary(org.apache.cassandra.streaming.StreamSummary) Sets(com.google.common.collect.Sets) InetAddress(java.net.InetAddress) OpenType(javax.management.openmbean.OpenType) StreamSession(org.apache.cassandra.streaming.StreamSession) Lists(com.google.common.collect.Lists) Map(java.util.Map) SessionInfo(org.apache.cassandra.streaming.SessionInfo) ArrayType(javax.management.openmbean.ArrayType) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) UnknownHostException(java.net.UnknownHostException) CompositeData(javax.management.openmbean.CompositeData) SessionInfo(org.apache.cassandra.streaming.SessionInfo) ProgressInfo(org.apache.cassandra.streaming.ProgressInfo) InetAddress(java.net.InetAddress) StreamSummary(org.apache.cassandra.streaming.StreamSummary)

Example 3 with SessionInfo

use of org.apache.cassandra.streaming.SessionInfo in project scylla-jmx by scylladb.

the class StreamStateCompositeData method toCompositeData.

public static CompositeData toCompositeData(final StreamState streamState) {
    Map<String, Object> valueMap = new HashMap<>();
    valueMap.put(ITEM_NAMES[0], streamState.planId.toString());
    valueMap.put(ITEM_NAMES[1], streamState.description);
    CompositeData[] sessions = new CompositeData[streamState.sessions.size()];
    Lists.newArrayList(Iterables.transform(streamState.sessions, input -> SessionInfoCompositeData.toCompositeData(streamState.planId, input))).toArray(sessions);
    valueMap.put(ITEM_NAMES[2], sessions);
    long currentRxBytes = 0;
    long totalRxBytes = 0;
    long currentTxBytes = 0;
    long totalTxBytes = 0;
    for (SessionInfo sessInfo : streamState.sessions) {
        currentRxBytes += sessInfo.getTotalSizeReceived();
        totalRxBytes += sessInfo.getTotalSizeToReceive();
        currentTxBytes += sessInfo.getTotalSizeSent();
        totalTxBytes += sessInfo.getTotalSizeToSend();
    }
    double rxPercentage = (totalRxBytes == 0 ? 100L : currentRxBytes * 100L / totalRxBytes);
    double txPercentage = (totalTxBytes == 0 ? 100L : currentTxBytes * 100L / totalTxBytes);
    valueMap.put(ITEM_NAMES[3], currentRxBytes);
    valueMap.put(ITEM_NAMES[4], totalRxBytes);
    valueMap.put(ITEM_NAMES[5], rxPercentage);
    valueMap.put(ITEM_NAMES[6], currentTxBytes);
    valueMap.put(ITEM_NAMES[7], totalTxBytes);
    valueMap.put(ITEM_NAMES[8], txPercentage);
    try {
        return new CompositeDataSupport(COMPOSITE_TYPE, valueMap);
    } catch (OpenDataException e) {
        throw Throwables.propagate(e);
    }
}
Also used : HashMap(java.util.HashMap) OpenDataException(javax.management.openmbean.OpenDataException) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) SessionInfo(org.apache.cassandra.streaming.SessionInfo)

Example 4 with SessionInfo

use of org.apache.cassandra.streaming.SessionInfo in project cassandra by apache.

the class SessionInfoCompositeData method fromCompositeData.

public static SessionInfo fromCompositeData(CompositeData cd) {
    assert cd.getCompositeType().equals(COMPOSITE_TYPE);
    Object[] values = cd.getAll(ITEM_NAMES);
    InetAddress peer, connecting;
    try {
        peer = InetAddress.getByName((String) values[1]);
        connecting = InetAddress.getByName((String) values[2]);
    } catch (UnknownHostException e) {
        throw Throwables.propagate(e);
    }
    Function<CompositeData, StreamSummary> toStreamSummary = new Function<CompositeData, StreamSummary>() {

        public StreamSummary apply(CompositeData input) {
            return StreamSummaryCompositeData.fromCompositeData(input);
        }
    };
    SessionInfo info = new SessionInfo(peer, (int) values[8], connecting, fromArrayOfCompositeData((CompositeData[]) values[3], toStreamSummary), fromArrayOfCompositeData((CompositeData[]) values[4], toStreamSummary), StreamSession.State.valueOf((String) values[5]));
    Function<CompositeData, ProgressInfo> toProgressInfo = new Function<CompositeData, ProgressInfo>() {

        public ProgressInfo apply(CompositeData input) {
            return ProgressInfoCompositeData.fromCompositeData(input);
        }
    };
    for (ProgressInfo progress : fromArrayOfCompositeData((CompositeData[]) values[6], toProgressInfo)) {
        info.updateProgress(progress);
    }
    for (ProgressInfo progress : fromArrayOfCompositeData((CompositeData[]) values[7], toProgressInfo)) {
        info.updateProgress(progress);
    }
    return info;
}
Also used : Function(com.google.common.base.Function) UnknownHostException(java.net.UnknownHostException) ProgressInfo(org.apache.cassandra.streaming.ProgressInfo) SessionInfo(org.apache.cassandra.streaming.SessionInfo) InetAddress(java.net.InetAddress) StreamSummary(org.apache.cassandra.streaming.StreamSummary)

Example 5 with SessionInfo

use of org.apache.cassandra.streaming.SessionInfo in project cassandra by apache.

the class NetStats method execute.

@Override
public void execute(NodeProbe probe) {
    System.out.printf("Mode: %s%n", probe.getOperationMode());
    Set<StreamState> statuses = probe.getStreamStatus();
    if (statuses.isEmpty())
        System.out.println("Not sending any streams.");
    for (StreamState status : statuses) {
        System.out.printf("%s %s%n", status.description, status.planId.toString());
        for (SessionInfo info : status.sessions) {
            System.out.printf("    %s", info.peer.toString());
            // print private IP when it is used
            if (!info.peer.equals(info.connecting)) {
                System.out.printf(" (using %s)", info.connecting.toString());
            }
            System.out.printf("%n");
            if (!info.receivingSummaries.isEmpty()) {
                if (humanReadable)
                    System.out.printf("        Receiving %d files, %s total. Already received %d files, %s total%n", info.getTotalFilesToReceive(), FileUtils.stringifyFileSize(info.getTotalSizeToReceive()), info.getTotalFilesReceived(), FileUtils.stringifyFileSize(info.getTotalSizeReceived()));
                else
                    System.out.printf("        Receiving %d files, %d bytes total. Already received %d files, %d bytes total%n", info.getTotalFilesToReceive(), info.getTotalSizeToReceive(), info.getTotalFilesReceived(), info.getTotalSizeReceived());
                for (ProgressInfo progress : info.getReceivingFiles()) {
                    System.out.printf("            %s%n", progress.toString());
                }
            }
            if (!info.sendingSummaries.isEmpty()) {
                if (humanReadable)
                    System.out.printf("        Sending %d files, %s total. Already sent %d files, %s total%n", info.getTotalFilesToSend(), FileUtils.stringifyFileSize(info.getTotalSizeToSend()), info.getTotalFilesSent(), FileUtils.stringifyFileSize(info.getTotalSizeSent()));
                else
                    System.out.printf("        Sending %d files, %d bytes total. Already sent %d files, %d bytes total%n", info.getTotalFilesToSend(), info.getTotalSizeToSend(), info.getTotalFilesSent(), info.getTotalSizeSent());
                for (ProgressInfo progress : info.getSendingFiles()) {
                    System.out.printf("            %s%n", progress.toString());
                }
            }
        }
    }
    if (!probe.isStarting()) {
        System.out.printf("Read Repair Statistics:%nAttempted: %d%nMismatch (Blocking): %d%nMismatch (Background): %d%n", probe.getReadRepairAttempted(), probe.getReadRepairRepairedBlocking(), probe.getReadRepairRepairedBackground());
        MessagingServiceMBean ms = probe.msProxy;
        System.out.printf("%-25s", "Pool Name");
        System.out.printf("%10s", "Active");
        System.out.printf("%10s", "Pending");
        System.out.printf("%15s", "Completed");
        System.out.printf("%10s%n", "Dropped");
        int pending;
        long completed;
        long dropped;
        pending = 0;
        for (int n : ms.getLargeMessagePendingTasks().values()) pending += n;
        completed = 0;
        for (long n : ms.getLargeMessageCompletedTasks().values()) completed += n;
        dropped = 0;
        for (long n : ms.getLargeMessageDroppedTasks().values()) dropped += n;
        System.out.printf("%-25s%10s%10s%15s%10s%n", "Large messages", "n/a", pending, completed, dropped);
        pending = 0;
        for (int n : ms.getSmallMessagePendingTasks().values()) pending += n;
        completed = 0;
        for (long n : ms.getSmallMessageCompletedTasks().values()) completed += n;
        dropped = 0;
        for (long n : ms.getSmallMessageDroppedTasks().values()) dropped += n;
        System.out.printf("%-25s%10s%10s%15s%10s%n", "Small messages", "n/a", pending, completed, dropped);
        pending = 0;
        for (int n : ms.getGossipMessagePendingTasks().values()) pending += n;
        completed = 0;
        for (long n : ms.getGossipMessageCompletedTasks().values()) completed += n;
        dropped = 0;
        for (long n : ms.getGossipMessageDroppedTasks().values()) dropped += n;
        System.out.printf("%-25s%10s%10s%15s%10s%n", "Gossip messages", "n/a", pending, completed, dropped);
    }
}
Also used : StreamState(org.apache.cassandra.streaming.StreamState) ProgressInfo(org.apache.cassandra.streaming.ProgressInfo) MessagingServiceMBean(org.apache.cassandra.net.MessagingServiceMBean) SessionInfo(org.apache.cassandra.streaming.SessionInfo)

Aggregations

SessionInfo (org.apache.cassandra.streaming.SessionInfo)6 HashMap (java.util.HashMap)3 CompositeData (javax.management.openmbean.CompositeData)3 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)3 OpenDataException (javax.management.openmbean.OpenDataException)3 ProgressInfo (org.apache.cassandra.streaming.ProgressInfo)3 Function (com.google.common.base.Function)2 Throwables (com.google.common.base.Throwables)2 Iterables (com.google.common.collect.Iterables)2 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 Arrays (java.util.Arrays)2 Map (java.util.Map)2 UUID (java.util.UUID)2 ArrayType (javax.management.openmbean.ArrayType)2 CompositeType (javax.management.openmbean.CompositeType)2 OpenType (javax.management.openmbean.OpenType)2 SimpleType (javax.management.openmbean.SimpleType)2