Search in sources :

Example 1 with StreamSummary

use of org.apache.cassandra.streaming.StreamSummary 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 2 with StreamSummary

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

the class PrepareMessage method toString.

@Override
public String toString() {
    final StringBuilder sb = new StringBuilder("Prepare (");
    sb.append(requests.size()).append(" requests, ");
    int totalFile = 0;
    for (StreamSummary summary : summaries) totalFile += summary.files;
    sb.append(" ").append(totalFile).append(" files");
    sb.append('}');
    return sb.toString();
}
Also used : StreamSummary(org.apache.cassandra.streaming.StreamSummary)

Aggregations

StreamSummary (org.apache.cassandra.streaming.StreamSummary)2 Function (com.google.common.base.Function)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ProgressInfo (org.apache.cassandra.streaming.ProgressInfo)1 SessionInfo (org.apache.cassandra.streaming.SessionInfo)1