You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-dev@hadoop.apache.org by "Doug Cutting (JIRA)" <ji...@apache.org> on 2006/04/20 00:27:35 UTC

[jira] Commented: (HADOOP-151) Misdeclared field in RPC.class

    [ http://issues.apache.org/jira/browse/HADOOP-151?page=comments#action_12375205 ] 

Doug Cutting commented on HADOOP-151:
-------------------------------------

What's the problem with a static CLIENT?  What problems does this cause?  The client has the connection pool, so one potential problem is that, a large request or response will delay other requests or responses to/from the same host.  Is that the issue you're seeing?  If so, can you provide more details about the circumstances where this occurs?


> Misdeclared field in RPC.class
> ------------------------------
>
>          Key: HADOOP-151
>          URL: http://issues.apache.org/jira/browse/HADOOP-151
>      Project: Hadoop
>         Type: Bug

>     Reporter: paul sutter

>
> In RPC.java, the field named CLIENT should be neither static, nor a field of RPC. It should be (a) a private nonstatic field of InvocationHandler(),and (just further down), (b) a local variable in the RPC.call() method below.  The comment above the declaration was a bit of giveaway: 
>    //TODO mb@media-style.com: static client or non-static client?
>   private static Client CLIENT;	
>   private static class Invoker implements InvocationHandler {
>     private InetSocketAddress address;
>     public Invoker(InetSocketAddress address, Configuration conf) {
>       this.address = address;
>       CLIENT = (Client) conf.getObject(Client.class.getName());
>       if(CLIENT == null) {
>           CLIENT = new Client(ObjectWritable.class, conf);
>           conf.setObject(Client.class.getName(), CLIENT);
>       }
>     }
>     public Object invoke(Object proxy, Method method, Object[] args)
>       throws Throwable {
>       ObjectWritable value = (ObjectWritable)
>         CLIENT.call(new Invocation(method, args), address);
>       return value.get();
>     }
>   }
>   /** Construct a client-side proxy object that implements the named protocol,
>    * talking to a server at the named address. */
>   public static Object getProxy(Class protocol, InetSocketAddress addr, Configuration conf) {
>     return Proxy.newProxyInstance(protocol.getClassLoader(),
>                                   new Class[] { protocol },
>                                   new Invoker(addr, conf));
>   }
>   /** Expert: Make multiple, parallel calls to a set of servers. */
>   public static Object[] call(Method method, Object[][] params,
>                               InetSocketAddress[] addrs, Configuration conf)
>     throws IOException {
>     Invocation[] invocations = new Invocation[params.length];
>     for (int i = 0; i < params.length; i++)
>       invocations[i] = new Invocation(method, params[i]);
>     CLIENT = (Client) conf.getObject(Client.class.getName());
>     if(CLIENT == null) {
>         CLIENT = new Client(ObjectWritable.class, conf);
>         conf.setObject(Client.class.getName(), CLIENT);
>     }
>     Writable[] wrappedValues = CLIENT.call(invocations, addrs);
>     
>     if (method.getReturnType() == Void.TYPE) {
>       return null;
>     }
>     Object[] values =
>       (Object[])Array.newInstance(method.getReturnType(),wrappedValues.length);
>     for (int i = 0; i < values.length; i++)
>       if (wrappedValues[i] != null)
>         values[i] = ((ObjectWritable)wrappedValues[i]).get();
>     
>     return values;
>   }. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira