Esempio n. 1
0
            internal virtual RPC.Server.VerProtocolImpl GetHighestSupportedProtocol(RPC.RpcKind
                                                                                    rpcKind, string protocolName)
            {
                long highestVersion = 0L;

                RPC.Server.ProtoClassProtoImpl highest = null;
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("Size of protoMap for " + rpcKind + " =" + GetProtocolImplMap(rpcKind).
                              Count);
                }
                foreach (KeyValuePair <RPC.Server.ProtoNameVer, RPC.Server.ProtoClassProtoImpl> pv
                         in GetProtocolImplMap(rpcKind))
                {
                    if (pv.Key.protocol.Equals(protocolName))
                    {
                        if ((highest == null) || (pv.Key.version > highestVersion))
                        {
                            highest        = pv.Value;
                            highestVersion = pv.Key.version;
                        }
                    }
                }
                if (highest == null)
                {
                    return(null);
                }
                return(new RPC.Server.VerProtocolImpl(highestVersion, highest));
            }
Esempio n. 2
0
 /// <exception cref="Org.Apache.Hadoop.Ipc.RpcServerException"/>
 private static RPC.Server.ProtoClassProtoImpl GetProtocolImpl(RPC.Server server,
                                                               string protoName, long clientVersion)
 {
     RPC.Server.ProtoNameVer pv = new RPC.Server.ProtoNameVer(protoName, clientVersion
                                                              );
     RPC.Server.ProtoClassProtoImpl impl = server.GetProtocolImplMap(RPC.RpcKind.RpcProtocolBuffer
                                                                     )[pv];
     if (impl == null)
     {
         // no match for Protocol AND Version
         RPC.Server.VerProtocolImpl highest = server.GetHighestSupportedProtocol(RPC.RpcKind
                                                                                 .RpcProtocolBuffer, protoName);
         if (highest == null)
         {
             throw new RpcNoSuchProtocolException("Unknown protocol: " + protoName);
         }
         // protocol supported but not the version that client wants
         throw new RPC.VersionMismatch(protoName, clientVersion, highest.version);
     }
     return(impl);
 }
Esempio n. 3
0
                /// <exception cref="System.Exception"/>
                public virtual IWritable Call(RPC.Server server, string protocol, IWritable writableRequest
                                              , long receiveTime)
                {
                    ProtobufRpcEngine.RpcRequestWrapper request = (ProtobufRpcEngine.RpcRequestWrapper
                                                                   )writableRequest;
                    ProtobufRpcEngineProtos.RequestHeaderProto rpcRequest = request.requestHeader;
                    string methodName    = rpcRequest.GetMethodName();
                    string protoName     = rpcRequest.GetDeclaringClassProtocolName();
                    long   clientVersion = rpcRequest.GetClientProtocolVersion();

                    if (server.verbose)
                    {
                        Log.Info("Call: protocol=" + protocol + ", method=" + methodName);
                    }
                    RPC.Server.ProtoClassProtoImpl protocolImpl = GetProtocolImpl(server, protoName,
                                                                                  clientVersion);
                    BlockingService service = (BlockingService)protocolImpl.protocolImpl;

                    Descriptors.MethodDescriptor methodDescriptor = service.GetDescriptorForType().FindMethodByName
                                                                        (methodName);
                    if (methodDescriptor == null)
                    {
                        string msg = "Unknown method " + methodName + " called on " + protocol + " protocol.";
                        Log.Warn(msg);
                        throw new RpcNoSuchMethodException(msg);
                    }
                    Message prototype = service.GetRequestPrototype(methodDescriptor);
                    Message param     = prototype.NewBuilderForType().MergeFrom(request.theRequestRead).Build
                                            ();
                    Message   result;
                    long      startTime = Time.Now();
                    int       qTime     = (int)(startTime - receiveTime);
                    Exception exception = null;

                    try
                    {
                        server.rpcDetailedMetrics.Init(protocolImpl.protocolClass);
                        result = service.CallBlockingMethod(methodDescriptor, null, param);
                    }
                    catch (ServiceException e)
                    {
                        exception = (Exception)e.InnerException;
                        throw (Exception)e.InnerException;
                    }
                    catch (Exception e)
                    {
                        exception = e;
                        throw;
                    }
                    finally
                    {
                        int processingTime = (int)(Time.Now() - startTime);
                        if (Log.IsDebugEnabled())
                        {
                            string msg = "Served: " + methodName + " queueTime= " + qTime + " procesingTime= "
                                         + processingTime;
                            if (exception != null)
                            {
                                msg += " exception= " + exception.GetType().Name;
                            }
                            Log.Debug(msg);
                        }
                        string detailedMetricsName = (exception == null) ? methodName : exception.GetType
                                                         ().Name;
                        server.rpcMetrics.AddRpcQueueTime(qTime);
                        server.rpcMetrics.AddRpcProcessingTime(processingTime);
                        server.rpcDetailedMetrics.AddProcessingTime(detailedMetricsName, processingTime);
                    }
                    return(new ProtobufRpcEngine.RpcResponseWrapper(result));
                }
Esempio n. 4
0
 internal VerProtocolImpl(long ver, RPC.Server.ProtoClassProtoImpl protocolTarget)
 {
     this.version        = ver;
     this.protocolTarget = protocolTarget;
 }