/** * Initiate a graceful failover by talking to the target node's ZKFC. * This sends an RPC to the ZKFC, which coordinates the failover. * * @param toNode the node to fail to * @return status code (0 for success) * @throws IOException if failover does not succeed */ private int gracefulFailoverThroughZKFCs(HAServiceTarget toNode) throws IOException { int timeout = FailoverController.getRpcTimeoutToNewActive(getConf()); ZKFCProtocol proxy = toNode.getZKFCProxy(getConf(), timeout); try { proxy.gracefulFailover(); out.println("Failover to " + toNode + " successful"); } catch (ServiceFailedException sfe) { errOut.println("Failover failed: " + sfe.getLocalizedMessage()); return -1; } return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
protected int getAllServiceState() { Collection<String> targetIds = getTargetIds(null); if (targetIds.isEmpty()) { errOut.println("Failed to get service IDs"); return -1; } for (String targetId : targetIds) { HAServiceTarget target = resolveTarget(targetId); String address = target.getAddress().getHostName() + ":" + target.getAddress().getPort(); try { HAServiceProtocol proto = target.getProxy(getConf(), rpcTimeoutForChecks); out.println(String.format("%-50s %-10s", address, proto .getServiceStatus().getState())); } catch (IOException e) { out.println(String.format("%-50s %-10s", address, "Failed to connect: " + e.getMessage())); } } return 0; }
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**
private int transitionToActive(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToActive: incorrect number of arguments"); printUsage(errOut, "-transitionToActive"); return -1; } /* returns true if other target node is active or some exception occurred and forceActive was not set */ if(!cmd.hasOption(FORCEACTIVE)) { if(isOtherTargetNodeActive(argv[0], cmd.hasOption(FORCEACTIVE))) { return -1; } } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToActive(proto, createReqInfo()); return 0; }
HAServiceProtocol proto = target.getProxy(getConf(), 5000); if(proto.getServiceStatus().getState() == HAServiceState.ACTIVE) { errOut.println("transitionToActive: Node " + targetId +" is already active");
FailoverController fc = new FailoverController(getConf(), requestSource);
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int getServiceState(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("getServiceState: incorrect number of arguments"); printUsage(errOut, "-getServiceState"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); out.println(proto.getServiceStatus().getState()); return 0; }
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**
private int checkHealth(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("checkHealth: incorrect number of arguments"); printUsage(errOut, "-checkHealth"); return -1; } HAServiceProtocol proto = resolveTarget(argv[0]).getProxy( getConf(), rpcTimeoutForChecks); try { HAServiceProtocolHelper.monitorHealth(proto, createReqInfo()); } catch (HealthCheckFailedException e) { errOut.println("Health check failed: " + e.getLocalizedMessage()); return -1; } return 0; }
private int transitionToStandby(final CommandLine cmd) throws IOException, ServiceFailedException { String[] argv = cmd.getArgs(); if (argv.length != 1) { errOut.println("transitionToStandby: incorrect number of arguments"); printUsage(errOut, "-transitionToStandby"); return -1; } HAServiceTarget target = resolveTarget(argv[0]); if (!checkManualStateManagementOK(target)) { return -1; } HAServiceProtocol proto = target.getProxy( getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto, createReqInfo()); return 0; } /**