You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2012/12/20 04:55:54 UTC
svn commit: r1424282 - in /hbase/trunk/hbase-server/src:
main/java/org/apache/hadoop/hbase/client/HTable.java
test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
Author: stack
Date: Thu Dec 20 03:55:54 2012
New Revision: 1424282
URL: http://svn.apache.org/viewvc?rev=1424282&view=rev
Log:
HBASE-7397 HTable.coprocessorService() should allow null values in returned Map
Modified:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1424282&r1=1424281&r2=1424282&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HTable.java Thu Dec 20 03:55:54 2012
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.NavigableMap;
import java.util.TreeMap;
import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@@ -1259,17 +1258,11 @@ public class HTable implements HTableInt
public <T extends Service, R> Map<byte[],R> coprocessorService(final Class<T> service,
byte[] startKey, byte[] endKey, final Batch.Call<T,R> callable)
throws ServiceException, Throwable {
- final Map<byte[],R> results = new ConcurrentSkipListMap<byte[], R>(Bytes.BYTES_COMPARATOR);
+ final Map<byte[],R> results = Collections.synchronizedMap(
+ new TreeMap<byte[], R>(Bytes.BYTES_COMPARATOR));
coprocessorService(service, startKey, endKey, callable, new Batch.Callback<R>() {
public void update(byte[] region, byte[] row, R value) {
- if (value == null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Call to " + service.getName() +
- " received NULL value from Batch.Call for region " + Bytes.toStringBinary(region));
- }
- } else {
- results.put(region, value);
- }
+ results.put(region, value);
}
});
return results;
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java?rev=1424282&r1=1424281&r2=1424282&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoprocessorEndpoint.java Thu Dec 20 03:55:54 2012
@@ -257,6 +257,44 @@ public class TestCoprocessorEndpoint {
}
@Test
+ public void testCoprocessorServiceNullResponse() throws Throwable {
+ HTable table = new HTable(util.getConfiguration(), TEST_TABLE);
+ NavigableMap<HRegionInfo,ServerName> regions = table.getRegionLocations();
+
+ final TestProtos.EchoRequestProto request =
+ TestProtos.EchoRequestProto.newBuilder().setMessage("hello").build();
+ try {
+ // scan: for all regions
+ final RpcController controller = new ServerRpcController();
+ // test that null results are supported
+ Map<byte[], String> results = table.coprocessorService(TestRpcServiceProtos.TestProtobufRpcProto.class,
+ ROWS[0], ROWS[ROWS.length - 1],
+ new Batch.Call<TestRpcServiceProtos.TestProtobufRpcProto, String>() {
+ public String call(TestRpcServiceProtos.TestProtobufRpcProto instance)
+ throws IOException {
+ BlockingRpcCallback<TestProtos.EchoResponseProto> callback = new BlockingRpcCallback<TestProtos.EchoResponseProto>();
+ instance.echo(controller, request, callback);
+ TestProtos.EchoResponseProto response = callback.get();
+ LOG.debug("Batch.Call got result " + response);
+ return null;
+ }
+ }
+ );
+ for (Map.Entry<byte[], String> e : results.entrySet()) {
+ LOG.info("Got value "+e.getValue()+" for region "+Bytes.toStringBinary(e.getKey()));
+ }
+ assertEquals(3, results.size());
+ for (HRegionInfo info : regions.navigableKeySet()) {
+ LOG.info("Region info is "+info.getRegionNameAsString());
+ assertTrue(results.containsKey(info.getRegionName()));
+ assertNull(results.get(info.getRegionName()));
+ }
+ } finally {
+ table.close();
+ }
+ }
+
+ @Test
public void testMasterCoprocessorService() throws Throwable {
HBaseAdmin admin = util.getHBaseAdmin();
final TestProtos.EchoRequestProto request =