BalanceIndexOperation extends AbstractIndexOperation { @Override public ExecutionInstruction getExecutionInstruction(List<MasterOperation> runningOperations) throws Exception { for (MasterOperation operation : runningOperations) { if (operation instanceof BalanceIndexOperation && ((BalanceIndexOperation) operation)._indexName.equals(_indexName)) { return ExecutionInstruction.CANCEL; } } return ExecutionInstruction.EXECUTE; } BalanceIndexOperation(String indexName); @Override List<OperationId> execute(MasterContext context, List<MasterOperation> runningOperations); @Override void nodeOperationsComplete(MasterContext context, List<OperationResult> results); @Override ExecutionInstruction getExecutionInstruction(List<MasterOperation> runningOperations); @Override String toString();  }
@Test public void testGetExecutionInstruction() throws Exception { MasterOperation op1 = new BalanceIndexOperation("index1"); MasterOperation op2 = new BalanceIndexOperation("index1"); assertEquals(ExecutionInstruction.EXECUTE, op1.getExecutionInstruction(EMPTY_LIST)); assertEquals(ExecutionInstruction.CANCEL, op2.getExecutionInstruction(Arrays.asList(op1))); }