예제 #1
0
    // Register  protocol and its impl for rpc calls
    void registerProtocolAndImpl(RpcKind rpcKind, Class<?> protocolClass, Object protocolImpl) {
      String protocolName = RPC.getProtocolName(protocolClass);
      long version;

      try {
        version = RPC.getProtocolVersion(protocolClass);
      } catch (Exception ex) {
        LOG.warn("Protocol " + protocolClass + " NOT registered as cannot get protocol version ");
        return;
      }

      getProtocolImplMap(rpcKind)
          .put(
              new ProtoNameVer(protocolName, version),
              new ProtoClassProtoImpl(protocolClass, protocolImpl));
      LOG.debug(
          "RpcKind = "
              + rpcKind
              + " Protocol Name = "
              + protocolName
              + " version="
              + version
              + " ProtocolImpl="
              + protocolImpl.getClass().getName()
              + " protocolClass="
              + protocolClass.getName());
    }
예제 #2
0
 public Invocation(Method method, Object[] parameters) {
   this.methodName = method.getName();
   this.parameterClasses = method.getParameterTypes();
   this.parameters = parameters;
   rpcVersion = writableRpcVersion;
   if (method.getDeclaringClass().equals(VersionedProtocol.class)) {
     // VersionedProtocol is exempted from version check.
     clientVersion = 0;
     clientMethodsHash = 0;
   } else {
     this.clientVersion = RPC.getProtocolVersion(method.getDeclaringClass());
     this.clientMethodsHash =
         ProtocolSignature.getFingerprint(method.getDeclaringClass().getMethods());
   }
   this.declaringClassProtocolName = RPC.getProtocolName(method.getDeclaringClass());
 }