diff --git a/service/src/java/org/apache/hive/service/server/HiveServer2.java b/service/src/java/org/apache/hive/service/server/HiveServer2.java index 58e8e49..7e50a34 100644 --- a/service/src/java/org/apache/hive/service/server/HiveServer2.java +++ b/service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -251,7 +251,8 @@ public void process(WatchedEvent event) { if (znode != null) { try { znode.close(); - LOG.warn("This HiveServer2 instance is now de-registered from ZooKeeper. " + LOG.warn("This HiveServer2 instance (" + getServerInstanceURIForLog() + ") is now " + + "de-registered from ZooKeeper. " + "The server will be shut down after the last client sesssion completes."); } catch (IOException e) { LOG.error("Failed to close the persistent ephemeral znode", e); @@ -300,10 +301,24 @@ public synchronized void start() { super.start(); } + /** + * Get HS2 uri for logging purposes during shutdown/de-register. + * Don't throw exceptions, just log them. + * @return this HS2 instance uri + */ + private String getServerInstanceURIForLog() { + try { + return getServerInstanceURI(getHiveConf()); + } catch (Exception e) { + LOG.error("Error obtaining server instance uri", e); + } + return "unknown uri"; + } + @Override public synchronized void stop() { - LOG.info("Shutting down HiveServer2"); HiveConf hiveConf = this.getHiveConf(); + LOG.info("Shutting down HiveServer2 (" + getServerInstanceURIForLog() + ")"); super.stop(); // Remove this server instance from ZooKeeper if dynamic service discovery is set if (hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_SUPPORT_DYNAMIC_SERVICE_DISCOVERY)) {