ShardPreCommitCoordinationTask implements Callable<Void> { @Override public Void call() throws TransactionCommitFailedException { try { LOG.debug("Shard {}, preCommit started", rootShardPrefix); preCommitBlocking(); return null; } catch (final TransactionCommitFailedException e) { LOG.warn("Shard: {} Submit Error during phase PreCommit, starting Abort", rootShardPrefix, e); throw e; } } ShardPreCommitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
                                       final Collection<DOMStoreThreePhaseCommitCohort> cohorts); @Override Void call();  }
@Test public void basicTest() throws Exception { doReturn(Void.TYPE).when(LISTENABLE_FUTURE).get(); doReturn(LISTENABLE_FUTURE).when(DOM_STORE_THREE_PHASE_COMMIT_COHORT).preCommit(); COHORTS.add(DOM_STORE_THREE_PHASE_COMMIT_COHORT); ShardPreCommitCoordinationTask shardPreCommitCoordinationTask = new ShardPreCommitCoordinationTask(DOM_DATA_TREE_IDENTIFIER, COHORTS); shardPreCommitCoordinationTask.call(); verify(DOM_STORE_THREE_PHASE_COMMIT_COHORT).preCommit(); }
@Test(expected = TransactionCommitFailedException.class) public void exceptionCallTest() throws Exception { doThrow(new InterruptedException()).when(LISTENABLE_FUTURE).get(); doReturn(LISTENABLE_FUTURE).when(DOM_STORE_THREE_PHASE_COMMIT_COHORT).preCommit(); COHORTS.add(DOM_STORE_THREE_PHASE_COMMIT_COHORT); ShardPreCommitCoordinationTask shardPreCommitCoordinationTask = new ShardPreCommitCoordinationTask(DOM_DATA_TREE_IDENTIFIER, COHORTS); shardPreCommitCoordinationTask.call(); }