hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmhs...@apache.org
Subject svn commit: r1511337 - in /hbase/branches/0.95/hbase-client/src: main/java/org/apache/hadoop/hbase/client/Mutation.java test/java/org/apache/hadoop/hbase/client/TestPutWriteToWal.java
Date Wed, 07 Aug 2013 14:47:40 GMT
Author: jmhsieh
Date: Wed Aug  7 14:47:39 2013
New Revision: 1511337

URL: http://svn.apache.org/r1511337
Log:
HBASE-9093 HBase client API: Restore the writeToWAL method in 0.95 (Hari Shreedharan)

Re-added to the 0.95 branch as deprecated methods.



Added:
    hbase/branches/0.95/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPutWriteToWal.java
Modified:
    hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java

Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java?rev=1511337&r1=1511336&r2=1511337&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
(original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
Wed Aug  7 14:47:39 2013
@@ -179,6 +179,34 @@ public abstract class Mutation extends O
   }
 
   /**
+   * Set the durability for this mutation. If this is set to true,
+   * the default durability of the table is set.
+   * @param writeToWal
+   */
+  @Deprecated
+  public void setWriteToWAL(boolean writeToWal) {
+    if(!writeToWal) {
+      setDurability(Durability.SKIP_WAL);
+    } else {
+    // This is required to handle the case where this method is
+    // called twice, first with writeToWal = false,
+    // and then with writeToWal = true
+      setDurability(Durability.USE_DEFAULT);
+    }
+  }
+
+  /**
+   * Get the durability for this mutation.
+   * @return - true if this mutation is set to write to the WAL either
+   * synchronously, asynchronously or fsync to disk on the file system.
+   * - to get the exact durability, use the {#getDurability} method.
+   */
+  @Deprecated
+  public boolean getWriteToWAL() {
+    return Durability.SKIP_WAL != getDurability();
+  }
+
+  /**
    * Method for retrieving the put's familyMap
    * @return familyMap
    */

Added: hbase/branches/0.95/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPutWriteToWal.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPutWriteToWal.java?rev=1511337&view=auto
==============================================================================
--- hbase/branches/0.95/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPutWriteToWal.java
(added)
+++ hbase/branches/0.95/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestPutWriteToWal.java
Wed Aug  7 14:47:39 2013
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.hadoop.hbase.client;
+
+import org.apache.hadoop.hbase.SmallTests;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Tests for testing methods added in HBASE-9093. This set of tests is meant
+ * to test the {@linkplain Mutation#setWriteToWAL(boolean)}
+ * and {@linkplain Mutation#getWriteToWAL()} methods which provide
+ * a compatibility layer with HBase versions < 95's client side WAL semantics.
+ */
+@Category(SmallTests.class)
+public class TestPutWriteToWal {
+
+  private Put put;
+  @Before
+  public void setUp() throws Exception {
+    put = new Put("test".getBytes());
+  }
+
+  @Test
+  public void testWriteToWAL(){
+    put.setWriteToWAL(true);
+    Assert.assertEquals(Durability.USE_DEFAULT, put.getDurability());
+  }
+
+  @Test
+  public void testNoWriteToWAL() {
+    put.setWriteToWAL(false);
+    Assert.assertEquals(Durability.SKIP_WAL, put.getDurability());
+  }
+
+  @Test
+  public void testWriteToWALSwitch() {
+    put.setWriteToWAL(false);
+    Assert.assertEquals(Durability.SKIP_WAL, put.getDurability());
+    put.setWriteToWAL(true);
+    Assert.assertEquals(Durability.USE_DEFAULT, put.getDurability());
+  }
+
+  @Test
+  public void testPutCopy() {
+    put.setWriteToWAL(false);
+    Put putCopy1 = new Put(put);
+    Assert.assertEquals(Durability.SKIP_WAL, putCopy1.getDurability());
+
+    put.setWriteToWAL(true);
+    Put putCopy2 = new Put(put);
+    Assert.assertEquals(Durability.USE_DEFAULT, putCopy2.getDurability());
+  }
+}



Mime
View raw message