You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2019/10/29 23:23:16 UTC

[accumulo] branch master updated: Fix #1398 traces going to 0.0.0.0 address (#1399)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new a8ffe67  Fix #1398 traces going to 0.0.0.0 address (#1399)
a8ffe67 is described below

commit a8ffe671539dc3a0e4b87a813b57835952a5f98e
Author: etseidl <et...@users.noreply.github.com>
AuthorDate: Tue Oct 29 16:23:08 2019 -0700

    Fix #1398 traces going to 0.0.0.0 address (#1399)
---
 .../java/org/apache/accumulo/tracer/AsyncSpanReceiver.java    |  4 +++-
 .../src/main/java/org/apache/accumulo/tracer/TraceServer.java | 11 +++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java
index fde4a32..7ccbe11 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/AsyncSpanReceiver.java
@@ -94,13 +94,15 @@ public abstract class AsyncSpanReceiver<SpanKey,Destination> implements SpanRece
     }
 
     host = conf.get(TraceUtil.TRACE_HOST_PROPERTY, host);
-    if (host == null) {
+    log.info("host from config: {}", host);
+    if (host == null || "0.0.0.0".equals(host)) {
       try {
         host = InetAddress.getLocalHost().getCanonicalHostName().toString();
       } catch (UnknownHostException e) {
         host = "unknown";
       }
     }
+    log.info("starting span receiver with hostname {}", host);
     service = conf.get(TraceUtil.TRACE_SERVICE_PROPERTY, service);
     maxQueueSize = conf.getInt(QUEUE_SIZE, maxQueueSize);
     minSpanSize = conf.getInt(SPAN_MIN_MS, minSpanSize);
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
index d029b53..5c13f7a 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceServer.java
@@ -20,6 +20,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.nio.channels.ServerSocketChannel;
@@ -222,8 +223,14 @@ public class TraceServer implements Watcher, AutoCloseable {
     TThreadPoolServer.Args options = new TThreadPoolServer.Args(transport);
     options.processor(new Processor<Iface>(new Receiver()));
     server = new TThreadPoolServer(options);
-    registerInZooKeeper(sock.getInetAddress().getHostAddress() + ":" + sock.getLocalPort(),
-        conf.get(Property.TRACE_ZK_PATH));
+    // if sock is bound to the wildcard address, the local address will be 0.0.0.0.
+    // check for this, and try using InetAddress.getLocalHost instead.
+    // the problem is registering 0.0.0.0 in zookeeper doesn't work for non-local
+    // services (like remote tablet servers)
+    String hostAddr = sock.getInetAddress().getHostAddress();
+    if ("0.0.0.0".equals(hostAddr))
+      hostAddr = InetAddress.getLocalHost().getHostAddress();
+    registerInZooKeeper(hostAddr + ":" + sock.getLocalPort(), conf.get(Property.TRACE_ZK_PATH));
     writer = new AtomicReference<>(this.accumuloClient.createBatchWriter(tableName,
         new BatchWriterConfig().setMaxLatency(BATCH_WRITER_MAX_LATENCY, TimeUnit.SECONDS)));
   }