accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] 01/01: Merge branch 'fix-advertise-host-ACCUMULO-4776' into 1.8
Date Wed, 10 Jan 2018 23:46:03 GMT
This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch 1.8
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit c2a6f8fd69011ce13b63ad5c885846ee2a6eb6e8
Merge: 7fc61d4 bad30a1
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Wed Jan 10 18:17:26 2018 -0500

    Merge branch 'fix-advertise-host-ACCUMULO-4776' into 1.8

 .../java/org/apache/accumulo/monitor/Monitor.java  | 23 +++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --cc server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index a35518e,b3e3d5c..e9026c2
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@@ -17,10 -17,10 +17,12 @@@
  package org.apache.accumulo.monitor;
  
  import static java.nio.charset.StandardCharsets.UTF_8;
 +import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
  
+ import java.net.InetAddress;
+ import java.net.UnknownHostException;
  import java.util.ArrayList;
 +import java.util.Arrays;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
@@@ -456,48 -453,50 +458,55 @@@ public class Monitor 
      }
  
      Monitor.START_TIME = System.currentTimeMillis();
 -    int port = config.getConfiguration().getPort(Property.MONITOR_PORT);
 -    try {
 -      log.debug("Creating monitor on port " + port);
 -      server = new EmbeddedWebServer(hostname, port);
 -    } catch (Throwable ex) {
 -      log.error("Unable to start embedded web server", ex);
 -      throw new RuntimeException(ex);
 +    int ports[] = config.getConfiguration().getPort(Property.MONITOR_PORT);
 +    for (int port : ports) {
 +      try {
 +        log.debug("Creating monitor on port " + port);
 +        server = new EmbeddedWebServer(hostname, port);
 +        server.addServlet(DefaultServlet.class, "/");
 +        server.addServlet(OperationServlet.class, "/op");
 +        server.addServlet(MasterServlet.class, "/master");
 +        server.addServlet(TablesServlet.class, "/tables");
 +        server.addServlet(TServersServlet.class, "/tservers");
 +        server.addServlet(ProblemServlet.class, "/problems");
 +        server.addServlet(GcStatusServlet.class, "/gc");
 +        server.addServlet(LogServlet.class, "/log");
 +        server.addServlet(XMLServlet.class, "/xml");
 +        server.addServlet(JSONServlet.class, "/json");
 +        server.addServlet(VisServlet.class, "/vis");
 +        server.addServlet(ScanServlet.class, "/scans");
 +        server.addServlet(BulkImportServlet.class, "/bulkImports");
 +        server.addServlet(Summary.class, "/trace/summary");
 +        server.addServlet(ListType.class, "/trace/listType");
 +        server.addServlet(ShowTrace.class, "/trace/show");
 +        server.addServlet(ReplicationServlet.class, "/replication");
 +        if (server.isUsingSsl())
 +          server.addServlet(ShellServlet.class, "/shell");
 +        server.start();
 +        break;
 +      } catch (Throwable ex) {
 +        log.error("Unable to start embedded web server", ex);
 +      }
 +    }
 +    if (!server.isRunning()) {
 +      throw new RuntimeException("Unable to start embedded web server on ports: " + Arrays.toString(ports));
      }
 -
 -    server.addServlet(DefaultServlet.class, "/");
 -    server.addServlet(OperationServlet.class, "/op");
 -    server.addServlet(MasterServlet.class, "/master");
 -    server.addServlet(TablesServlet.class, "/tables");
 -    server.addServlet(TServersServlet.class, "/tservers");
 -    server.addServlet(ProblemServlet.class, "/problems");
 -    server.addServlet(GcStatusServlet.class, "/gc");
 -    server.addServlet(LogServlet.class, "/log");
 -    server.addServlet(XMLServlet.class, "/xml");
 -    server.addServlet(JSONServlet.class, "/json");
 -    server.addServlet(VisServlet.class, "/vis");
 -    server.addServlet(ScanServlet.class, "/scans");
 -    server.addServlet(Summary.class, "/trace/summary");
 -    server.addServlet(ListType.class, "/trace/listType");
 -    server.addServlet(ShowTrace.class, "/trace/show");
 -    server.addServlet(ReplicationServlet.class, "/replication");
 -    if (server.isUsingSsl())
 -      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);
      }

-- 
To stop receiving notification emails like this one, please contact
"commits@accumulo.apache.org" <commits@accumulo.apache.org>.

Mime
View raw message