Repository: hbase
Updated Branches:
  refs/heads/0.98 e7136813d -> ec66983a9


HBASE-14840 Sink cluster reports data replication request as success
though the data is not replicated (Ashish Singhi)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ec66983a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ec66983a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ec66983a

Branch: refs/heads/0.98
Commit: ec66983a9231e7e537a087f2e024a5983fbfcc36
Parents: e713681
Author: ramkrishna <[email protected]>
Authored: Fri Nov 20 15:55:33 2015 +0530
Committer: ramkrishna <[email protected]>
Committed: Fri Nov 20 15:55:33 2015 +0530

----------------------------------------------------------------------
 .../hbase/regionserver/HRegionServer.java       |  6 +++--
 .../replication/TestMasterReplication.java      | 25 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ec66983a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index bdda1d3..94e437f 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -4287,16 +4287,18 @@ public class HRegionServer implements 
ClientProtos.ClientService.BlockingInterfa
       final ReplicateWALEntryRequest request)
   throws ServiceException {
     try {
+      checkOpen();
       if (replicationSinkHandler != null) {
-        checkOpen();
         requestCount.increment();
         List<WALEntry> entries = request.getEntryList();
         CellScanner cellScanner = 
((PayloadCarryingRpcController)controller).cellScanner();
         rsHost.preReplicateLogEntries(entries, cellScanner);
         replicationSinkHandler.replicateLogEntries(entries, cellScanner);
         rsHost.postReplicateLogEntries(entries, cellScanner);
+        return ReplicateWALEntryResponse.newBuilder().build();
+      } else {
+        throw new ServiceException("Replication services are not initialized 
yet");
       }
-      return ReplicateWALEntryResponse.newBuilder().build();
     } catch (IOException ie) {
       throw new ServiceException(ie);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ec66983a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java
index f2e330e..5935045 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java
@@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
 import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.zookeeper.MiniZooKeeperCluster;
@@ -58,6 +59,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.google.protobuf.ServiceException;
+
 @Category(LargeTests.class)
 public class TestMasterReplication {
 
@@ -244,6 +247,28 @@ public class TestMasterReplication {
     }
   }
 
+  /*
+   * Test RSRpcServices#replicateWALEntry when replication is disabled. This 
is to simulate
+   * HBASE-14840
+   */
+  @Test(timeout = 180000, expected = ServiceException.class)
+  public void testReplicateWALEntryWhenReplicationIsDisabled() throws 
Exception {
+    LOG.info("testSimplePutDelete");
+    baseConfiguration.setBoolean(HConstants.REPLICATION_ENABLE_KEY, false);
+    HTable[] htables = null;
+    try {
+      startMiniClusters(1);
+      createTableOnClusters(table);
+      htables = getHTablesOnClusters(tableName);
+
+      HRegionServer rs = utilities[0].getRSForFirstRegionInTable(tableName);
+      rs.replicateWALEntry(null, null);
+    } finally {
+      close(htables);
+      shutDownMiniClusters();
+    }
+  }
+
   @After
   public void tearDown() throws IOException {
     configurations = null;

Reply via email to