use of com.eightkdata.mongowp.server.api.Request in project torodb by torodb.
the class OplogOperationApplier method executeTorodCommand.
private <A, R> Status<R> executeTorodCommand(String db, Command<? super A, ? super R> command, A arg, ExclusiveWriteMongodTransaction trans) throws MongoException {
Request req = new Request(db, null, true, null);
Status<R> result = trans.execute(req, command, arg);
return result;
}
use of com.eightkdata.mongowp.server.api.Request in project torodb by torodb.
the class AkkaDbCloner method insertDocuments.
private int insertDocuments(MongodServer localServer, String toDb, String collection, List<BsonDocument> docsToInsert) throws RollbackException {
try (WriteMongodTransaction transaction = createWriteMongodTransaction(localServer)) {
Status<InsertResult> insertResult = transaction.execute(new Request(toDb, null, true, null), InsertCommand.INSTANCE, new InsertArgument.Builder(collection).addDocuments(docsToInsert).setWriteConcern(WriteConcern.fsync()).setOrdered(true).build());
if (!insertResult.isOk()) {
throw new CloningException("Error while inserting a cloned document");
}
int insertedDocs = insertResult.getResult().getN();
if (insertedDocs != docsToInsert.size()) {
throw new CloningException("Expected to insert " + docsToInsert.size() + " but " + insertResult + " were inserted");
}
transaction.commit();
return insertedDocs;
} catch (UserException ex) {
throw new CloningException("Unexpected error while cloning documents", ex);
}
}
Aggregations