hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1344034 [3/3] - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/thrift/ main/java/org/apache/hadoop/hbase/thrift/generated/ main/resources/org/apache/hadoop/hbase/thrift/ test/java/org/apache/hadoop/hbase/thrift/
Date Tue, 29 May 2012 22:31:55 GMT
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java?rev=1344034&r1=1344033&r2=1344034&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/thrift/generated/TRowResult.java
Tue May 29 22:31:54 2012
@@ -443,7 +443,7 @@ public class TRowResult implements org.a
                 for (int _i9 = 0; _i9 < _map8.size; ++_i9)
                 {
                   ByteBuffer _key10; // required
-                  TCell _val11; // required
+                  TCell _val11; // optional
                   _key10 = iprot.readBinary();
                   _val11 = new TCell();
                   _val11.read(iprot);

Modified: hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift?rev=1344034&r1=1344033&r2=1344034&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
(original)
+++ hbase/trunk/hbase-server/src/main/resources/org/apache/hadoop/hbase/thrift/Hbase.thrift
Tue May 29 22:31:54 2012
@@ -110,6 +110,16 @@ struct BatchMutation {
   2:list<Mutation> mutations
 }
 
+/**
+ * For increments that are not incrementColumnValue
+ * equivalents.
+ */
+struct TIncrement {
+  1:Text table,
+  2:Text row,
+  3:Text column,
+  4:i64  ammount
+}
 
 /**
  * Holds row name and then a map of columns to cells. 
@@ -628,6 +638,23 @@ service Hbase {
   ) throws (1:IOError io)
 
   /**
+   * Increment a cell by the ammount.
+   * Increments can be applied async if hbase.regionserver.thrift.coalesceIncrement is set
to true.
+   * False is the default.  Turn to true if you need the extra performance and can accept
some
+   * data loss if a thrift server dies with increments still in the queue.
+   */
+  void increment(
+    /** The single increment to apply */
+    1:TIncrement increment
+  ) throws (1:IOError io)
+
+
+  void incrementRows(
+    /** The list of increments */
+    1:list<TIncrement> increments
+  ) throws (1:IOError io)
+
+  /**
    * Completely delete the row's cells marked with a timestamp
    * equal-to or older than the passed timestamp.
    */

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java?rev=1344034&r1=1344033&r2=1344034&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java
Tue May 29 22:31:54 2012
@@ -37,12 +37,14 @@ import org.apache.hadoop.hbase.HConstant
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.filter.ParseFilter;
+import org.apache.hadoop.hbase.thrift.ThriftServerRunner.HBaseHandler;
 import org.apache.hadoop.hbase.thrift.generated.BatchMutation;
 import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor;
 import org.apache.hadoop.hbase.thrift.generated.Hbase;
 import org.apache.hadoop.hbase.thrift.generated.IOError;
 import org.apache.hadoop.hbase.thrift.generated.Mutation;
 import org.apache.hadoop.hbase.thrift.generated.TCell;
+import org.apache.hadoop.hbase.thrift.generated.TIncrement;
 import org.apache.hadoop.hbase.thrift.generated.TRegionInfo;
 import org.apache.hadoop.hbase.thrift.generated.TRowResult;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -70,11 +72,15 @@ public class TestThriftServer {
   private static ByteBuffer asByteBuffer(String i) {
     return ByteBuffer.wrap(Bytes.toBytes(i));
   }
+  private static ByteBuffer asByteBuffer(long l) {
+    return ByteBuffer.wrap(Bytes.toBytes(l));
+  }
 
   // Static names for tables, columns, rows, and values
   private static ByteBuffer tableAname = asByteBuffer("tableA");
   private static ByteBuffer tableBname = asByteBuffer("tableB");
   private static ByteBuffer columnAname = asByteBuffer("columnA:");
+  private static ByteBuffer columnAAname = asByteBuffer("columnA:A");
   private static ByteBuffer columnBname = asByteBuffer("columnB:");
   private static ByteBuffer rowAname = asByteBuffer("rowA");
   private static ByteBuffer rowBname = asByteBuffer("rowB");
@@ -82,9 +88,11 @@ public class TestThriftServer {
   private static ByteBuffer valueBname = asByteBuffer("valueB");
   private static ByteBuffer valueCname = asByteBuffer("valueC");
   private static ByteBuffer valueDname = asByteBuffer("valueD");
+  private static ByteBuffer valueEname = asByteBuffer(100l);
 
   @BeforeClass
   public static void beforeClass() throws Exception {
+    UTIL.getConfiguration().setBoolean(ThriftServerRunner.COALESCE_INC_KEY, true);
     UTIL.startMiniCluster();
   }
 
@@ -112,6 +120,7 @@ public class TestThriftServer {
     doTestGetTableRegions();
     doTestFilterRegistration();
     doTestGetRegionInfo();
+    doTestIncrements();
   }
 
   /**
@@ -237,6 +246,44 @@ public class TestThriftServer {
     return record.getMetric(name).longValue();
   }
 
+  public void doTestIncrements() throws Exception {
+    ThriftServerRunner.HBaseHandler handler =
+        new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
+    createTestTables(handler);
+    doTestIncrements(handler);
+    dropTestTables(handler);
+  }
+
+  public static void doTestIncrements(HBaseHandler handler) throws Exception {
+    List<Mutation> mutations = new ArrayList<Mutation>(1);
+    mutations.add(new Mutation(false, columnAAname, valueEname, true));
+    mutations.add(new Mutation(false, columnAname, valueEname, true));
+    handler.mutateRow(tableAname, rowAname, mutations, null);
+    handler.mutateRow(tableAname, rowBname, mutations, null);
+
+    List<TIncrement> increments = new ArrayList<TIncrement>();
+    increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
+    increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
+    increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
+
+    int numIncrements = 60000;
+    for (int i = 0; i < numIncrements; i++) {
+      handler.increment(new TIncrement(tableAname, rowAname, columnAname, 2));
+      handler.incrementRows(increments);
+    }
+
+    Thread.sleep(1000);
+    long lv = handler.get(tableAname, rowAname, columnAname, null).get(0).value.getLong();
+    assertEquals((100 + (2 * numIncrements)), lv );
+
+
+    lv = handler.get(tableAname, rowBname, columnAAname, null).get(0).value.getLong();
+    assertEquals((100 + (3 * 7 * numIncrements)), lv);
+
+    assertTrue(handler.coalescer.getSuccessfulCoalescings() > 0);
+
+  }
+
   /**
    * Tests adding a series of Mutations and BatchMutations, including a
    * delete mutation.  Also tests data retrieval, and getting back multiple



Mime
View raw message