hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1202057 - in /hbase/branches/0.92: ./ src/main/java/org/apache/hadoop/hbase/client/coprocessor/ src/main/java/org/apache/hadoop/hbase/regionserver/ src/test/java/org/apache/hadoop/hbase/regionserver/
Date Tue, 15 Nov 2011 06:32:48 GMT
Author: garyh
Date: Tue Nov 15 06:32:48 2011
New Revision: 1202057

URL: http://svn.apache.org/viewvc?rev=1202057&view=rev
Log:
HBASE-4784  Handle void return types in CoprocessorProtocol methods

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/coprocessor/ExecResult.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1202057&r1=1202056&r2=1202057&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Tue Nov 15 06:32:48 2011
@@ -424,6 +424,8 @@ Release 0.92.0 - Unreleased
    HBASE-4777  Write back to client 'incompatible' if we show up with wrong version
    HBASE-4775  Remove -ea from all but tests; enable it if you need it testing
    HBASE-4776  HLog.closed should be checked inside of updateLock
+   HBASE-4784  Void return types not handled correctly for CoprocessorProtocol
+               methods
 
   TESTS
    HBASE-4492  TestRollingRestart fails intermittently

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/coprocessor/ExecResult.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/coprocessor/ExecResult.java?rev=1202057&r1=1202056&r2=1202057&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/coprocessor/ExecResult.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/client/coprocessor/ExecResult.java
Tue Nov 15 06:32:48 2011
@@ -48,15 +48,13 @@ import java.io.Serializable;
  */
 public class ExecResult implements Writable {
   private byte[] regionName;
-  private Class<?> valueType;
   private Object value;
 
   public ExecResult() {
   }
 
-  public ExecResult(byte[] region, Class<?> valueType, Object value) {
+  public ExecResult(byte[] region, Object value) {
     this.regionName = region;
-    this.valueType = valueType;
     this.value = value;
   }
 
@@ -73,24 +71,11 @@ public class ExecResult implements Writa
     Bytes.writeByteArray(out, regionName);
     HbaseObjectWritable.writeObject(out, value,
         value != null ? value.getClass() : Writable.class, null);
-    Class<?> alternativeSerializationClass;
-    if(value instanceof Writable){
-      alternativeSerializationClass = Writable.class;
-    } else {
-      alternativeSerializationClass = Serializable.class;
-    }
-    out.writeUTF((valueType != null ? valueType : alternativeSerializationClass).getName());
   }
 
   @Override
   public void readFields(DataInput in) throws IOException {
     regionName = Bytes.readByteArray(in);
     value = HbaseObjectWritable.readObject(in, null);
-    String className = in.readUTF();
-    try {
-      valueType = Classes.extendedForName(className);
-    } catch (ClassNotFoundException e) {
-      throw new IOException("Unable to find class of type: " + className );
-    }
   }
 }

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1202057&r1=1202056&r2=1202057&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Tue
Nov 15 06:32:48 2011
@@ -3936,13 +3936,11 @@ public class HRegion implements HeapSize
 
     CoprocessorProtocol handler = protocolHandlers.getInstance(protocol);
     Object value;
-    Class<?> returnType;
 
     try {
       Method method = protocol.getMethod(
           call.getMethodName(), call.getParameterClasses());
       method.setAccessible(true);
-      returnType = method.getReturnType();
 
       value = method.invoke(handler, call.getParameters());
     } catch (InvocationTargetException e) {
@@ -3962,7 +3960,7 @@ public class HRegion implements HeapSize
       throw ioe;
     }
 
-    return new ExecResult(getRegionName(), returnType, value);
+    return new ExecResult(getRegionName(), value);
   }
 
   /*

Modified: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java?rev=1202057&r1=1202056&r2=1202057&view=diff
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
(original)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java
Tue Nov 15 06:32:48 2011
@@ -62,6 +62,7 @@ public class TestServerCustomProtocol {
     public int getPingCount();
     public int incrementCount(int diff);
     public String hello(String name);
+    public void noop();
   }
 
   /* Test protocol implementation */
@@ -96,6 +97,11 @@ public class TestServerCustomProtocol {
     }
 
     @Override
+    public void noop() {
+      // do nothing, just test void return type
+    }
+
+    @Override
     public ProtocolSignature getProtocolSignature(
         String protocol, long version, int clientMethodsHashCode)
     throws IOException {
@@ -332,6 +338,26 @@ public class TestServerCustomProtocol {
     verifyRegionResults(table, results, null, ROW_C);
   }
 
+  @Test
+  public void testVoidReturnType() throws Throwable {
+    HTable table = new HTable(util.getConfiguration(), TEST_TABLE);
+
+    Map<byte[],Object> results = table.coprocessorExec(PingProtocol.class,
+        ROW_A, ROW_C,
+        new Batch.Call<PingProtocol,Object>(){
+          public Object call(PingProtocol instance) {
+            instance.noop();
+            return null;
+          }
+        });
+
+    assertEquals("Should have results from three regions", 3, results.size());
+    // all results should be null
+    for (Object v : results.values()) {
+      assertNull(v);
+    }
+  }
+
   private void verifyRegionResults(HTable table,
       Map<byte[],String> results, byte[] row) throws Exception {
     verifyRegionResults(table, results, "pong", row);



Mime
View raw message