Search in sources :

Example 1 with MongodConnection

use of com.torodb.mongodb.core.MongodConnection in project torodb by torodb.

the class TorodbSafeRequestProcessor method openConnection.

@Override
public MongodConnection openConnection() {
    MongodConnection connection = server.openConnection();
    LOGGER.info("Accepted connection {}", connection.getConnectionId());
    return connection;
}
Also used : MongodConnection(com.torodb.mongodb.core.MongodConnection)

Example 2 with MongodConnection

use of com.torodb.mongodb.core.MongodConnection in project torodb by torodb.

the class SimpleAnalyzedOplogBatchExecutor method execute.

@Override
public void execute(OplogOperation op, ApplierContext context) throws OplogApplyingException, RollbackException, UserException {
    try (MongodConnection connection = server.openConnection();
        ExclusiveWriteMongodTransaction mongoTransaction = connection.openExclusiveWriteTransaction()) {
        oplogOperationApplier.apply(op, mongoTransaction, context);
        mongoTransaction.commit();
    }
}
Also used : MongodConnection(com.torodb.mongodb.core.MongodConnection) ExclusiveWriteMongodTransaction(com.torodb.mongodb.core.ExclusiveWriteMongodTransaction)

Example 3 with MongodConnection

use of com.torodb.mongodb.core.MongodConnection in project torodb by torodb.

the class BDDOplogTest method execute.

@Override
public void execute(OplogTestContext context) throws Exception {
    MongodServer server = context.getMongodServer();
    try (MongodConnection conn = server.openConnection()) {
        try (WriteMongodTransaction trans = conn.openWriteTransaction(true)) {
            given(trans);
            trans.commit();
        }
    }
    context.apply(streamOplog(), getApplierContext());
    try (MongodConnection conn = server.openConnection()) {
        try (ReadOnlyMongodTransaction trans = conn.openReadOnlyTransaction()) {
            then(trans);
        }
    }
}
Also used : WriteMongodTransaction(com.torodb.mongodb.core.WriteMongodTransaction) ReadOnlyMongodTransaction(com.torodb.mongodb.core.ReadOnlyMongodTransaction) MongodConnection(com.torodb.mongodb.core.MongodConnection) MongodServer(com.torodb.mongodb.core.MongodServer)

Example 4 with MongodConnection

use of com.torodb.mongodb.core.MongodConnection in project torodb by torodb.

the class AkkaDbCloner method createWriteMongodTransaction.

private WriteMongodTransaction createWriteMongodTransaction(MongodServer server) {
    MongodConnection connection = server.openConnection();
    WriteMongodTransaction delegateTransaction = connection.openWriteTransaction();
    return new CloseConnectionWriteMongodTransaction(delegateTransaction);
}
Also used : WriteMongodTransaction(com.torodb.mongodb.core.WriteMongodTransaction) MongodConnection(com.torodb.mongodb.core.MongodConnection)

Aggregations

MongodConnection (com.torodb.mongodb.core.MongodConnection)4 WriteMongodTransaction (com.torodb.mongodb.core.WriteMongodTransaction)2 ExclusiveWriteMongodTransaction (com.torodb.mongodb.core.ExclusiveWriteMongodTransaction)1 MongodServer (com.torodb.mongodb.core.MongodServer)1 ReadOnlyMongodTransaction (com.torodb.mongodb.core.ReadOnlyMongodTransaction)1