Search in sources :

Example 1 with CollectionOplogOperation

use of com.eightkdata.mongowp.server.api.oplog.CollectionOplogOperation in project torodb by torodb.

the class BatchAnalyzer method apply.

@Override
public List<AnalyzedOplogBatch> apply(List<OplogOperation> oplogOps) {
    List<AnalyzedOplogBatch> result = new ArrayList<>();
    int fromExcluded = -1;
    for (int i = 0; i < oplogOps.size(); i++) {
        OplogOperation op = oplogOps.get(i);
        switch(op.getType()) {
            case DB:
            case NOOP:
                LOGGER.debug("Ignoring operation {}", op);
                break;
            case DB_CMD:
                addParallelToBatch(oplogOps, fromExcluded, i, result);
                fromExcluded = i;
                result.add(new SingleOpAnalyzedOplogBatch((DbCmdOplogOperation) op));
                break;
            case DELETE:
            case INSERT:
            case UPDATE:
                {
                    //CUD operations on system collection must be addressed sequentially
                    if (SYSTEM_COLLECTIONS.contains(((CollectionOplogOperation) op).getCollection())) {
                        addParallelToBatch(oplogOps, fromExcluded, i, result);
                        fromExcluded = i;
                        result.add(new SingleOpAnalyzedOplogBatch(op));
                    }
                    break;
                }
            default:
                throw new AssertionError("Found an unknown oplog operation " + op);
        }
    }
    addParallelToBatch(oplogOps, fromExcluded, oplogOps.size(), result);
    return result;
}
Also used : ArrayList(java.util.ArrayList) DbCmdOplogOperation(com.eightkdata.mongowp.server.api.oplog.DbCmdOplogOperation) CollectionOplogOperation(com.eightkdata.mongowp.server.api.oplog.CollectionOplogOperation) DbCmdOplogOperation(com.eightkdata.mongowp.server.api.oplog.DbCmdOplogOperation) OplogOperation(com.eightkdata.mongowp.server.api.oplog.OplogOperation) CollectionOplogOperation(com.eightkdata.mongowp.server.api.oplog.CollectionOplogOperation)

Aggregations

CollectionOplogOperation (com.eightkdata.mongowp.server.api.oplog.CollectionOplogOperation)1 DbCmdOplogOperation (com.eightkdata.mongowp.server.api.oplog.DbCmdOplogOperation)1 OplogOperation (com.eightkdata.mongowp.server.api.oplog.OplogOperation)1 ArrayList (java.util.ArrayList)1