hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raw...@apache.org
Subject svn commit: r1066149 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Tue, 01 Feb 2011 19:15:20 GMT
Author: rawson
Date: Tue Feb  1 19:15:19 2011
New Revision: 1066149

URL: http://svn.apache.org/viewvc?rev=1066149&view=rev
Log:
HBASE-3494  checkAndPut implementation doesnt verify row param and writable row are the same

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1066149&r1=1066148&r2=1066149&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Tue Feb  1 19:15:19 2011
@@ -34,7 +34,8 @@ Release 0.91.0 - Unreleased
    	           causing data loss during recovery
    HBASE-3493  HMaster sometimes hangs during initialization due to missing
                notify call (Bruno Dumon via Stack)
-
+   HBASE-3494  checkAndPut implementation doesnt verify row param and writable 
+              row are the same
 
   IMPROVEMENTS
    HBASE-2001  Coprocessors: Colocate user code with regions (Mingjie Lai via

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1066149&r1=1066148&r2=1066149&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Tue Feb  1
19:15:19 2011
@@ -69,6 +69,7 @@ import org.apache.hadoop.hbase.client.Ge
 import org.apache.hadoop.hbase.client.Increment;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Row;
 import org.apache.hadoop.hbase.client.RowLock;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.coprocessor.Exec;
@@ -1635,7 +1636,11 @@ public class HRegion implements HeapSize
     checkResources();
     boolean isPut = w instanceof Put;
     if (!isPut && !(w instanceof Delete))
-      throw new IOException("Action must be Put or Delete");
+      throw new DoNotRetryIOException("Action must be Put or Delete");
+    Row r = (Row)w;
+    if (Bytes.compareTo(row, r.getRow()) != 0) {
+      throw new DoNotRetryIOException("Action's getRow must match the passed row");
+    }
 
     startRegionOperation();
     try {

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1066149&r1=1066148&r2=1066149&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java Tue Feb
 1 19:15:19 2011
@@ -34,6 +34,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestCase;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -96,6 +97,8 @@ public class TestHRegion extends HBaseTe
   protected final byte[] value1 = Bytes.toBytes("value1");
   protected final byte[] value2 = Bytes.toBytes("value2");
   protected final byte [] row = Bytes.toBytes("rowA");
+  protected final byte [] row2 = Bytes.toBytes("rowB");
+
 
   /**
    * @see org.apache.hadoop.hbase.HBaseTestCase#setUp()
@@ -605,6 +608,20 @@ public class TestHRegion extends HBaseTe
 
   }
 
+  public void testCheckAndPut_wrongRowInPut() throws IOException {
+    initHRegion(tableName, this.getName(), COLUMNS);
+
+    Put put = new Put(row2);
+    put.add(fam1, qual1, value1);
+    try {
+    boolean res = region.checkAndMutate(row,
+        fam1, qual1, value2, put, null, false);
+      fail();
+    } catch (DoNotRetryIOException expected) {
+      // expected exception.
+    }
+  }
+
   public void testCheckAndDelete_ThatDeleteWasWritten() throws IOException{
     byte [] tableName = Bytes.toBytes("testtable");
     byte [] row1 = Bytes.toBytes("row1");



Mime
View raw message