code: @SuppressWarnings("unchecked")
    public static <T extends VersionedProtocol> ProtocolProxy<T> getProtocolProxy(
        Class<T> protocol,
  		                          long clientVersion,
                                  InetSocketAddress addr,
                                  UserGroupInformation ticket,
                                  Configuration conf,
                                  SocketFactory factory,
                                  int rpcTimeout) throws IOException {
      T proxy = (T) Proxy.newProxyInstance(
              protocol.getClassLoader(), new Class[] { protocol },
              new Invoker(addr, ticket, conf, factory, rpcTimeout, protocol));
      String protocolName = protocol.getName();
      
      try {
        ProtocolSignature serverInfo = proxy
        .getProtocolSignature(protocolName, clientVersion,
            ProtocolSignature.getFingerprint(protocol.getMethods()));
        return new ProtocolProxy<T>(protocol, proxy, serverInfo.getMethods());
      } catch (RemoteException re) {
        IOException ioe = re.unwrapRemoteException(IOException.class);
        if (ioe.getMessage().startsWith(IOException.class.getName() + ": "
            + NoSuchMethodException.class.getName())) {
          // Method getProtocolSignature not supported      
          long serverVersion = proxy.getProtocolVersion(protocol.getName(), 
              clientVersion);
          if (serverVersion == clientVersion) {
            return  new ProtocolProxy<T>(protocol, proxy, null);
          }
          throw new VersionMismatch(protocolName, clientVersion, 
              serverVersion, proxy);
        }
        throw re;
      }
    }
docs: Construct a client-side proxy that implements the named protocol,
  talking to a server at the named address.
  
  @param protocol protocol
  @param clientVersion client's version
  @param addr server address
  @param ticket security ticket
  @param conf configuration
  @param factory socket factory
  @param rpcTimeout max time for each rpc; 0 means no timeout
  @return the proxy
  @throws IOException if any error occurs