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