Review Board 1.7.22


HBASE-5203 Group atomic put/delete operation into a single WALEdit to handle region server failures.

Review Request #3510 - Created Jan. 16, 2012 and submitted

Lars Hofhansl
trunk
HBASE-5203
Reviewers
hbase
stack, tedyu
hbase
Basically a rewrite (sorry about that) of HBASE-3485 "Allow atomic put/delete in one call".
This makes this actually correct in the case of RegionServer failures (HBASE-3485 was correct for all scenarios but RegionServer failures).
HRegion.mutateRow(...) now groups all edits into a single WALEdit and appends all edits in one call. Only then are the memstore edits applied.
This is the first time that WALEdits can contain KVs from different types of operations. So I also had to fix the replication code to understand that.
WAL recovery already handles this case.
* Tests added in HBASE-3485
* manual testing.
* passes all tests.
http://svn.apache.org/repos/asf/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java
Revision 1232110 New Change
[20] 135 lines
[+20] [+] public class Delete extends Mutation
136
    list.add(kv);
136
    list.add(kv);
137
    familyMap.put(kv.getFamily(), list);
137
    familyMap.put(kv.getFamily(), list);
138
  }
138
  }
139

    
   
139

   
140
  /**
140
  /**

    
   
141
   * Advanced use only.

    
   
142
   * Add an existing delete marker to this Delete object.

    
   
143
   * @param kv An existing KeyValue of type "delete".

    
   
144
   * @return this for invocation chaining

    
   
145
   * @throws IOException

    
   
146
   */

    
   
147
  public Delete addDeleteMarker(KeyValue kv) throws IOException {

    
   
148
    if (!kv.isDelete()) {

    
   
149
      throw new IOException("The recently added KeyValue is not of type "

    
   
150
          + "delete. Rowkey: " + Bytes.toStringBinary(this.row));

    
   
151
    }

    
   
152
    if (Bytes.compareTo(this.row, 0, row.length, kv.getBuffer(),

    
   
153
        kv.getRowOffset(), kv.getRowLength()) != 0) {

    
   
154
      throw new IOException("The row in the recently added KeyValue "

    
   
155
          + Bytes.toStringBinary(kv.getBuffer(), kv.getRowOffset(),

    
   
156
              kv.getRowLength()) + " doesn't match the original one "

    
   
157
          + Bytes.toStringBinary(this.row));

    
   
158
    }

    
   
159
    byte [] family = kv.getFamily();

    
   
160
    List<KeyValue> list = familyMap.get(family);

    
   
161
    if (list == null) {

    
   
162
      list = new ArrayList<KeyValue>();

    
   
163
    }

    
   
164
    list.add(kv);

    
   
165
    familyMap.put(family, list);

    
   
166
    return this;

    
   
167
  }

    
   
168

   

    
   
169
  /**
141
   * Delete all versions of all columns of the specified family.
170
   * Delete all versions of all columns of the specified family.
142
   * <p>
171
   * <p>
143
   * Overrides previous calls to deleteColumn and deleteColumns for the
172
   * Overrides previous calls to deleteColumn and deleteColumns for the
144
   * specified family.
173
   * specified family.
145
   * @param family family name
174
   * @param family family name
[+20] [20] 157 lines
http://svn.apache.org/repos/asf/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Revision 1232110 New Change
 
http://svn.apache.org/repos/asf/hbase/trunk/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSink.java
Revision 1232110 New Change
 
http://svn.apache.org/repos/asf/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
Revision 1232110 New Change
 
http://svn.apache.org/repos/asf/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
Revision 1232110 New Change
 
  1. http://svn.apache.org/repos/asf/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java: Loading...
  2. http://svn.apache.org/repos/asf/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java: Loading...
  3. http://svn.apache.org/repos/asf/hbase/trunk/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSink.java: Loading...
  4. http://svn.apache.org/repos/asf/hbase/trunk/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java: Loading...
  5. http://svn.apache.org/repos/asf/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java: Loading...