@Test public void testErrorOnExpirationFutureTriggersRejoin() throws Exception { when(serviceNode.join()).thenReturn( Futures.<ServiceNode.Lease>immediateFuture(lease), SettableFuture.<ServiceNode.Lease>create()); when(lease.getExpirationFuture()).thenReturn(Futures.<Void>immediateFailedFuture(new Exception("boom"))); ThriftEventHandler handler = new ThriftEventHandler(serviceHandler, serviceNode); handler.preServe(); InOrder inOrder = inOrder(serviceNode, lease, serviceHandler); inOrder.verify(serviceNode).join(); inOrder.verify(serviceHandler).onJoin(); inOrder.verify(lease).getExpirationFuture(); inOrder.verify(serviceHandler).onLeave(); inOrder.verify(serviceNode).join(); verifyNoMoreInteractions(serviceHandler, serviceNode, lease); }
@Override public void preServe() { ServiceNodeUtils.joinService(serviceNode, retryIntervalMsec, serviceNodeEventHandler); }
ThriftEventHandler implements TServerEventHandler { @Override public void preServe() { ServiceNodeUtils.joinService(serviceNode, retryIntervalMsec, serviceNodeEventHandler); } }
ThriftEventHandler implements TServerEventHandler { @Override public void preServe() { ServiceNodeUtils.joinService(serviceNode, retryIntervalMsec, serviceNodeEventHandler); } @Inject  ThriftEventHandler(@Assisted ServiceNodeEventHandler serviceNodeEventHandler,
                            @Assisted ServiceNode serviceNode); }
ThriftEventHandler implements TServerEventHandler { @Override public void preServe() { ServiceNodeUtils.joinService(serviceNode, retryIntervalMsec, serviceNodeEventHandler); } @Inject  ThriftEventHandler(@Assisted ServiceNodeEventHandler serviceNodeEventHandler,
                            @Assisted ServiceNode serviceNode); @Override void preServe(); @Override ServerContext createContext(TProtocol input, TProtocol output); @Override void deleteContext(ServerContext serverContext, TProtocol input, TProtocol output); @Override void processContext(ServerContext serverContext, TTransport inputTransport, TTransport outputTransport); }
ThriftEventHandler implements TServerEventHandler { @Override public void preServe() { ServiceNodeUtils.joinService(serviceNode, retryIntervalMsec, serviceNodeEventHandler); } @Inject  ThriftEventHandler(@Assisted ServiceNodeEventHandler serviceNodeEventHandler,
                            @Assisted ServiceNode serviceNode); @Override void preServe(); @Override ServerContext createContext(TProtocol input, TProtocol output); @Override void deleteContext(ServerContext serverContext, TProtocol input, TProtocol output); @Override void processContext(ServerContext serverContext, TTransport inputTransport, TTransport outputTransport);  }