avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1027741 - in /avro/trunk: ./ lang/java/src/java/org/apache/avro/mapred/tether/ lang/java/src/java/org/apache/avro/reflect/ lang/java/src/java/org/apache/avro/specific/ lang/java/src/test/java/org/apache/avro/ lang/java/src/test/java/org/ap...
Date Tue, 26 Oct 2010 20:45:46 GMT
Author: cutting
Date: Tue Oct 26 20:45:46 2010
New Revision: 1027741

URL: http://svn.apache.org/viewvc?rev=1027741&view=rev
Log:
AVRO-683. Java: Fix RPC proxy factories to not require casting.  Contributed by Stephen Gargan.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/src/java/org/apache/avro/mapred/tether/TetheredProcess.java
    avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectRequestor.java
    avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificRequestor.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestBulkData.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceReflect.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceSpecific.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolDatagram.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolHttp.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflect.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflectMeta.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecific.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/ipc/TestNettyServer.java
    avro/trunk/lang/java/src/test/java/org/apache/avro/mapred/tether/TetherTask.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Oct 26 20:45:46 2010
@@ -19,6 +19,9 @@ Avro 1.5.0 (unreleased)
     AVRO-682. Java: Add method DataFileStream.getMetaKeys().
     (Harsh J Chouraria via cutting)
 
+    AVRO-683. Java: Fix RPC proxy factories to not require casting.
+    (Stephen Gargan via cutting)
+
   BUG FIXES
 
     AVRO-675. C: Bytes and fixed setters don't update datum size.

Modified: avro/trunk/lang/java/src/java/org/apache/avro/mapred/tether/TetheredProcess.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/mapred/tether/TetheredProcess.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/mapred/tether/TetheredProcess.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/mapred/tether/TetheredProcess.java Tue Oct
26 20:45:46 2010
@@ -71,7 +71,7 @@ class TetheredProcess  {
       // open client, connecting to sub-process
       this.clientTransceiver =
         new SocketTransceiver(new InetSocketAddress(outputService.inputPort()));
-      this.inputClient = (InputProtocol)
+      this.inputClient =
         SpecificRequestor.getClient(InputProtocol.class, clientTransceiver);
 
 

Modified: avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectRequestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectRequestor.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectRequestor.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/reflect/ReflectRequestor.java Tue Oct 26
20:45:46 2010
@@ -52,24 +52,26 @@ public class ReflectRequestor extends Sp
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
-  public static Object getClient(Class<?> iface, Transceiver transciever)
+  public static <T> T getClient(Class<T> iface, Transceiver transciever) 
     throws IOException {
     return getClient(iface, transciever, ReflectData.get());
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
-  public static Object getClient(Class<?> iface, Transceiver transciever, ReflectData
reflectData)
-    throws IOException {
+  @SuppressWarnings("unchecked")
+  public static <T> T getClient(Class<T> iface, Transceiver transciever,
+                                ReflectData reflectData) throws IOException {
     Protocol protocol = reflectData.getProtocol(iface);
-    return Proxy.newProxyInstance(iface.getClassLoader(),
+    return (T)Proxy.newProxyInstance(iface.getClassLoader(), 
                                   new Class[] { iface },
                                   new ReflectRequestor(protocol, transciever));
   }
   
   /** Create a proxy instance whose methods invoke RPCs. */
-  public static Object getClient(Class<?> iface, ReflectRequestor rreq)
+  @SuppressWarnings("unchecked")
+  public static <T> T getClient(Class<T> iface, ReflectRequestor rreq) 
     throws IOException {
-    return Proxy.newProxyInstance(iface.getClassLoader(),
+    return (T)Proxy.newProxyInstance(iface.getClassLoader(), 
                                   new Class[] { iface }, rreq);
   }
 }

Modified: avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificRequestor.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificRequestor.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificRequestor.java (original)
+++ avro/trunk/lang/java/src/java/org/apache/avro/specific/SpecificRequestor.java Tue Oct
26 20:45:46 2010
@@ -84,25 +84,27 @@ public class SpecificRequestor extends R
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
-  public static Object getClient(Class<?> iface, Transceiver transciever)
+  public static  <T> T getClient(Class<T> iface, Transceiver transciever)
     throws IOException {
     return getClient(iface, transciever, SpecificData.get());
   }
 
   /** Create a proxy instance whose methods invoke RPCs. */
-  public static Object getClient(Class<?> iface, Transceiver transciever,
+  @SuppressWarnings("unchecked")
+  public static  <T> T getClient(Class<T> iface, Transceiver transciever,
                                  SpecificData specificData)
     throws IOException {
     Protocol protocol = specificData.getProtocol(iface);
-    return Proxy.newProxyInstance(iface.getClassLoader(),
+    return (T)Proxy.newProxyInstance(iface.getClassLoader(),
                                   new Class[] { iface },
                                   new SpecificRequestor(protocol, transciever));
   }
-  
+
   /** Create a proxy instance whose methods invoke RPCs. */
-  public static Object getClient(Class<?> iface, SpecificRequestor requestor)
+  @SuppressWarnings("unchecked")
+  public static <T> T getClient(Class<T> iface, SpecificRequestor requestor)
     throws IOException {
-    return Proxy.newProxyInstance(iface.getClassLoader(),
+    return (T)Proxy.newProxyInstance(iface.getClassLoader(),
                                   new Class[] { iface }, requestor);
   }
 }

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestBulkData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestBulkData.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestBulkData.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestBulkData.java Tue Oct 26 20:45:46
2010
@@ -71,7 +71,7 @@ public class TestBulkData {
     server.start();
     client =
       new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
-    proxy = (BulkData)SpecificRequestor.getClient(BulkData.class, client);
+    proxy = SpecificRequestor.getClient(BulkData.class, client);
   }
 
   @Test

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceReflect.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceReflect.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceReflect.java Tue Oct 26
20:45:46 2010
@@ -35,7 +35,7 @@ public class TestNamespaceReflect extend
                               new InetSocketAddress(0));
     server.start();
     client = new SocketTransceiver(new InetSocketAddress(server.getPort()));
-    proxy = (TestNamespace)ReflectRequestor.getClient(TestNamespace.class, client);
+    proxy = ReflectRequestor.getClient(TestNamespace.class, client);
   }
 
 }

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceSpecific.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceSpecific.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceSpecific.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestNamespaceSpecific.java Tue Oct
26 20:45:46 2010
@@ -59,7 +59,7 @@ public class TestNamespaceSpecific {
                               new InetSocketAddress(0));
     server.start();
     client = new SocketTransceiver(new InetSocketAddress(server.getPort()));
-    proxy = (TestNamespace)SpecificRequestor.getClient(TestNamespace.class, client);
+    proxy = SpecificRequestor.getClient(TestNamespace.class, client);
   }
 
   @Test

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolDatagram.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolDatagram.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolDatagram.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolDatagram.java Tue Oct 26
20:45:46 2010
@@ -38,7 +38,7 @@ public class TestProtocolDatagram extend
                                                new Random().nextInt(10000)+10000));
     server.start();
     client = new DatagramTransceiver(new InetSocketAddress("localhost", server.getPort()));
-    proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
+    proxy = SpecificRequestor.getClient(Simple.class, client);
   }
 
 }

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolHttp.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolHttp.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolHttp.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolHttp.java Tue Oct 26 20:45:46
2010
@@ -36,7 +36,7 @@ public class TestProtocolHttp extends Te
     server.start();
     client =
       new HttpTransceiver(new URL("http://127.0.0.1:"+server.getPort()+"/"));
-    proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
+    proxy = SpecificRequestor.getClient(Simple.class, client);
   }
 
 }

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflect.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflect.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflect.java Tue Oct 26
20:45:46 2010
@@ -77,7 +77,7 @@ public class TestProtocolReflect {
                               new InetSocketAddress(0));
     server.start();
     client = new SocketTransceiver(new InetSocketAddress(server.getPort()));
-    proxy = (Simple)ReflectRequestor.getClient(Simple.class, client);
+    proxy = ReflectRequestor.getClient(Simple.class, client);
   }
 
   @Test

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflectMeta.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflectMeta.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflectMeta.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolReflectMeta.java Tue Oct
26 20:45:46 2010
@@ -41,7 +41,7 @@ public class TestProtocolReflectMeta ext
     ReflectRequestor requestor = new ReflectRequestor(Simple.class, client);
     requestor.addRPCPlugin(new RPCMetaTestPlugin("key1"));
     requestor.addRPCPlugin(new RPCMetaTestPlugin("key2"));
-    proxy = (Simple)ReflectRequestor.getClient(Simple.class, (ReflectRequestor)requestor);
+    proxy = ReflectRequestor.getClient(Simple.class, (ReflectRequestor)requestor);
   }
 
 }

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecific.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecific.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecific.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecific.java Tue Oct 26
20:45:46 2010
@@ -82,7 +82,7 @@ public class TestProtocolSpecific {
                               new InetSocketAddress(0));
     server.start();
     client = new SocketTransceiver(new InetSocketAddress(server.getPort()));
-    proxy = (Simple)SpecificRequestor.getClient(Simple.class, client);
+    proxy = SpecificRequestor.getClient(Simple.class, client);
   }
 
   @Test

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/TestProtocolSpecificMeta.java Tue Oct
26 20:45:46 2010
@@ -42,6 +42,6 @@ public class TestProtocolSpecificMeta ex
     SpecificRequestor req = new SpecificRequestor(Simple.class, client);
     req.addRPCPlugin(new RPCMetaTestPlugin("key1"));
     req.addRPCPlugin(new RPCMetaTestPlugin("key2"));
-    proxy = (Simple)SpecificRequestor.getClient(Simple.class, (SpecificRequestor)req);
+    proxy = SpecificRequestor.getClient(Simple.class, (SpecificRequestor)req);
   }
 }

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/ipc/TestNettyServer.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/ipc/TestNettyServer.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/ipc/TestNettyServer.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/ipc/TestNettyServer.java Tue Oct 26
20:45:46 2010
@@ -54,7 +54,7 @@ public class TestNettyServer {
     // client
     Transceiver transceiver = new NettyTransceiver(new InetSocketAddress(
         serverPort));
-    Mail proxy = (Mail) SpecificRequestor.getClient(Mail.class, transceiver);
+    Mail proxy = SpecificRequestor.getClient(Mail.class, transceiver);
 
     Message msg = new Message();
     msg.to = new Utf8("wife");

Modified: avro/trunk/lang/java/src/test/java/org/apache/avro/mapred/tether/TetherTask.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/src/test/java/org/apache/avro/mapred/tether/TetherTask.java?rev=1027741&r1=1027740&r2=1027741&view=diff
==============================================================================
--- avro/trunk/lang/java/src/test/java/org/apache/avro/mapred/tether/TetherTask.java (original)
+++ avro/trunk/lang/java/src/test/java/org/apache/avro/mapred/tether/TetherTask.java Tue Oct
26 20:45:46 2010
@@ -100,8 +100,7 @@ public abstract class TetherTask<IN,MID,
     int clientPort = Integer.parseInt(clientPortString);
     this.clientTransceiver =
       new SocketTransceiver(new InetSocketAddress(clientPort));
-    this.outputClient = (OutputProtocol)
-      SpecificRequestor.getClient(OutputProtocol.class, clientTransceiver);
+    this.outputClient = SpecificRequestor.getClient(OutputProtocol.class, clientTransceiver);
 
     // send inputPort to parent
     outputClient.configure(inputPort);



Mime
View raw message