throw new FailoverFailedException("Unable to fence " + fromSvc + ". Fencing failed."); } catch (FailoverFailedException ffe) { msg += ". Failback to " + fromSvc + " failed (" + ffe.getMessage() + ")"; LOG.error(msg); throw new FailoverFailedException(msg, cause);
out.println("Failover from "+args[0]+" to "+args[1]+" successful"); } catch (FailoverFailedException ffe) { errOut.println("Failover failed: " + ffe.getLocalizedMessage()); return -1;
throw new FailoverFailedException( "Can't failover a service to itself"); String msg = "Unable to get service state for " + target; LOG.error(msg, e); throw new FailoverFailedException(msg, e); throw new FailoverFailedException( "Can't failover to an active service"); String notReadyReason = toSvcStatus.getNotReadyReason(); if (!forceActive) { throw new FailoverFailedException( target + " is not ready to become active: " + notReadyReason); HAServiceProtocolHelper.monitorHealth(toSvc, createReqInfo()); } catch (HealthCheckFailedException hce) { throw new FailoverFailedException( "Can't failover to an unhealthy service", hce); } catch (IOException e) { throw new FailoverFailedException( "Got an IO exception", e);
@Test public void testFailoverToUnreadyService() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); Mockito.doReturn(STATE_NOT_READY).when(svc2.proxy) .getServiceStatus(); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); try { doFailover(svc1, svc2, false, false); fail("Can't failover to a service that's not ready"); } catch (FailoverFailedException ffe) { // Expected if (!ffe.getMessage().contains("injected not ready")) { throw ffe; } } assertEquals(HAServiceState.ACTIVE, svc1.state); assertEquals(HAServiceState.STANDBY, svc2.state); // Forcing it means we ignore readyToBecomeActive doFailover(svc1, svc2, false, true); assertEquals(HAServiceState.STANDBY, svc1.state); assertEquals(HAServiceState.ACTIVE, svc2.state); }
@Test public void testFailoverWithoutPermission() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); Mockito.doThrow(new AccessControlException("Access denied")) .when(svc1.proxy).getServiceStatus(); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); Mockito.doThrow(new AccessControlException("Access denied")) .when(svc2.proxy).getServiceStatus(); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); try { doFailover(svc1, svc2, false, false); fail("Can't failover when access is denied"); } catch (FailoverFailedException ffe) { assertTrue(ffe.getCause().getMessage().contains("Access denied")); } }
throw new FailoverFailedException( "Can't failover a service to itself"); String msg = "Unable to get service state for " + target; LOG.error(msg + ": " + e.getLocalizedMessage()); throw new FailoverFailedException(msg, e); throw new FailoverFailedException( "Can't failover to an active service"); String notReadyReason = toSvcStatus.getNotReadyReason(); if (!forceActive) { throw new FailoverFailedException( target + " is not ready to become active: " + notReadyReason); HAServiceProtocolHelper.monitorHealth(toSvc, createReqInfo()); } catch (HealthCheckFailedException hce) { throw new FailoverFailedException( "Can't failover to an unhealthy service", hce); } catch (IOException e) { throw new FailoverFailedException( "Got an IO exception", e);
@Test public void testFailoverToUnreadyService() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); Mockito.doReturn(STATE_NOT_READY).when(svc2.proxy) .getServiceStatus(); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); try { doFailover(svc1, svc2, false, false); fail("Can't failover to a service that's not ready"); } catch (FailoverFailedException ffe) { // Expected if (!ffe.getMessage().contains("injected not ready")) { throw ffe; } } assertEquals(HAServiceState.ACTIVE, svc1.state); assertEquals(HAServiceState.STANDBY, svc2.state); // Forcing it means we ignore readyToBecomeActive doFailover(svc1, svc2, false, true); assertEquals(HAServiceState.STANDBY, svc1.state); assertEquals(HAServiceState.ACTIVE, svc2.state); }
@Test public void testFailoverWithoutPermission() throws Exception { DummyHAService svc1 = new DummyHAService(HAServiceState.ACTIVE, svc1Addr); Mockito.doThrow(new AccessControlException("Access denied")) .when(svc1.proxy).getServiceStatus(); DummyHAService svc2 = new DummyHAService(HAServiceState.STANDBY, svc2Addr); Mockito.doThrow(new AccessControlException("Access denied")) .when(svc2.proxy).getServiceStatus(); svc1.fencer = svc2.fencer = setupFencer(AlwaysSucceedFencer.class.getName()); try { doFailover(svc1, svc2, false, false); fail("Can't failover when access is denied"); } catch (FailoverFailedException ffe) { assertTrue(ffe.getCause().getMessage().contains("Access denied")); } }
throw new FailoverFailedException("Unable to fence " + fromSvc + ". Fencing failed."); } catch (FailoverFailedException ffe) { msg += ". Failback to " + fromSvc + " failed (" + ffe.getMessage() + ")"; LOG.fatal(msg); throw new FailoverFailedException(msg, cause);
out.println("Failover from "+args[0]+" to "+args[1]+" successful"); } catch (FailoverFailedException ffe) { errOut.println("Failover failed: " + ffe.getLocalizedMessage()); return -1;
throw new FailoverFailedException( "Can't failover a service to itself"); String msg = "Unable to get service state for " + target; LOG.error(msg + ": " + e.getLocalizedMessage()); throw new FailoverFailedException(msg, e); throw new FailoverFailedException( "Can't failover to an active service"); String notReadyReason = toSvcStatus.getNotReadyReason(); if (!forceActive) { throw new FailoverFailedException( target + " is not ready to become active: " + notReadyReason); HAServiceProtocolHelper.monitorHealth(toSvc, createReqInfo()); } catch (HealthCheckFailedException hce) { throw new FailoverFailedException( "Can't failover to an unhealthy service", hce); } catch (IOException e) { throw new FailoverFailedException( "Got an IO exception", e);
throw new FailoverFailedException("Unable to fence " + fromSvc + ". Fencing failed."); } catch (FailoverFailedException ffe) { msg += ". Failback to " + fromSvc + " failed (" + ffe.getMessage() + ")"; LOG.fatal(msg); throw new FailoverFailedException(msg, cause);
out.println("Failover from "+args[0]+" to "+args[1]+" successful"); } catch (FailoverFailedException ffe) { errOut.println("Failover failed: " + ffe.getLocalizedMessage()); return -1;
throw new FailoverFailedException( "Can't failover a service to itself"); String msg = "Unable to get service state for " + target; LOG.error(msg + ": " + e.getLocalizedMessage()); throw new FailoverFailedException(msg, e); throw new FailoverFailedException( "Can't failover to an active service"); String notReadyReason = toSvcStatus.getNotReadyReason(); if (!forceActive) { throw new FailoverFailedException( target + " is not ready to become active: " + notReadyReason); HAServiceProtocolHelper.monitorHealth(toSvc, createReqInfo()); } catch (HealthCheckFailedException hce) { throw new FailoverFailedException( "Can't failover to an unhealthy service", hce); } catch (IOException e) { throw new FailoverFailedException( "Got an IO exception", e);
throw new FailoverFailedException("Unable to fence " + fromSvc + ". Fencing failed."); } catch (FailoverFailedException ffe) { msg += ". Failback to " + fromSvc + " failed (" + ffe.getMessage() + ")"; LOG.fatal(msg); throw new FailoverFailedException(msg, cause);
out.println("Failover from "+args[0]+" to "+args[1]+" successful"); } catch (FailoverFailedException ffe) { errOut.println("Failover failed: " + ffe.getLocalizedMessage()); return -1;
throw new FailoverFailedException( "Can't failover a service to itself"); String msg = "Unable to get service state for " + target; LOG.error(msg + ": " + e.getLocalizedMessage()); throw new FailoverFailedException(msg, e); throw new FailoverFailedException( "Can't failover to an active service"); String notReadyReason = toSvcStatus.getNotReadyReason(); if (!forceActive) { throw new FailoverFailedException( target + " is not ready to become active: " + notReadyReason); HAServiceProtocolHelper.monitorHealth(toSvc, createReqInfo()); } catch (HealthCheckFailedException hce) { throw new FailoverFailedException( "Can't failover to an unhealthy service", hce); } catch (IOException e) { throw new FailoverFailedException( "Got an IO exception", e);
throw new FailoverFailedException("Unable to fence " + fromSvc + ". Fencing failed."); } catch (FailoverFailedException ffe) { msg += ". Failback to " + fromSvc + " failed (" + ffe.getMessage() + ")"; LOG.fatal(msg); throw new FailoverFailedException(msg, cause);
out.println("Failover from "+args[0]+" to "+args[1]+" successful"); } catch (FailoverFailedException ffe) { errOut.println("Failover failed: " + ffe.getLocalizedMessage()); return -1;