@Override public void run() { // ensure we don't run this task multiple times synchronized (this) { // quick exit if we already marked the task complete if (TimeoutExceptionInjector.this.complete) return; // mark the task is run, to avoid repeats TimeoutExceptionInjector.this.complete = true; } long end = EnvironmentEdgeManager.currentTime(); TimeoutException tee = new TimeoutException( "Timeout caused Foreign Exception", start, end, maxTime); String source = "timer-" + timer; listener.receive(new ForeignException(source, tee)); } };
@Override public Void answer(InvocationOnMock invocation) throws Throwable { int index = elem[0]; if (index == memberErrorIndex) { LOG.debug("Sending error to coordinator"); ForeignException remoteCause = new ForeignException("TIMER", new TimeoutException("subprocTimeout" , 1, 2, 0)); Subprocedure r = ((Subprocedure) invocation.getMock()); LOG.error("Remote commit failure, not propagating error:" + remoteCause); comms.receiveAbortProcedure(r.getName(), remoteCause); assertTrue(r.isComplete()); // don't complete the error phase until the coordinator has gotten the error // notification (which ensures that we never progress past prepare) try { Procedure.waitForLatch(coordinatorReceivedErrorLatch, new ForeignExceptionDispatcher(), WAKE_FREQUENCY, "coordinator received error"); } catch (InterruptedException e) { LOG.debug("Wait for latch interrupted, done:" + (coordinatorReceivedErrorLatch.getCount() == 0)); // reset the interrupt status on the thread Thread.currentThread().interrupt(); } } elem[0] = ++index; return null; } }).when(commit).acquireBarrier();
public void testMemberCommitCommsFailure() throws Exception { buildCohortMemberPair(); final TimeoutException oate = new TimeoutException("bogus timeout",1,2,0); doAnswer( new Answer<Void>() {
final TimeoutException oate = new TimeoutException("bogus timeout", 1,2,0); doAnswer( new Answer<Void>() {
@Override public void run() { // ensure we don't run this task multiple times synchronized (this) { // quick exit if we already marked the task complete if (TimeoutExceptionInjector.this.complete) return; // mark the task is run, to avoid repeats TimeoutExceptionInjector.this.complete = true; } long end = EnvironmentEdgeManager.currentTimeMillis(); TimeoutException tee = new TimeoutException( "Timeout caused Foreign Exception", start, end, maxTime); String source = "timer-" + timer; listener.receive(new ForeignException(source, tee)); } };
@Override public void run() { // ensure we don't run this task multiple times synchronized (this) { // quick exit if we already marked the task complete if (TimeoutExceptionInjector.this.complete) return; // mark the task is run, to avoid repeats TimeoutExceptionInjector.this.complete = true; } long end = EnvironmentEdgeManager.currentTime(); TimeoutException tee = new TimeoutException( "Timeout caused Foreign Exception", start, end, maxTime); String source = "timer-" + timer; listener.receive(new ForeignException(source, tee)); } };
@Override public Void answer(InvocationOnMock invocation) throws Throwable { int index = elem[0]; if (index == memberErrorIndex) { LOG.debug("Sending error to coordinator"); ForeignException remoteCause = new ForeignException("TIMER", new TimeoutException("subprocTimeout" , 1, 2, 0)); Subprocedure r = ((Subprocedure) invocation.getMock()); LOG.error("Remote commit failure, not propagating error:" + remoteCause); comms.receiveAbortProcedure(r.getName(), remoteCause); assertTrue(r.isComplete()); // don't complete the error phase until the coordinator has gotten the error // notification (which ensures that we never progress past prepare) try { Procedure.waitForLatch(coordinatorReceivedErrorLatch, new ForeignExceptionDispatcher(), WAKE_FREQUENCY, "coordinator received error"); } catch (InterruptedException e) { LOG.debug("Wait for latch interrupted, done:" + (coordinatorReceivedErrorLatch.getCount() == 0)); // reset the interrupt status on the thread Thread.currentThread().interrupt(); } } elem[0] = ++index; return null; } }).when(commit).acquireBarrier();
final TimeoutException oate = new TimeoutException("bogus timeout", 1,2,0); doAnswer( new Answer<Void>() {
public void testMemberCommitCommsFailure() throws Exception { buildCohortMemberPair(); final TimeoutException oate = new TimeoutException("bogus timeout",1,2,0); doAnswer( new Answer<Void>() {