Beispiel #1
0
  /** Expert: Make multiple, parallel calls to a set of servers. */
  public static Object[] call(
      Method method,
      Object[][] params,
      InetSocketAddress[] addrs,
      UserGroupInformation ticket,
      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 = CLIENTS.getClient(conf);
    try {
      Writable[] wrappedValues =
          client.call(invocations, addrs, method.getDeclaringClass(), ticket);

      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;
    } finally {
      CLIENTS.stopClient(client);
    }
  }
Beispiel #2
0
 /* close the IPC client that's responsible for this invoker's RPCs */
 private synchronized void close() {
   if (!isClosed) {
     isClosed = true;
     CLIENTS.stopClient(client);
   }
 }