Search in sources :

Example 1 with CreateIndexesCommand

use of com.torodb.mongodb.commands.signatures.admin.CreateIndexesCommand in project torodb by torodb.

the class OplogOperationApplier method insertIndex.

private void insertIndex(BsonDocument indexDoc, String database, ExclusiveWriteMongodTransaction trans) throws OplogApplyingException {
    try {
        CreateIndexesCommand command = CreateIndexesCommand.INSTANCE;
        IndexOptions indexOptions = IndexOptions.unmarshall(indexDoc);
        CreateIndexesArgument arg = new CreateIndexesArgument(indexOptions.getCollection(), Arrays.asList(new IndexOptions[] { indexOptions }));
        Status executionResult = executeReplCommand(database, command, arg, trans.getTorodTransaction());
        if (!executionResult.isOk()) {
            throw new OplogApplyingException(new MongoException(executionResult));
        }
    } catch (MongoException ex) {
        throw new OplogApplyingException(ex);
    }
}
Also used : Status(com.eightkdata.mongowp.Status) MongoException(com.eightkdata.mongowp.exceptions.MongoException) CreateIndexesArgument(com.torodb.mongodb.commands.signatures.admin.CreateIndexesCommand.CreateIndexesArgument) IndexOptions(com.torodb.mongodb.commands.pojos.index.IndexOptions) CreateIndexesCommand(com.torodb.mongodb.commands.signatures.admin.CreateIndexesCommand)

Aggregations

Status (com.eightkdata.mongowp.Status)1 MongoException (com.eightkdata.mongowp.exceptions.MongoException)1 IndexOptions (com.torodb.mongodb.commands.pojos.index.IndexOptions)1 CreateIndexesCommand (com.torodb.mongodb.commands.signatures.admin.CreateIndexesCommand)1 CreateIndexesArgument (com.torodb.mongodb.commands.signatures.admin.CreateIndexesCommand.CreateIndexesArgument)1