Example usage for org.apache.cassandra.streaming StreamState hasFailedSession

List of usage examples for org.apache.cassandra.streaming StreamState hasFailedSession

Introduction

In this page you can find the example usage for org.apache.cassandra.streaming StreamState hasFailedSession.

Prototype

public boolean hasFailedSession() 

Source Link

Usage

From source file:com.spotify.hdfs2cass.cassandra.cql.CrunchCqlBulkRecordWriter.java

License:Apache License

private void close() {
    LOG.info("SSTables built. Now starting streaming");
    context.setStatus("streaming");
    heartbeat.startHeartbeat();/*from w w  w  .ja v a2  s  .  c  om*/
    try {
        if (writer != null) {
            writer.close();
            Future<StreamState> future = loader.stream(Collections.<InetAddress>emptySet(),
                    new ProgressIndicator());
            try {
                StreamState streamState = Uninterruptibles.getUninterruptibly(future);
                if (streamState.hasFailedSession()) {
                    LOG.warn("Some streaming sessions failed");
                } else {
                    LOG.info("Streaming finished successfully");
                }
            } catch (ExecutionException e) {
                throw new CrunchRuntimeException(
                        "Streaming to the following hosts failed: " + loader.getFailedHosts(), e);
            }
        } else {
            LOG.info("SSTableWriter wasn't instantiated, no streaming happened.");
        }
    } catch (IOException e) {
        throw new CrunchRuntimeException(e);
    } finally {
        heartbeat.stopHeartbeat();
    }
}

From source file:com.spotify.hdfs2cass.cassandra.thrift.CrunchBulkRecordWriter.java

License:Apache License

private void close() throws IOException {
    LOG.info("SSTables built. Now starting streaming");
    heartbeat.startHeartbeat();/*from  ww w.  j a va2  s. co  m*/
    try {
        if (writer != null) {
            writer.close();
            Future<StreamState> future = loader.stream(Collections.<InetAddress>emptySet(),
                    new ProgressIndicator());
            try {
                StreamState streamState = Uninterruptibles.getUninterruptibly(future);
                if (streamState.hasFailedSession()) {
                    LOG.warn("Some streaming sessions failed");
                } else {
                    LOG.info("Streaming finished successfully");
                }
            } catch (ExecutionException e) {
                throw new RuntimeException(
                        "Streaming to the following hosts failed: " + loader.getFailedHosts(), e);
            }
        } else {
            LOG.info("SSTableWriter wasn't instantiated, no streaming happened.");
        }
    } finally {
        heartbeat.stopHeartbeat();
    }
    LOG.info("Successfully closed bulk record writer");
}