public static void transitionToStandby(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.transitionToStandby(reqInfo); } catch (RemoteException e) { throw e.unwrapRemoteException(ServiceFailedException.class); } } }
private synchronized void becomeStandby() { LOG.info("ZK Election indicated that " + localTarget + " should become standby"); try { int timeout = FailoverController.getGracefulFenceTimeout(conf); localTarget.getProxy(conf, timeout).transitionToStandby(createReqInfo()); LOG.info("Successfully transitioned " + localTarget + " to standby state"); } catch (Exception e) { LOG.error("Couldn't transition " + localTarget + " to standby state", e); // TODO handle this. It's a likely case since we probably got fenced // at the same time. } serviceState = HAServiceState.STANDBY; }
@Override public TransitionToStandbyResponseProto transitionToStandby( RpcController controller, TransitionToStandbyRequestProto request) throws ServiceException { try { server.transitionToStandby(convert(request.getReqInfo())); return TRANSITION_TO_STANDBY_RESP; } catch(IOException e) { throw new ServiceException(e); } }
boolean needFence = false; try { localTarget.getProxy(conf, timeout).transitionToStandby(createReqInfo()); LOG.info("Successfully ensured local node is in standby mode"); } catch (IOException ioe) {
/** * Try to get the HA state of the node at the given address. This * function is guaranteed to be "quick" -- ie it has a short timeout * and no retries. Its only purpose is to avoid fencing a node that * has already restarted. */ boolean tryGracefulFence(HAServiceTarget svc) { HAServiceProtocol proxy = null; try { proxy = svc.getProxy(gracefulFenceConf, gracefulFenceTimeout); proxy.transitionToStandby(createReqInfo()); return true; } catch (ServiceFailedException sfe) { LOG.warn("Unable to gracefully make {} standby ({})", svc, sfe.getMessage()); } catch (IOException ioe) { LOG.warn("Unable to gracefully make {} standby (unable to connect)", svc, ioe); } finally { if (proxy != null) { RPC.stopProxy(proxy); } } return false; }
public static void transitionToStandby(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.transitionToStandby(reqInfo); } catch (RemoteException e) { throw e.unwrapRemoteException(ServiceFailedException.class); } } }
public static void transitionToStandby(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.transitionToStandby(reqInfo); } catch (RemoteException e) { throw e.unwrapRemoteException(ServiceFailedException.class); } } }
public static void transitionToStandby(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.transitionToStandby(reqInfo); } catch (RemoteException e) { throw e.unwrapRemoteException(ServiceFailedException.class); } } }
public static void transitionToStandby(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.transitionToStandby(reqInfo); } catch (RemoteException e) { throw e.unwrapRemoteException(ServiceFailedException.class); } } }
private synchronized void becomeStandby() { LOG.info("ZK Election indicated that " + localTarget + " should become standby"); try { int timeout = FailoverController.getGracefulFenceTimeout(conf); localTarget.getProxy(conf, timeout).transitionToStandby(createReqInfo()); LOG.info("Successfully transitioned " + localTarget + " to standby state"); } catch (Exception e) { LOG.error("Couldn't transition " + localTarget + " to standby state", e); // TODO handle this. It's a likely case since we probably got fenced // at the same time. } serviceState = HAServiceState.STANDBY; }
private synchronized void becomeStandby() { LOG.info("ZK Election indicated that " + localTarget + " should become standby"); try { int timeout = FailoverController.getGracefulFenceTimeout(conf); localTarget.getProxy(conf, timeout).transitionToStandby(createReqInfo()); LOG.info("Successfully transitioned " + localTarget + " to standby state"); } catch (Exception e) { LOG.error("Couldn't transition " + localTarget + " to standby state", e); // TODO handle this. It's a likely case since we probably got fenced // at the same time. } serviceState = HAServiceState.STANDBY; }
private synchronized void becomeStandby() { LOG.info("ZK Election indicated that " + localTarget + " should become standby"); try { int timeout = FailoverController.getGracefulFenceTimeout(conf); localTarget.getProxy(conf, timeout).transitionToStandby(createReqInfo()); LOG.info("Successfully transitioned " + localTarget + " to standby state"); } catch (Exception e) { LOG.error("Couldn't transition " + localTarget + " to standby state", e); // TODO handle this. It's a likely case since we probably got fenced // at the same time. } serviceState = HAServiceState.STANDBY; }
@Override public TransitionToStandbyResponseProto transitionToStandby( RpcController controller, TransitionToStandbyRequestProto request) throws ServiceException { try { server.transitionToStandby(convert(request.getReqInfo())); return TRANSITION_TO_STANDBY_RESP; } catch(IOException e) { throw new ServiceException(e); } }
@Override public TransitionToStandbyResponseProto transitionToStandby( RpcController controller, TransitionToStandbyRequestProto request) throws ServiceException { try { server.transitionToStandby(convert(request.getReqInfo())); return TRANSITION_TO_STANDBY_RESP; } catch(IOException e) { throw new ServiceException(e); } }
@Override public TransitionToStandbyResponseProto transitionToStandby( RpcController controller, TransitionToStandbyRequestProto request) throws ServiceException { try { server.transitionToStandby(convert(request.getReqInfo())); return TRANSITION_TO_STANDBY_RESP; } catch(IOException e) { throw new ServiceException(e); } }
@Override public TransitionToStandbyResponseProto transitionToStandby( RpcController controller, TransitionToStandbyRequestProto request) throws ServiceException { try { server.transitionToStandby(convert(request.getReqInfo())); return TRANSITION_TO_STANDBY_RESP; } catch(IOException e) { throw new ServiceException(e); } }
@Test public void testTransitionToStandby() throws Exception { assertEquals(0, runTool("-transitionToStandby", "nn1")); Mockito.verify(mockProtocol).transitionToStandby(anyReqInfo()); }
private synchronized void becomeStandby() { LOG.info("ZK Election indicated that " + localTarget + " should become standby"); try { int timeout = FailoverController.getGracefulFenceTimeout(conf); localTarget.getProxy(conf, timeout).transitionToStandby(createReqInfo()); LOG.info("Successfully transitioned " + localTarget + " to standby state"); } catch (Exception e) { LOG.error("Couldn't transition " + localTarget + " to standby state", e); // TODO handle this. It's a likely case since we probably got fenced // at the same time. } serviceState = HAServiceState.STANDBY; }
@Test public void testFailoverFromFaultyServiceSucceeds() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); Mockito.doThrow(new ServiceFailedException("Failed!")) .when(svc1.proxy).transitionToStandby(anyReqInfo()); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); AlwaysSucceedFencer.fenceCalled = 0; try { doFailover(svc1, svc2, false, false); } catch (FailoverFailedException ffe) { fail("Faulty active prevented failover"); } // svc1 still thinks it's active, that's OK, it was fenced assertEquals(1, AlwaysSucceedFencer.fenceCalled); assertSame(svc1, AlwaysSucceedFencer.fencedSvc); assertEquals(HAServiceState.ACTIVE, svc1.state); assertEquals(HAServiceState.ACTIVE, svc2.state); }
@Test public void testFailoverFromFaultyServiceFencingFailure() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); Mockito.doThrow(new ServiceFailedException("Failed!")) .when(svc1.proxy).transitionToStandby(anyReqInfo()); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); svc1.fencer = svc2.fencer = setupFencer(AlwaysFailFencer.class.getName()); AlwaysFailFencer.fenceCalled = 0; try { doFailover(svc1, svc2, false, false); fail("Failed over even though fencing failed"); } catch (FailoverFailedException ffe) { // Expected } assertEquals(1, AlwaysFailFencer.fenceCalled); assertSame(svc1, AlwaysFailFencer.fencedSvc); assertEquals(HAServiceState.ACTIVE, svc1.state); assertEquals(HAServiceState.STANDBY, svc2.state); }