From 892e2726628497c6816bf652a9ccf1de4409e0bd Mon Sep 17 00:00:00 2001 From: Ashish Singhi Date: Fri, 20 Nov 2015 15:28:35 +0530 Subject: [PATCH] HBASE-14840 Sink cluster reports data replication request as success though the data is not replicated --- .../hadoop/hbase/regionserver/HRegionServer.java | 6 ++++-- .../hbase/replication/TestMasterReplication.java | 25 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) 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 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); } 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; -- 1.9.2.msysgit.0