Repository: phoenix
Updated Branches:
  refs/heads/4.0 f18922c61 -> 495491a72


PHOENIX-1176 Allow tracing to be turned on globally through config


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/495491a7
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/495491a7
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/495491a7

Branch: refs/heads/4.0
Commit: 495491a729150896d04307ab8315fc60904a5cb9
Parents: f18922c
Author: James Taylor <jtay...@salesforce.com>
Authored: Sun Aug 17 11:21:36 2014 -0700
Committer: James Taylor <jtay...@salesforce.com>
Committed: Sun Aug 17 11:21:36 2014 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/query/QueryServicesOptions.java   |  3 +++
 .../apache/phoenix/trace/util/ConfigurationAdapter.java  | 11 +++++------
 .../main/java/org/apache/phoenix/trace/util/Tracing.java |  8 +++++---
 3 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/495491a7/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index 20c3359..ae1dbc7 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -60,6 +60,7 @@ import java.util.Map.Entry;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.regionserver.wal.WALCellCodec;
+import org.apache.phoenix.trace.util.Tracing;
 import org.apache.phoenix.util.DateUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
 
@@ -140,6 +141,8 @@ public class QueryServicesOptions {
      * Configuration key to overwrite the tablename that should be used as the 
target table
      */
     public static final String DEFAULT_TRACING_STATS_TABLE_NAME = 
"SYSTEM.TRACING_STATS";
+    public static final String DEFAULT_TRACING_FREQ = 
Tracing.Frequency.NEVER.getKey();
+    public static final double DEFAULT_TRACING_PROBABILITY_THRESHOLD = 0.05;
 
     private final Configuration config;
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/495491a7/phoenix-core/src/main/java/org/apache/phoenix/trace/util/ConfigurationAdapter.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/ConfigurationAdapter.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/ConfigurationAdapter.java
index a96be7d..cde7f9e 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/ConfigurationAdapter.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/ConfigurationAdapter.java
@@ -18,7 +18,6 @@
 package org.apache.phoenix.trace.util;
 
 import org.apache.hadoop.conf.Configuration;
-
 import org.apache.phoenix.jdbc.PhoenixConnection;
 
 /**
@@ -26,7 +25,7 @@ import org.apache.phoenix.jdbc.PhoenixConnection;
  */
 abstract class ConfigurationAdapter {
 
-  public abstract String get(String key);
+  public abstract String get(String key, String defaultValue);
 
   public static class ConnectionConfigurationAdapter extends 
ConfigurationAdapter {
     private PhoenixConnection conn;
@@ -36,8 +35,8 @@ abstract class ConfigurationAdapter {
     }
 
     @Override
-    public String get(String key) {
-      return conn.getClientInfo(key);
+    public String get(String key, String defaultValue) {
+      return conn.getQueryServices().getProps().get(key, defaultValue);
     }
   }
 
@@ -49,8 +48,8 @@ abstract class ConfigurationAdapter {
     }
 
     @Override
-    public String get(String key) {
-      return conf.get(key);
+    public String get(String key, String defaultValue) {
+      return conf.get(key, defaultValue);
     }
   }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/495491a7/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java 
b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
index 5e4ac9e..e90d2c8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
@@ -30,6 +30,7 @@ import org.apache.phoenix.call.CallRunner;
 import org.apache.phoenix.call.CallWrapper;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
 import org.cloudera.htrace.Sampler;
 import org.cloudera.htrace.Span;
 import org.cloudera.htrace.Trace;
@@ -112,19 +113,20 @@ public class Tracing {
                 @Override
                 public Sampler<?> apply(ConfigurationAdapter conn) {
                     // get the connection properties for the probability 
information
-                    double threshold = 
Double.parseDouble(conn.get(QueryServices.TRACING_PROBABILITY_THRESHOLD_ATTRIB));
+                    String probThresholdStr = 
conn.get(QueryServices.TRACING_PROBABILITY_THRESHOLD_ATTRIB, null);
+                    double threshold = probThresholdStr == null ? 
QueryServicesOptions.DEFAULT_TRACING_PROBABILITY_THRESHOLD : 
Double.parseDouble(probThresholdStr);
                     return new ProbabilitySampler(threshold);
                 }
             };
 
     public static Sampler<?> getConfiguredSampler(PhoenixConnection 
connection) {
-        String tracelevel = 
connection.getClientInfo(QueryServices.TRACING_FREQ_ATTRIB);
+        String tracelevel = 
connection.getQueryServices().getProps().get(QueryServices.TRACING_FREQ_ATTRIB, 
QueryServicesOptions.DEFAULT_TRACING_FREQ);
         return getSampler(tracelevel, new 
ConfigurationAdapter.ConnectionConfigurationAdapter(
                 connection));
     }
 
     public static Sampler<?> getConfiguredSampler(Configuration conf) {
-        String tracelevel = conf.get(QueryServices.TRACING_FREQ_ATTRIB);
+        String tracelevel = conf.get(QueryServices.TRACING_FREQ_ATTRIB, 
QueryServicesOptions.DEFAULT_TRACING_FREQ);
         return getSampler(tracelevel, new 
ConfigurationAdapter.HadoopConfigConfigurationAdapter(
                 conf));
     }

Reply via email to