Search in sources :

Example 1 with Stopwatch

use of com.datastax.oss.driver.shaded.guava.common.base.Stopwatch in project dsbulk by datastax.

the class CountWorkflow method execute.

@Override
public boolean execute() {
    LOGGER.debug("{} started.", this);
    metricsManager.start();
    Stopwatch timer = Stopwatch.createStarted();
    Flux.fromIterable(readStatements).flatMap(statement -> Flux.from(executor.readReactive(statement)).transform(queryWarningsHandler).transform(totalItemsMonitor).transform(totalItemsCounter).transform(failedItemsMonitor).transform(failedReadsHandler).doOnNext(readResultCounter.newCountingUnit()::update).then().subscribeOn(scheduler), readConcurrency).transform(terminationHandler).blockLast();
    timer.stop();
    int totalErrors = logManager.getTotalErrors();
    metricsManager.stop(timer.elapsed(), totalErrors == 0);
    Duration elapsed = DurationUtils.round(timer.elapsed(), TimeUnit.SECONDS);
    String elapsedStr = elapsed.isZero() ? "less than one second" : DurationUtils.formatDuration(elapsed);
    if (totalErrors == 0) {
        success = true;
        LOGGER.info("{} completed successfully in {}.", this, elapsedStr);
    } else {
        LOGGER.warn("{} completed with {} errors in {}.", this, totalErrors, elapsedStr);
    }
    return totalErrors == 0;
}
Also used : Stopwatch(com.datastax.oss.driver.shaded.guava.common.base.Stopwatch) Duration(java.time.Duration)

Example 2 with Stopwatch

use of com.datastax.oss.driver.shaded.guava.common.base.Stopwatch in project dsbulk by datastax.

the class LoadWorkflow method execute.

@Override
public boolean execute() {
    LOGGER.debug("{} started.", this);
    metricsManager.start();
    Stopwatch timer = Stopwatch.createStarted();
    Flux<Statement<?>> statements;
    if (hasManyReaders) {
        statements = manyReaders();
    } else {
        statements = fewReaders();
    }
    statements.transform(this::executeStatements).transform(queryWarningsHandler).transform(failedWritesHandler).transform(resultPositionsHndler).transform(terminationHandler).blockLast();
    timer.stop();
    int totalErrors = logManager.getTotalErrors();
    metricsManager.stop(timer.elapsed(), totalErrors == 0);
    Duration elapsed = DurationUtils.round(timer.elapsed(), TimeUnit.SECONDS);
    String elapsedStr = elapsed.isZero() ? "less than one second" : DurationUtils.formatDuration(elapsed);
    if (totalErrors == 0) {
        LOGGER.info("{} completed successfully in {}.", this, elapsedStr);
    } else {
        LOGGER.warn("{} completed with {} errors in {}.", this, totalErrors, elapsedStr);
    }
    return totalErrors == 0;
}
Also used : BoundStatement(com.datastax.oss.driver.api.core.cql.BoundStatement) BatchableStatement(com.datastax.oss.driver.api.core.cql.BatchableStatement) Statement(com.datastax.oss.driver.api.core.cql.Statement) Stopwatch(com.datastax.oss.driver.shaded.guava.common.base.Stopwatch) Duration(java.time.Duration)

Example 3 with Stopwatch

use of com.datastax.oss.driver.shaded.guava.common.base.Stopwatch in project dsbulk by datastax.

the class UnloadWorkflow method execute.

@Override
public boolean execute() {
    LOGGER.debug("{} started.", this);
    metricsManager.start();
    Flux<Record> flux;
    if (writeConcurrency == 1) {
        flux = oneWriter();
    } else if (writeConcurrency < numCores / 2 || readConcurrency < numCores / 2) {
        flux = fewWriters();
    } else {
        flux = manyWriters();
    }
    Stopwatch timer = Stopwatch.createStarted();
    flux.then().flux().transform(terminationHandler).blockLast();
    timer.stop();
    int totalErrors = logManager.getTotalErrors();
    metricsManager.stop(timer.elapsed(), totalErrors == 0);
    Duration elapsed = DurationUtils.round(timer.elapsed(), TimeUnit.SECONDS);
    String elapsedStr = elapsed.isZero() ? "less than one second" : DurationUtils.formatDuration(elapsed);
    if (totalErrors == 0) {
        LOGGER.info("{} completed successfully in {}.", this, elapsedStr);
    } else {
        LOGGER.warn("{} completed with {} errors in {}.", this, totalErrors, elapsedStr);
    }
    return totalErrors == 0;
}
Also used : Stopwatch(com.datastax.oss.driver.shaded.guava.common.base.Stopwatch) Record(com.datastax.oss.dsbulk.connectors.api.Record) Duration(java.time.Duration)

Aggregations

Stopwatch (com.datastax.oss.driver.shaded.guava.common.base.Stopwatch)3 Duration (java.time.Duration)3 BatchableStatement (com.datastax.oss.driver.api.core.cql.BatchableStatement)1 BoundStatement (com.datastax.oss.driver.api.core.cql.BoundStatement)1 Statement (com.datastax.oss.driver.api.core.cql.Statement)1 Record (com.datastax.oss.dsbulk.connectors.api.Record)1