use of com.datastax.oss.dsbulk.executor.api.result.WriteResult in project dsbulk by datastax.
the class LogManager method appendStatement.
@SuppressWarnings("BlockingMethodInNonBlockingContext")
private <R extends Result> Mono<R> appendStatement(R result, String logFileName, boolean appendNewLine) {
try {
Path logFile = operationDirectory.resolve(logFileName);
PrintWriter writer = openFiles.get(logFile);
assert writer != null;
writer.print("Statement: ");
String format = statementFormatter.format(result.getStatement(), statementFormatVerbosity, protocolVersion, codecRegistry);
LogManagerUtils.printAndMaybeAddNewLine(format, writer);
if (result instanceof WriteResult) {
WriteResult writeResult = (WriteResult) result;
// If a conditional update could not be applied, print the failed mutations
if (writeResult.isSuccess() && !writeResult.wasApplied()) {
writer.println("Failed conditional updates: ");
writeResult.getFailedWrites().forEach(row -> {
String failed = rowFormatter.format(row, protocolVersion, codecRegistry);
LogManagerUtils.printAndMaybeAddNewLine(failed, writer);
});
}
}
if (result.getError().isPresent()) {
stackTracePrinter.printStackTrace(result.getError().get(), writer);
}
if (appendNewLine) {
writer.println();
}
writer.flush();
return Mono.just(result);
} catch (Exception e) {
return Mono.error(e);
}
}
use of com.datastax.oss.dsbulk.executor.api.result.WriteResult in project dsbulk by datastax.
the class BulkExecutorTestBase method writeSyncStringTest.
// Tests for synchronous write methods
@Test
void writeSyncStringTest() {
BulkExecutor executor = newBulkExecutor(false);
WriteResult r = executor.writeSync("write should succeed 1");
verifySuccessfulWriteResult(r);
verifySession(1, 0);
}
use of com.datastax.oss.dsbulk.executor.api.result.WriteResult in project dsbulk by datastax.
the class BulkExecutorTestBase method writeAsyncStatementFailSafeTest.
@Test
void writeAsyncStatementFailSafeTest() throws Exception {
BulkExecutor executor = newBulkExecutor(true);
WriteResult r = executor.writeAsync(failed).get();
verifyFailedWriteResult(r);
verifySession(0, 1);
verifyListener(0, 1);
}
use of com.datastax.oss.dsbulk.executor.api.result.WriteResult in project dsbulk by datastax.
the class BulkExecutorTestBase method writeSyncStatementFailSafeTest.
@Test
void writeSyncStatementFailSafeTest() {
BulkExecutor executor = newBulkExecutor(true);
WriteResult r = executor.writeSync(failed);
verifyFailedWriteResult(r);
verifySession(0, 1);
verifyListener(0, 1);
}
use of com.datastax.oss.dsbulk.executor.api.result.WriteResult in project dsbulk by datastax.
the class BulkExecutorTestBase method writeSyncStringFailSafeTest.
@Test
void writeSyncStringFailSafeTest() {
BulkExecutor executor = newBulkExecutor(true);
WriteResult r = executor.writeSync("should fail");
verifyFailedWriteResult(r);
verifySession(0, 1);
verifyListener(0, 1);
}
Aggregations