private static void changeHandlerThread(InvocationHandler handler, Thread oldThread, Thread newThread) { if (handler instanceof ThreadConfinedProxy) { ((ThreadConfinedProxy) handler).changeThread(oldThread, newThread); } if (handler instanceof DelegatingInvocationHandler) { changeThread(((DelegatingInvocationHandler) handler).getDelegate(), oldThread, newThread); } }
@Test public void learnerRecovery() { for (int i = 0; i < NUM_POTENTIAL_LEADERS * 3; i++) { state.gainLeadership(i % NUM_POTENTIAL_LEADERS); } PaxosLearnerImpl learner = (PaxosLearnerImpl) ((DelegatingInvocationHandler) Proxy.getInvocationHandler(state.learner(0))).getDelegate(); PaxosStateLog<PaxosValue> log = learner.log; SortedMap<Long, PaxosValue> cache = learner.state; log.truncate(log.getGreatestLogEntry()); cache.clear(); state.gainLeadership(0); } }
private static void changeHandlerThread(InvocationHandler handler, Thread oldThread, Thread newThread) { if (handler instanceof ThreadConfinedProxy) { ((ThreadConfinedProxy) handler).changeThread(oldThread, newThread); } if (handler instanceof DelegatingInvocationHandler) { changeThread(((DelegatingInvocationHandler) handler).getDelegate(), oldThread, newThread); } }