You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/01/10 23:46:11 UTC

[GitHub] asfgit closed pull request #354: ACCUMULO-4776 Fix advertised host in monitor

asfgit closed pull request #354: ACCUMULO-4776 Fix advertised host in monitor
URL: https://github.com/apache/accumulo/pull/354
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 1fa82d3b35..b3e3d5cb16 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -18,6 +18,8 @@
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -480,20 +482,27 @@ public void run(String hostname) {
       server.addServlet(ShellServlet.class, "/shell");
     server.start();
 
-    try {
-      log.debug("Using " + hostname + " to advertise monitor location in ZooKeeper");
-
-      String monitorAddress = HostAndPort.fromParts(hostname, server.getPort()).toString();
+    String advertiseHost = hostname;
+    if (advertiseHost.equals("0.0.0.0")) {
+      try {
+        advertiseHost = InetAddress.getLocalHost().getHostName();
+      } catch (UnknownHostException e) {
+        log.error("Unable to get hostname", e);
+      }
+    }
+    log.debug("Using {} to advertise monitor location in ZooKeeper", advertiseHost);
 
+    try {
+      String monitorAddress = HostAndPort.fromParts(advertiseHost, server.getPort()).toString();
       ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(instance) + Constants.ZMONITOR_HTTP_ADDR, monitorAddress.getBytes(UTF_8),
           NodeExistsPolicy.OVERWRITE);
-      log.info("Set monitor address in zookeeper to " + monitorAddress);
+      log.info("Set monitor address in zookeeper to {}", monitorAddress);
     } catch (Exception ex) {
       log.error("Unable to set monitor HTTP address in zookeeper", ex);
     }
 
-    if (null != hostname) {
-      LogService.startLogListener(Monitor.getContext().getConfiguration(), instance.getInstanceID(), hostname);
+    if (null != advertiseHost) {
+      LogService.startLogListener(Monitor.getContext().getConfiguration(), instance.getInstanceID(), advertiseHost);
     } else {
       log.warn("Not starting log4j listener as we could not determine address to use");
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services