while (!foundLeader && retries < maxRetries) { for (HiveServer2Instance hiveServer2Instance : haRegistryClient.getAll()) { if (hiveServer2Instance.isLeader()) { foundLeader = true; connParams.setHost(hiveServer2Instance.getHost()); connParams.setPort(hiveServer2Instance.getRpcPort()); final String mode = hiveServer2Instance.getTransportMode().equals("http") ? "http:/" + hiveServer2Instance .getHttpEndpoint() : hiveServer2Instance.getTransportMode(); LOG.info("Found HS2 Active Host: {} Port: {} Identity: {} Mode: {}", hiveServer2Instance.getHost(), hiveServer2Instance.getRpcPort(), hiveServer2Instance.getWorkerIdentity(), mode); String serverConfStr = Joiner.on(';').withKeyValueSeparator("=").join(hiveServer2Instance.getProperties()); if (LOG.isDebugEnabled()) { LOG.debug("Configurations applied to JDBC connection params. {}", hiveServer2Instance.getProperties());
@Override protected HiveServer2Instance createServiceInstance(final ServiceRecord srv) throws IOException { Endpoint activeEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.ACTIVE_ENDPOINT); return new HiveServer2Instance(srv, activeEndpoint != null ? ACTIVE_ENDPOINT : PASSIVE_ENDPOINT); }
@Override public String toString() { String result = "instanceId: " + getWorkerIdentity() + " isLeader: " + isLeader + " host: " + getHost() + " port: " + getRpcPort() + " transportMode: " + transportMode; if (httpEndpoint != null) { result += " httpEndpoint: " + httpEndpoint; } return result; } }
if (instance.getWorkerIdentity().equals(workerIdentity)) { targetInstance = instance; break; if (!targetInstance.isLeader()) { LOG.error("HiveServer2 instance (workerIdentity: " + workerIdentity + ") is not a leader. Cannot failover"); System.err.println("HiveServer2 instance (workerIdentity: " + workerIdentity + ") is not a leader. Cannot failover"); String webPort = targetInstance.getProperties().get(ConfVars.HIVE_SERVER2_WEBUI_PORT.varname); String webEndpoint = "http://" + targetInstance.getHost() + ":" + webPort + "/leader"; HttpDelete httpDelete = new HttpDelete(webEndpoint); CloseableHttpResponse httpResponse = null;
@Override public HiveServer2Instance getLeader() { for (HiveServer2Instance hs2Instance : getAll()) { if (hs2Instance.isLeader()) { return hs2Instance; } } return null; }
@Override public HiveServer2Instance getInstance(final String instanceId) { for (HiveServer2Instance hs2Instance : getAll()) { if (hs2Instance.getWorkerIdentity().equals(instanceId)) { return hs2Instance; } } return null; }
if (instance.getWorkerIdentity().equals(workerIdentity)) { targetInstance = instance; break; if (!targetInstance.isLeader()) { LOG.error("HiveServer2 instance (workerIdentity: " + workerIdentity + ") is not a leader. Cannot failover"); System.err.println("HiveServer2 instance (workerIdentity: " + workerIdentity + ") is not a leader. Cannot failover"); String webPort = targetInstance.getProperties().get(ConfVars.HIVE_SERVER2_WEBUI_PORT.varname); String webEndpoint = "http://" + targetInstance.getHost() + ":" + webPort + "/leader"; HttpDelete httpDelete = new HttpDelete(webEndpoint); CloseableHttpResponse httpResponse = null;
@Override public String toString() { String result = "instanceId: " + getWorkerIdentity() + " isLeader: " + isLeader + " host: " + getHost() + " port: " + getRpcPort() + " transportMode: " + transportMode; if (httpEndpoint != null) { result += " httpEndpoint: " + httpEndpoint; } return result; } }
@Override public HiveServer2Instance getLeader() { for (HiveServer2Instance hs2Instance : getAll()) { if (hs2Instance.isLeader()) { return hs2Instance; } } return null; }
@Override public HiveServer2Instance getInstance(final String instanceId) { for (HiveServer2Instance hs2Instance : getAll()) { if (hs2Instance.getWorkerIdentity().equals(instanceId)) { return hs2Instance; } } return null; }
while (!foundLeader && retries < maxRetries) { for (HiveServer2Instance hiveServer2Instance : haRegistryClient.getAll()) { if (hiveServer2Instance.isLeader()) { foundLeader = true; connParams.setHost(hiveServer2Instance.getHost()); connParams.setPort(hiveServer2Instance.getRpcPort()); final String mode = hiveServer2Instance.getTransportMode().equals("http") ? "http:/" + hiveServer2Instance .getHttpEndpoint() : hiveServer2Instance.getTransportMode(); LOG.info("Found HS2 Active Host: {} Port: {} Identity: {} Mode: {}", hiveServer2Instance.getHost(), hiveServer2Instance.getRpcPort(), hiveServer2Instance.getWorkerIdentity(), mode); String serverConfStr = Joiner.on(';').withKeyValueSeparator("=").join(hiveServer2Instance.getProperties()); if (LOG.isDebugEnabled()) { LOG.debug("Configurations applied to JDBC connection params. {}", hiveServer2Instance.getProperties());
@Override protected HiveServer2Instance createServiceInstance(final ServiceRecord srv) throws IOException { Endpoint activeEndpoint = srv.getInternalEndpoint(HS2ActivePassiveHARegistry.ACTIVE_ENDPOINT); return new HiveServer2Instance(srv, activeEndpoint != null ? ACTIVE_ENDPOINT : PASSIVE_ENDPOINT); }