Review Board 1.7.22


hbase-4507 Create checkAndPut variant that exposes timestamp

Review Request #2118 - Created Sept. 29, 2011 and updated

Michael Stack
hbase-4507
Reviewers
hbase
hbase-git
Adds a checkAndPut that takes a timestamp

 
src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
Revision 3679c02 New Change
[20] 21 lines
[+20]
22
import java.io.IOException;
22
import java.io.IOException;
23
import java.net.ConnectException;
23
import java.net.ConnectException;
24
import java.util.List;
24
import java.util.List;
25

    
   
25

   
26
import org.apache.hadoop.hbase.Abortable;
26
import org.apache.hadoop.hbase.Abortable;

    
   
27
import org.apache.hadoop.hbase.HConstants;
27
import org.apache.hadoop.hbase.HRegionInfo;
28
import org.apache.hadoop.hbase.HRegionInfo;
28
import org.apache.hadoop.hbase.HServerInfo;
29
import org.apache.hadoop.hbase.HServerInfo;
29
import org.apache.hadoop.hbase.NotServingRegionException;
30
import org.apache.hadoop.hbase.NotServingRegionException;
30
import org.apache.hadoop.hbase.Stoppable;
31
import org.apache.hadoop.hbase.Stoppable;
31
import org.apache.hadoop.hbase.client.Delete;
32
import org.apache.hadoop.hbase.client.Delete;
[+20] [20] 138 lines
[+20] [+] public int delete(final byte[] regionName, final List<Delete> deletes)
170
  public boolean checkAndPut(final byte[] regionName, final byte [] row,
171
  public boolean checkAndPut(final byte[] regionName, final byte [] row,
171
      final byte [] family, final byte [] qualifier, final byte [] value,
172
      final byte [] family, final byte [] qualifier, final byte [] value,
172
      final Put put)
173
      final Put put)
173
  throws IOException;
174
  throws IOException;
174

    
   
175

   

    
   
176
  /**

    
   
177
   * Atomically checks if a row/family/qualifier value match the expectedValue

    
   
178
   * AND that the passed <code>expectedTimestampOfLatestVersion</code> is the

    
   
179
   * timestamp of the latest version. If all checks pass, 

    
   
180
   * we will add the passed <code>put</code>. If passed expected value is null,

    
   
181
   * then the check is for existence of the row/column.

    
   
182
   * <p>Use this variation on checkAndPut to detect updates even if a previous

    
   
183
   * update wrote the same value (Each update will be given a unique

    
   
184
   * timestamp even if a swarm of checkAndPuts arrive in the same millisecond).

    
   
185
   * @param regionName region name

    
   
186
   * @param row row to check

    
   
187
   * @param family column family

    
   
188
   * @param qualifier column qualifier

    
   
189
   * @param value the expected value

    
   
190
   * @param expectedTimestampOfLatestVersion The expected timestamp of the most

    
   
191
   * recent version at this row/family/qualifier coordinates; pass

    
   
192
   * {@link HConstants#LATEST_TIMESTAMP} to have this method act like

    
   
193
   * {@link #checkAndPut(byte[], byte[], byte[], byte[], byte[], Put)}

    
   
194
   * @param put data to put if check succeeds

    
   
195
   * @throws IOException e

    
   
196
   * @return true if the new put was executed, false otherwise

    
   
197
   */

    
   
198
  public boolean checkAndPut(final byte[] regionName, final byte [] row,

    
   
199
      final byte [] family, final byte [] qualifier, final byte [] value,

    
   
200
      final long expectedTimestampOfLatestVersion, final Put put)

    
   
201
  throws IOException;
175

    
   
202

   
176
  /**
203
  /**
177
   * Atomically checks if a row/family/qualifier value match the expectedValue.
204
   * Atomically checks if a row/family/qualifier value match the expectedValue.
178
   * If it does, it adds the delete. If passed expected value is null, then the
205
   * If it does, it adds the delete. If passed expected value is null, then the
179
   * check is for non-existance of the row/column.
206
   * check is for non-existance of the row/column.
[+20] [20] 364 lines
src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Revision 6ec857c New Change
 
src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Revision 96b763b New Change
 
src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Revision 99b34cc New Change
 
  1. src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java: Loading...
  2. src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java: Loading...
  3. src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java: Loading...
  4. src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java: Loading...