HBASE-14840 Sink cluster reports data replication request as success

though the data is not replicated (Ashish Singhi)
This commit is contained in:
ramkrishna 2015-11-20 15:57:10 +05:30
parent 8dbbe96e04
commit 86be690b07
2 changed files with 31 additions and 2 deletions

View File

@ -1794,16 +1794,18 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
public ReplicateWALEntryResponse replicateWALEntry(final RpcController controller,
final ReplicateWALEntryRequest request) throws ServiceException {
try {
checkOpen();
if (regionServer.replicationSinkHandler != null) {
checkOpen();
requestCount.increment();
List<WALEntry> entries = request.getEntryList();
CellScanner cellScanner = ((PayloadCarryingRpcController)controller).cellScanner();
regionServer.getRegionServerCoprocessorHost().preReplicateLogEntries(entries, cellScanner);
regionServer.replicationSinkHandler.replicateLogEntries(entries, cellScanner);
regionServer.getRegionServerCoprocessorHost().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);
}

View File

@ -48,6 +48,8 @@ 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.RSRpcServices;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.ReplicationTests;
@ -59,6 +61,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.google.protobuf.ServiceException;
@Category({ReplicationTests.class, LargeTests.class})
public class TestMasterReplication {
@ -245,6 +249,29 @@ 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);
Table[] htables = null;
try {
startMiniClusters(1);
createTableOnClusters(table);
htables = getHTablesOnClusters(tableName);
HRegionServer rs = utilities[0].getRSForFirstRegionInTable(tableName);
RSRpcServices rsrpc = new RSRpcServices(rs);
rsrpc.replicateWALEntry(null, null);
} finally {
close(htables);
shutDownMiniClusters();
}
}
@After
public void tearDown() throws IOException {
configurations = null;