예제 #1
0
파일: RPC.java 프로젝트: baeeq/hadoop-20
  /** 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);
    }
  }
예제 #2
0
 public Invoker(
     Class<?> protocol,
     InetSocketAddress address,
     UserGroupInformation ticket,
     Configuration conf,
     SocketFactory factory,
     int rpcTimeout)
     throws IOException {
   this.remoteId =
       Client.ConnectionId.getConnectionId(address, protocol, ticket, rpcTimeout, conf);
   this.client = CLIENTS.getClient(conf, factory);
 }
예제 #3
0
파일: RPC.java 프로젝트: baeeq/hadoop-20
 public Invoker(
     InetSocketAddress address,
     UserGroupInformation ticket,
     Configuration conf,
     SocketFactory factory,
     int rpcTimeout,
     Class<?> protocol) {
   this.address = address;
   this.ticket = ticket;
   this.client = CLIENTS.getClient(conf, factory);
   this.rpcTimeout = rpcTimeout;
   this.protocol = protocol;
 }
예제 #4
0
파일: RPC.java 프로젝트: baeeq/hadoop-20
 static Client getClient(Configuration conf, SocketFactory socketFactory) {
   return CLIENTS.getClient(conf, socketFactory);
 }
예제 #5
0
파일: RPC.java 프로젝트: baeeq/hadoop-20
 /* close the IPC client that's responsible for this invoker's RPCs */
 private synchronized void close() {
   if (!isClosed) {
     isClosed = true;
     CLIENTS.stopClient(client);
   }
 }
예제 #6
0
 // for unit testing only
 @InterfaceAudience.Private
 @InterfaceStability.Unstable
 static Client getClient(Configuration conf) {
   return CLIENTS.getClient(conf);
 }