HBASE-7688. Master coprocessor RPCs don't propagate exceptions (Mike Lewis)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1439692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
938a6e7ccd
commit
c2272d7f22
|
@ -2357,7 +2357,7 @@ Server {
|
||||||
.mergeFrom(call.getRequest()).build();
|
.mergeFrom(call.getRequest()).build();
|
||||||
final Message.Builder responseBuilder =
|
final Message.Builder responseBuilder =
|
||||||
service.getResponsePrototype(methodDesc).newBuilderForType();
|
service.getResponsePrototype(methodDesc).newBuilderForType();
|
||||||
service.callMethod(methodDesc, controller, execRequest, new RpcCallback<Message>() {
|
service.callMethod(methodDesc, execController, execRequest, new RpcCallback<Message>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Message message) {
|
public void run(Message message) {
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
|
|
|
@ -18,22 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.coprocessor;
|
package org.apache.hadoop.hbase.coprocessor;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import com.google.protobuf.ByteString;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import com.google.protobuf.RpcController;
|
||||||
import static org.junit.Assert.assertNull;
|
import com.google.protobuf.ServiceException;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.MediumTests;
|
import org.apache.hadoop.hbase.MediumTests;
|
||||||
|
@ -44,6 +42,7 @@ import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.client.coprocessor.Batch;
|
import org.apache.hadoop.hbase.client.coprocessor.Batch;
|
||||||
import org.apache.hadoop.hbase.coprocessor.protobuf.generated.ColumnAggregationProtos;
|
import org.apache.hadoop.hbase.coprocessor.protobuf.generated.ColumnAggregationProtos;
|
||||||
import org.apache.hadoop.hbase.ipc.BlockingRpcCallback;
|
import org.apache.hadoop.hbase.ipc.BlockingRpcCallback;
|
||||||
|
import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
|
||||||
import org.apache.hadoop.hbase.ipc.ServerRpcController;
|
import org.apache.hadoop.hbase.ipc.ServerRpcController;
|
||||||
import org.apache.hadoop.hbase.ipc.protobuf.generated.TestProtos;
|
import org.apache.hadoop.hbase.ipc.protobuf.generated.TestProtos;
|
||||||
import org.apache.hadoop.hbase.ipc.protobuf.generated.TestRpcServiceProtos;
|
import org.apache.hadoop.hbase.ipc.protobuf.generated.TestRpcServiceProtos;
|
||||||
|
@ -53,9 +52,11 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
import com.google.protobuf.ByteString;
|
import static org.junit.Assert.assertEquals;
|
||||||
import com.google.protobuf.RpcController;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import com.google.protobuf.ServiceException;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestEndpoint: test cases to verify coprocessor Endpoint
|
* TestEndpoint: test cases to verify coprocessor Endpoint
|
||||||
|
@ -68,7 +69,7 @@ public class TestCoprocessorEndpoint {
|
||||||
private static final byte[] TEST_FAMILY = Bytes.toBytes("TestFamily");
|
private static final byte[] TEST_FAMILY = Bytes.toBytes("TestFamily");
|
||||||
private static final byte[] TEST_QUALIFIER = Bytes.toBytes("TestQualifier");
|
private static final byte[] TEST_QUALIFIER = Bytes.toBytes("TestQualifier");
|
||||||
private static byte[] ROW = Bytes.toBytes("testRow");
|
private static byte[] ROW = Bytes.toBytes("testRow");
|
||||||
|
|
||||||
private static final int ROWSIZE = 20;
|
private static final int ROWSIZE = 20;
|
||||||
private static final int rowSeperator1 = 5;
|
private static final int rowSeperator1 = 5;
|
||||||
private static final int rowSeperator2 = 12;
|
private static final int rowSeperator2 = 12;
|
||||||
|
@ -287,6 +288,41 @@ public class TestCoprocessorEndpoint {
|
||||||
admin.close();
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCoprocessorError() throws Exception {
|
||||||
|
Configuration configuration = new Configuration(util.getConfiguration());
|
||||||
|
// Make it not retry forever
|
||||||
|
configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
|
||||||
|
HTable table = new HTable(configuration, TEST_TABLE);
|
||||||
|
|
||||||
|
try {
|
||||||
|
CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);
|
||||||
|
|
||||||
|
TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
|
||||||
|
TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);
|
||||||
|
|
||||||
|
service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
|
||||||
|
fail("Should have thrown an exception");
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
} finally {
|
||||||
|
table.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMasterCoprocessorError() throws Throwable {
|
||||||
|
HBaseAdmin admin = util.getHBaseAdmin();
|
||||||
|
TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service =
|
||||||
|
TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(admin.coprocessorService());
|
||||||
|
try {
|
||||||
|
service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
|
||||||
|
fail("Should have thrown an exception");
|
||||||
|
} catch (ServiceException e) {
|
||||||
|
} finally {
|
||||||
|
admin.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static byte[][] makeN(byte[] base, int n) {
|
private static byte[][] makeN(byte[] base, int n) {
|
||||||
byte[][] ret = new byte[n][];
|
byte[][] ret = new byte[n][];
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
|
|
Loading…
Reference in New Issue