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);
}
}
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;
}
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);
}
}
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;
}
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);
}
}
Aggregations