hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1133427 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/Delete.java src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Date Wed, 08 Jun 2011 15:27:09 GMT
Author: apurtell
Date: Wed Jun  8 15:27:09 2011
New Revision: 1133427

URL: http://svn.apache.org/viewvc?rev=1133427&view=rev
Log:
HBASE-3961  Add Delete.setWriteToWAL functionality

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1133427&r1=1133426&r2=1133427&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Jun  8 15:27:09 2011
@@ -247,6 +247,7 @@ Release 0.91.0 - Unreleased
                (Alejandro Abdelnur)
    HBASE-3941  "hbase version" command line should print version info
                (Jolly Chen)
+   HBASE-3961  Add Delete.setWriteToWAL functionality (Bruno Dumon)
 
   TASKS
    HBASE-3559  Move report of split to master OFF the heartbeat channel

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java?rev=1133427&r1=1133426&r2=1133427&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/Delete.java Wed Jun  8 15:27:09
2011
@@ -69,12 +69,13 @@ import java.util.TreeMap;
  * timestamp.  The constructor timestamp is not referenced.
  */
 public class Delete implements Writable, Row, Comparable<Row> {
-  private static final byte DELETE_VERSION = (byte)2;
+  private static final byte DELETE_VERSION = (byte)3;
 
   private byte [] row = null;
   // This ts is only used when doing a deleteRow.  Anything less,
   private long ts;
   private long lockId = -1L;
+  private boolean writeToWAL = true;
   private final Map<byte [], List<KeyValue>> familyMap =
     new TreeMap<byte [], List<KeyValue>>(Bytes.BYTES_COMPARATOR);
 
@@ -128,6 +129,7 @@ public class Delete implements Writable,
     this.ts = d.getTimeStamp();
     this.lockId = d.getLockId();
     this.familyMap.putAll(d.getFamilyMap());
+    this.writeToWAL = d.writeToWAL;
   }
 
   public int compareTo(final Row d) {
@@ -382,6 +384,9 @@ public class Delete implements Writable,
     this.row = Bytes.readByteArray(in);
     this.ts = in.readLong();
     this.lockId = in.readLong();
+    if (version > 2) {
+      this.writeToWAL = in.readBoolean();
+    }
     this.familyMap.clear();
     int numFamilies = in.readInt();
     for(int i=0;i<numFamilies;i++) {
@@ -413,6 +418,7 @@ public class Delete implements Writable,
     Bytes.writeByteArray(out, this.row);
     out.writeLong(this.ts);
     out.writeLong(this.lockId);
+    out.writeBoolean(this.writeToWAL);
     out.writeInt(familyMap.size());
     for(Map.Entry<byte [], List<KeyValue>> entry : familyMap.entrySet()) {
       Bytes.writeByteArray(out, entry.getKey());
@@ -460,4 +466,20 @@ public class Delete implements Writable,
     this.deleteColumn(parts[0], parts[1], HConstants.LATEST_TIMESTAMP);
     return this;
   }
+
+  /**
+   * @return true if edits should be applied to WAL, false if not
+   */
+  public boolean getWriteToWAL() {
+    return this.writeToWAL;
+  }
+
+  /**
+   * Set whether this Delete should be written to the WAL or not.
+   * Not writing the WAL means you may lose edits on server crash.
+   * @param write true if edits should be written to WAL, false if not
+   */
+  public void setWriteToWAL(boolean write) {
+    this.writeToWAL = write;
+  }
 }

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1133427&r1=1133426&r2=1133427&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Wed
Jun  8 15:27:09 2011
@@ -2068,7 +2068,7 @@ public class HRegionServer implements HR
       throws IOException {
     checkOpen();
     try {
-      boolean writeToWAL = true;
+      boolean writeToWAL = delete.getWriteToWAL();
       this.requestCount.incrementAndGet();
       HRegion region = getRegion(regionName);
       if (!region.getRegionInfo().isMetaTable()) {
@@ -2088,7 +2088,6 @@ public class HRegionServer implements HR
     checkOpen();
     HRegion region = null;
     try {
-      boolean writeToWAL = true;
       region = getRegion(regionName);
       if (!region.getRegionInfo().isMetaTable()) {
         this.cacheFlusher.reclaimMemStoreMemory();
@@ -2098,7 +2097,7 @@ public class HRegionServer implements HR
       for (Delete delete : deletes) {
         this.requestCount.incrementAndGet();
         locks[i] = getLockFromId(delete.getLockId());
-        region.delete(delete, locks[i], writeToWAL);
+        region.delete(delete, locks[i], delete.getWriteToWAL());
         i++;
       }
     } catch (WrongRegionException ex) {



Mime
View raw message