@Override public MonitorHealthResponseProto monitorHealth(RpcController controller, MonitorHealthRequestProto request) throws ServiceException { try { server.monitorHealth(); return MONITOR_HEALTH_RESP; } catch(IOException e) { throw new ServiceException(e); } }
public static void monitorHealth(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.monitorHealth(); } catch (RemoteException e) { throw e.unwrapRemoteException(HealthCheckFailedException.class); } }
try { status = proxy.getServiceStatus(); proxy.monitorHealth(); healthy = true; } catch (Throwable t) {
@Override public MonitorHealthResponseProto monitorHealth(RpcController controller, MonitorHealthRequestProto request) throws ServiceException { try { server.monitorHealth(); return MONITOR_HEALTH_RESP; } catch(IOException e) { throw new ServiceException(e); } }
@Override public MonitorHealthResponseProto monitorHealth(RpcController controller, MonitorHealthRequestProto request) throws ServiceException { try { server.monitorHealth(); return MONITOR_HEALTH_RESP; } catch(IOException e) { throw new ServiceException(e); } }
public static void monitorHealth(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.monitorHealth(); } catch (RemoteException e) { throw e.unwrapRemoteException(HealthCheckFailedException.class); } }
public static void monitorHealth(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.monitorHealth(); } catch (RemoteException e) { throw e.unwrapRemoteException(HealthCheckFailedException.class); } }
@Override public MonitorHealthResponseProto monitorHealth(RpcController controller, MonitorHealthRequestProto request) throws ServiceException { try { server.monitorHealth(); return MONITOR_HEALTH_RESP; } catch(IOException e) { throw new ServiceException(e); } }
@Override public MonitorHealthResponseProto monitorHealth(RpcController controller, MonitorHealthRequestProto request) throws ServiceException { try { server.monitorHealth(); return MONITOR_HEALTH_RESP; } catch(IOException e) { throw new ServiceException(e); } }
public static void monitorHealth(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.monitorHealth(); } catch (RemoteException e) { throw e.unwrapRemoteException(HealthCheckFailedException.class); } }
public static void monitorHealth(HAServiceProtocol svc, StateChangeRequestInfo reqInfo) throws IOException { try { svc.monitorHealth(); } catch (RemoteException e) { throw e.unwrapRemoteException(HealthCheckFailedException.class); } }
try { status = proxy.getServiceStatus(); proxy.monitorHealth(); healthy = true; } catch (Throwable t) {
try { status = proxy.getServiceStatus(); proxy.monitorHealth(); healthy = true; } catch (Throwable t) {
try { status = proxy.getServiceStatus(); proxy.monitorHealth(); healthy = true; } catch (Throwable t) {
@Test public void testCheckHealth() throws Exception { assertEquals(0, runTool("-checkHealth", "nn1")); Mockito.verify(mockProtocol).monitorHealth(); Mockito.doThrow(new HealthCheckFailedException("fake health check failure")) .when(mockProtocol).monitorHealth(); assertEquals(-1, runTool("-checkHealth", "nn1")); assertOutputContains("Health check failed: fake health check failure"); }
/** * Have the services fail their health checks half the time, * causing the master role to bounce back and forth in the * cluster. Meanwhile, causes ZK to disconnect clients every * 50ms, to trigger the retry code and failures to become active. */ @Test(timeout=(STRESS_RUNTIME_SECS + EXTRA_TIMEOUT_SECS) * 1000) public void testRandomHealthAndDisconnects() throws Exception { long runFor = STRESS_RUNTIME_SECS * 1000; Mockito.doAnswer(new RandomlyThrow(0)) .when(cluster.getService(0).proxy).monitorHealth(); Mockito.doAnswer(new RandomlyThrow(1)) .when(cluster.getService(1).proxy).monitorHealth(); conf.setInt(CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_KEY, 100); // Don't start until after the above mocking. Otherwise we can get // Mockito errors if the HM calls the proxy in the middle of // setting up the mock. cluster.start(); long st = Time.now(); while (Time.now() - st < runFor) { cluster.getTestContext().checkException(); serverFactory.closeAll(); Thread.sleep(50); } }
/** * Have the services fail their health checks half the time, * causing the master role to bounce back and forth in the * cluster. Meanwhile, causes ZK to disconnect clients every * 50ms, to trigger the retry code and failures to become active. */ @Test(timeout=(STRESS_RUNTIME_SECS + EXTRA_TIMEOUT_SECS) * 1000) public void testRandomHealthAndDisconnects() throws Exception { long runFor = STRESS_RUNTIME_SECS * 1000; Mockito.doAnswer(new RandomlyThrow(0)) .when(cluster.getService(0).proxy).monitorHealth(); Mockito.doAnswer(new RandomlyThrow(1)) .when(cluster.getService(1).proxy).monitorHealth(); conf.setInt(CommonConfigurationKeys.HA_FC_ELECTOR_ZK_OP_RETRIES_KEY, 100); // Don't start until after the above mocking. Otherwise we can get // Mockito errors if the HM calls the proxy in the middle of // setting up the mock. cluster.start(); long st = Time.now(); while (Time.now() - st < runFor) { cluster.getTestContext().checkException(); serverFactory.closeAll(); Thread.sleep(50); } }
/** * Test that, even if automatic HA is enabled, the monitoring operations * still function correctly. */ @Test public void testMonitoringOperationsWithAutoHaEnabled() throws Exception { Mockito.doReturn(STANDBY_READY_RESULT).when(mockProtocol).getServiceStatus(); // Turn on auto-HA HdfsConfiguration conf = getHAConf(); conf.setBoolean(DFSConfigKeys.DFS_HA_AUTO_FAILOVER_ENABLED_KEY, true); tool.setConf(conf); assertEquals(0, runTool("-checkHealth", "nn1")); Mockito.verify(mockProtocol).monitorHealth(); assertEquals(0, runTool("-getServiceState", "nn1")); Mockito.verify(mockProtocol).getServiceStatus(); }
@Test public void testFailoverToUnhealthyServiceFailsAndFailsback() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); Mockito.doThrow(new HealthCheckFailedException("Failed!")) .when(svc2.proxy).monitorHealth(); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); try { doFailover(svc1, svc2, false, false); fail("Failover to unhealthy service"); } catch (FailoverFailedException ffe) { // Expected } assertEquals(HAServiceState.ACTIVE, svc1.state); assertEquals(HAServiceState.STANDBY, svc2.state); }
@Test public void testFailoverToUnhealthyServiceFailsAndFailsback() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); Mockito.doThrow(new HealthCheckFailedException("Failed!")) .when(svc2.proxy).monitorHealth(); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); try { doFailover(svc1, svc2, false, false); fail("Failover to unhealthy service"); } catch (FailoverFailedException ffe) { // Expected } assertEquals(HAServiceState.ACTIVE, svc1.state); assertEquals(HAServiceState.STANDBY, svc2.state); }