incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Fixing some more tracing issues
Date Tue, 26 Nov 2013 03:28:34 GMT
Updated Branches:
  refs/heads/apache-blur-0.2 c49c21a86 -> f9f71fc57


Fixing some more tracing issues


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/f9f71fc5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/f9f71fc5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/f9f71fc5

Branch: refs/heads/apache-blur-0.2
Commit: f9f71fc575b5a5b26e2fcd543f57b0e864ed8b2d
Parents: c49c21a
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Mon Nov 25 22:27:48 2013 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Mon Nov 25 22:27:48 2013 -0500

----------------------------------------------------------------------
 .../blur/thrift/BlurControllerServer.java       | 43 ++++++++++++++++----
 .../org/apache/blur/trace/TraceCollector.java   |  4 +-
 .../java/org/apache/blur/trace/TracerImpl.java  |  2 +-
 3 files changed, 38 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f9f71fc5/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
----------------------------------------------------------------------
diff --git a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
index 877b744..51894bd 100644
--- a/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
+++ b/blur-core/src/main/java/org/apache/blur/thrift/BlurControllerServer.java
@@ -18,6 +18,8 @@ package org.apache.blur.thrift;
  */
 import java.io.Closeable;
 import java.io.IOException;
+import java.net.Socket;
+import java.net.SocketAddress;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -59,6 +61,10 @@ import org.apache.blur.manager.stats.MergerTableStats;
 import org.apache.blur.manager.status.MergerQueryStatusSingle;
 import org.apache.blur.server.ControllerServerContext;
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
+import org.apache.blur.thirdparty.thrift_0_9_0.protocol.TProtocol;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TFramedTransport;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TSocket;
+import org.apache.blur.thirdparty.thrift_0_9_0.transport.TTransport;
 import org.apache.blur.thrift.commands.BlurCommand;
 import org.apache.blur.thrift.generated.Blur.Client;
 import org.apache.blur.thrift.generated.Blur.Iface;
@@ -482,16 +488,37 @@ public class BlurControllerServer extends TableAdmin implements Iface
{
         futures.add(executor.submit(new Callable<Boolean>() {
           @Override
           public Boolean call() throws Exception {
-            String traceId = Trace.getTraceId();
-            if (traceId != null) {
-              client.startTrace(traceId);
+            Tracer trace = Trace.trace("remote call - thrift", Trace.param("node", getNode(client)));
+            try {
+              String traceId = Trace.getTraceId();
+              if (traceId != null) {
+                client.startTrace(traceId);
+              }
+              List<FetchResult> fetchRowBatch = client.fetchRowBatch(table, list);
+              for (int i = 0; i < list.size(); i++) {
+                int index = indexMap.get(list.get(i));
+                fetchResults.set(index, fetchRowBatch.get(i));
+              }
+              return Boolean.TRUE;
+            } finally {
+              trace.done();
+            }
+          }
+
+          private String getNode(Client client) {
+            TProtocol inputProtocol = client.getInputProtocol();
+            TTransport transport = inputProtocol.getTransport();
+            if (transport instanceof TFramedTransport) {
+              TFramedTransport framedTransport = (TFramedTransport) transport;
+              transport = framedTransport.getTransport();
             }
-            List<FetchResult> fetchRowBatch = client.fetchRowBatch(table, list);
-            for (int i = 0; i < list.size(); i++) {
-              int index = indexMap.get(list.get(i));
-              fetchResults.set(index, fetchRowBatch.get(i));
+            if (transport instanceof TSocket) {
+              TSocket tsocket = (TSocket) transport;
+              Socket socket = tsocket.getSocket();
+              SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
+              return remoteSocketAddress.toString();
             }
-            return Boolean.TRUE;
+            return "unknown";
           }
         }));
       }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f9f71fc5/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java b/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
index 68ba2fd..47e01e7 100644
--- a/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
+++ b/blur-util/src/main/java/org/apache/blur/trace/TraceCollector.java
@@ -54,8 +54,8 @@ public class TraceCollector {
     for (TracerImpl t : _traces) {
       builder.append("    ").append(t.toJson()).append(",\n");
     }
-    return "{\n  \"id\":\"" + _id + "\"\n  \"nodeName\":\"" + (_nodeName == null ? "unknown"
: _nodeName)
-        + "\"\n  \"pid\":\"" + _pid + "\"\n  \"thread\":\"" + _threadName + "\"\n  \"created\":"
+ _now
+    return "{\n  \"id\":\"" + _id + "\",\n  \"nodeName\":\"" + (_nodeName == null ? "unknown"
: _nodeName)
+        + "\",\n  \"pid\":\"" + _pid + "\",\n  \"thread\":\"" + _threadName + "\",\n  \"created\":"
+ _now
         + ",\n  \"traces\":[\n" + builder.toString() + "  ]\n}";
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/f9f71fc5/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
----------------------------------------------------------------------
diff --git a/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java b/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
index 9e25fe6..3b855d1 100644
--- a/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
+++ b/blur-util/src/main/java/org/apache/blur/trace/TracerImpl.java
@@ -79,7 +79,7 @@ public class TracerImpl implements Tracer {
       if (builder.length() != 0) {
         builder.append(',');
       }
-      builder.append("\"").append(parameter._name).append("\":\"").append(parameter._value).append("\"");
+      builder.append("{\"").append(parameter._name).append("\":\"").append(parameter._value).append("\"}");
     }
     return builder.toString();
   }


Mime
View raw message