You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@htrace.apache.org by iw...@apache.org on 2015/09/26 05:20:11 UTC

incubator-htrace git commit: HTRACE-114. Fix compilation error of htrace-hbase against hbase-1.0.0 (iwasakims)

Repository: incubator-htrace
Updated Branches:
  refs/heads/master 0432fd9fb -> 195ecee7d


HTRACE-114. Fix compilation error of htrace-hbase against hbase-1.0.0 (iwasakims)


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

Branch: refs/heads/master
Commit: 195ecee7d053f5f70fa9b96b22390ec335921a1e
Parents: 0432fd9
Author: Masatake Iwasaki <iw...@apache.org>
Authored: Wed Sep 23 15:42:45 2015 +0900
Committer: Masatake Iwasaki <iw...@apache.org>
Committed: Wed Sep 23 15:42:45 2015 +0900

----------------------------------------------------------------------
 htrace-hbase/pom.xml                            |  2 +-
 .../apache/htrace/impl/HBaseSpanReceiver.java   | 37 +++++++++-----------
 2 files changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/195ecee7/htrace-hbase/pom.xml
----------------------------------------------------------------------
diff --git a/htrace-hbase/pom.xml b/htrace-hbase/pom.xml
index fc8b188..4c27d71 100644
--- a/htrace-hbase/pom.xml
+++ b/htrace-hbase/pom.xml
@@ -31,7 +31,7 @@ language governing permissions and limitations under the License. -->
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-    <hbase.version>0.99.2</hbase.version>
+    <hbase.version>1.1.2</hbase.version>
     <jetty.version>9.2.13.v20150730</jetty.version>
     <createDependencyReducedPom>true</createDependencyReducedPom>
   </properties>

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/195ecee7/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
----------------------------------------------------------------------
diff --git a/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java b/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
index aa471ab..f2537f9 100644
--- a/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
+++ b/htrace-hbase/src/main/java/org/apache/htrace/impl/HBaseSpanReceiver.java
@@ -35,10 +35,10 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.BufferedMutator;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Table;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.htrace.HBaseHTraceConfiguration;
 import org.apache.htrace.core.HTraceConfiguration;
@@ -119,7 +119,6 @@ public class HBaseSpanReceiver extends SpanReceiver {
   };
 
   private ExecutorService service;
-  private final HTraceConfiguration conf;
   private final Configuration hconf;
   private final byte[] table;
   private final byte[] cf;
@@ -128,7 +127,6 @@ public class HBaseSpanReceiver extends SpanReceiver {
 
   public HBaseSpanReceiver(HTraceConfiguration conf) {
     this.queue = new ArrayBlockingQueue<Span>(1000);
-    this.conf = conf;
     this.hconf = HBaseConfiguration.create();
     this.table = Bytes.toBytes(conf.get(TABLE_KEY, DEFAULT_TABLE));
     this.cf = Bytes.toBytes(conf.get(COLUMNFAMILY_KEY, DEFAULT_COLUMNFAMILY));
@@ -156,7 +154,7 @@ public class HBaseSpanReceiver extends SpanReceiver {
 
   private class WriteSpanRunnable implements Runnable {
     private Connection hconnection;
-    private Table htable;
+    private BufferedMutator mutator;
 
     public WriteSpanRunnable() {
     }
@@ -194,14 +192,15 @@ public class HBaseSpanReceiver extends SpanReceiver {
         startClient();
         if (dequeuedSpans.isEmpty()) {
           try {
-            this.htable.flushCommits();
+            this.mutator.flush();
           } catch (IOException e) {
-            LOG.error("failed to flush writes to HBase.");
+            LOG.error("Failed to flush writes to HBase.");
             closeClient();
           }
           continue;
         }
 
+
         try {
           for (Span span : dequeuedSpans) {
             sbuilder.clear()
@@ -229,18 +228,14 @@ public class HBaseSpanReceiver extends SpanReceiver {
                                             .build());
             }
             Put put = new Put(Bytes.toBytes(span.getSpanId().getHigh()));
-            put.add(HBaseSpanReceiver.this.cf,
-                    sbuilder.build().toByteArray(),
-                    null);
+            put.addColumn(HBaseSpanReceiver.this.cf, sbuilder.build().toByteArray(), null);
             if (span.getParents().length == 0) {
-              put.add(HBaseSpanReceiver.this.icf,
-                      INDEX_TIME_QUAL,
-                      Bytes.toBytes(span.getStartTimeMillis()));
-              put.add(HBaseSpanReceiver.this.icf,
-                      INDEX_SPAN_QUAL,
-                      sbuilder.build().toByteArray());
+              put.addColumn(HBaseSpanReceiver.this.icf, INDEX_TIME_QUAL,
+                Bytes.toBytes(span.getStartTimeMillis()));
+              put.addColumn(HBaseSpanReceiver.this.icf, INDEX_SPAN_QUAL,
+                sbuilder.build().toByteArray());
             }
-            this.htable.put(put);
+            this.mutator.mutate(put);
           }
           // clear the list for the next time through.
           dequeuedSpans.clear();
@@ -276,9 +271,9 @@ public class HBaseSpanReceiver extends SpanReceiver {
     private void closeClient() {
       // close out the transport.
       try {
-        if (this.htable != null) {
-          this.htable.close();
-          this.htable = null;
+        if (this.mutator != null) {
+          this.mutator.close();
+          this.mutator = null;
         }
         if (this.hconnection != null) {
           this.hconnection.close();
@@ -293,10 +288,10 @@ public class HBaseSpanReceiver extends SpanReceiver {
      * Re-connect to HBase
      */
     private void startClient() {
-      if (this.htable == null) {
+      if (this.mutator == null) {
         try {
           hconnection = ConnectionFactory.createConnection(hconf);
-          htable = hconnection.getTable(TableName.valueOf(table));
+          mutator = hconnection.getBufferedMutator(TableName.valueOf(table));
         } catch (IOException e) {
           LOG.warn("Failed to create HBase connection. " + e.getMessage());
         }