Search in sources :

Example 1 with StreamState

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

the class StreamStateCompositeData method fromCompositeData.

public static StreamState fromCompositeData(CompositeData cd) {
    assert cd.getCompositeType().equals(COMPOSITE_TYPE);
    Object[] values = cd.getAll(ITEM_NAMES);
    UUID planId = UUID.fromString((String) values[0]);
    String description = (String) values[1];
    Set<SessionInfo> sessions = Sets.newHashSet(Iterables.transform(Arrays.asList((CompositeData[]) values[2]), input -> SessionInfoCompositeData.fromCompositeData(input)));
    return new StreamState(planId, description, sessions);
}
Also used : Arrays(java.util.Arrays) CompositeType(javax.management.openmbean.CompositeType) OpenDataException(javax.management.openmbean.OpenDataException) Iterables(com.google.common.collect.Iterables) SimpleType(javax.management.openmbean.SimpleType) Set(java.util.Set) CompositeData(javax.management.openmbean.CompositeData) Throwables(com.google.common.base.Throwables) HashMap(java.util.HashMap) UUID(java.util.UUID) Sets(com.google.common.collect.Sets) OpenType(javax.management.openmbean.OpenType) StreamState(org.apache.cassandra.streaming.StreamState) 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) StreamState(org.apache.cassandra.streaming.StreamState) CompositeData(javax.management.openmbean.CompositeData) SessionInfo(org.apache.cassandra.streaming.SessionInfo) UUID(java.util.UUID)

Example 2 with StreamState

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

the class NetStats method execute.

@Override
public void execute(NodeProbe probe) {
    PrintStream out = probe.output().out;
    out.printf("Mode: %s%n", probe.getOperationMode());
    Set<StreamState> statuses = probe.getStreamStatus();
    if (statuses.isEmpty())
        out.println("Not sending any streams.");
    for (StreamState status : statuses) {
        out.printf("%s %s%n", status.streamOperation.getDescription(), status.planId.toString());
        for (SessionInfo info : status.sessions) {
            out.printf("    %s", InetAddressAndPort.toString(info.peer, printPort));
            // print private IP when it is used
            if (!info.peer.equals(info.connecting)) {
                out.printf(" (using %s)", InetAddressAndPort.toString(info.connecting, printPort));
            }
            out.printf("%n");
            if (!info.receivingSummaries.isEmpty()) {
                printReceivingSummaries(out, info, humanReadable);
            }
            if (!info.sendingSummaries.isEmpty()) {
                printSendingSummaries(out, info, humanReadable);
            }
        }
    }
    if (!probe.isStarting()) {
        out.printf("Read Repair Statistics:%nAttempted: %d%nMismatch (Blocking): %d%nMismatch (Background): %d%n", probe.getReadRepairAttempted(), probe.getReadRepairRepairedBlocking(), probe.getReadRepairRepairedBackground());
        MessagingServiceMBean ms = probe.getMessagingServiceProxy();
        out.printf("%-25s", "Pool Name");
        out.printf("%10s", "Active");
        out.printf("%10s", "Pending");
        out.printf("%15s", "Completed");
        out.printf("%10s%n", "Dropped");
        int pending;
        long completed;
        long dropped;
        pending = 0;
        for (int n : ms.getLargeMessagePendingTasksWithPort().values()) pending += n;
        completed = 0;
        for (long n : ms.getLargeMessageCompletedTasksWithPort().values()) completed += n;
        dropped = 0;
        for (long n : ms.getLargeMessageDroppedTasksWithPort().values()) dropped += n;
        out.printf("%-25s%10s%10s%15s%10s%n", "Large messages", "n/a", pending, completed, dropped);
        pending = 0;
        for (int n : ms.getSmallMessagePendingTasksWithPort().values()) pending += n;
        completed = 0;
        for (long n : ms.getSmallMessageCompletedTasksWithPort().values()) completed += n;
        dropped = 0;
        for (long n : ms.getSmallMessageDroppedTasksWithPort().values()) dropped += n;
        out.printf("%-25s%10s%10s%15s%10s%n", "Small messages", "n/a", pending, completed, dropped);
        pending = 0;
        for (int n : ms.getGossipMessagePendingTasksWithPort().values()) pending += n;
        completed = 0;
        for (long n : ms.getGossipMessageCompletedTasksWithPort().values()) completed += n;
        dropped = 0;
        for (long n : ms.getGossipMessageDroppedTasksWithPort().values()) dropped += n;
        out.printf("%-25s%10s%10s%15s%10s%n", "Gossip messages", "n/a", pending, completed, dropped);
    }
}
Also used : StreamState(org.apache.cassandra.streaming.StreamState) PrintStream(java.io.PrintStream) MessagingServiceMBean(org.apache.cassandra.net.MessagingServiceMBean) SessionInfo(org.apache.cassandra.streaming.SessionInfo)

Example 3 with StreamState

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

the class CqlBulkRecordWriter method close.

private void close() throws IOException {
    if (writer != null) {
        writer.close();
        Future<StreamState> future = loader.stream(ignores);
        while (true) {
            try {
                future.get(1000, TimeUnit.MILLISECONDS);
                break;
            } catch (ExecutionException | TimeoutException te) {
                if (null != progress)
                    progress.progress();
                if (null != context)
                    HadoopCompat.progress(context);
            } catch (InterruptedException e) {
                throw new IOException(e);
            }
        }
        if (loader.getFailedHosts().size() > 0) {
            if (loader.getFailedHosts().size() > maxFailures)
                throw new IOException("Too many hosts failed: " + loader.getFailedHosts());
            else
                logger.warn("Some hosts failed: {}", loader.getFailedHosts());
        }
    }
}
Also used : StreamState(org.apache.cassandra.streaming.StreamState) IOException(java.io.IOException)

Example 4 with StreamState

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

the class CqlBulkRecordWriter method prepareWriter.

private void prepareWriter() throws IOException {
    if (writer == null) {
        writer = CQLSSTableWriter.builder().forTable(schema).using(insertStatement).withPartitioner(ConfigHelper.getOutputPartitioner(conf)).inDirectory(outputDir).withBufferSizeInMiB(Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64"))).withPartitioner(partitioner).build();
    }
    if (loader == null) {
        ExternalClient externalClient = new ExternalClient(conf);
        externalClient.setTableMetadata(TableMetadataRef.forOfflineTools(CreateTableStatement.parse(schema, keyspace).build()));
        loader = new SSTableLoader(outputDir, externalClient, new NullOutputHandler()) {

            @Override
            public void onSuccess(StreamState finalState) {
                if (deleteSrc)
                    FileUtils.deleteRecursive(outputDir);
            }
        };
    }
}
Also used : StreamState(org.apache.cassandra.streaming.StreamState) SSTableLoader(org.apache.cassandra.io.sstable.SSTableLoader)

Aggregations

StreamState (org.apache.cassandra.streaming.StreamState)4 SessionInfo (org.apache.cassandra.streaming.SessionInfo)2 Throwables (com.google.common.base.Throwables)1 Iterables (com.google.common.collect.Iterables)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 UUID (java.util.UUID)1 ArrayType (javax.management.openmbean.ArrayType)1 CompositeData (javax.management.openmbean.CompositeData)1 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)1 CompositeType (javax.management.openmbean.CompositeType)1 OpenDataException (javax.management.openmbean.OpenDataException)1 OpenType (javax.management.openmbean.OpenType)1 SimpleType (javax.management.openmbean.SimpleType)1