@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(ZKFCProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(ZKFCProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(ZKFCProtocolPB.class), HAServiceProtocolPB.class); }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(TraceAdminProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(TraceAdminProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(TraceAdminProtocolPB.class), TraceAdminProtocolPB.class); } }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(HAServiceProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(HAServiceProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(HAServiceProtocolPB.class), HAServiceProtocolPB.class); } }
private long[] getProtocolVersionForRpcKind(RPC.RpcKind rpcKind, String protocol) throws ClassNotFoundException { Class<?> protocolClass = Class.forName(protocol); String protocolName = RPC.getProtocolName(protocolClass); VerProtocolImpl[] vers = server.getSupportedProtocolVersions(rpcKind, protocolName); if (vers == null) { return null; } long [] versions = new long[vers.length]; for (int i=0; i<versions.length; i++) { versions[i] = vers[i].version; } return versions; } }
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()); }
/** * This constructor takes a connectionId, instead of creating a new one. */ private Invoker(Class<?> protocol, Client.ConnectionId connId, Configuration conf, SocketFactory factory) { this.remoteId = connId; this.client = CLIENTS.getClient(conf, factory, RpcWritable.Buffer.class); this.protocolName = RPC.getProtocolName(protocol); this.clientProtocolVersion = RPC .getProtocolVersion(protocol); }
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)); if (LOG.isDebugEnabled()) { LOG.debug("RpcKind = " + rpcKind + " Protocol Name = " + protocolName + " version=" + version + " ProtocolImpl=" + protocolImpl.getClass().getName() + " protocolClass=" + protocolClass.getName()); } }
private void fetchServerMethods(Method method) throws IOException { long clientVersion; clientVersion = RPC.getProtocolVersion(method.getDeclaringClass()); int clientMethodsHash = ProtocolSignature.getFingerprint(method .getDeclaringClass().getMethods()); ProtocolSignature serverInfo = ((VersionedProtocol) proxy) .getProtocolSignature(RPC.getProtocolName(protocol), clientVersion, clientMethodsHash); long serverVersion = serverInfo.getVersion(); if (serverVersion != clientVersion) { throw new RPC.VersionMismatch(protocol.getName(), clientVersion, serverVersion); } int[] serverMethodsCodes = serverInfo.getMethods(); if (serverMethodsCodes != null) { serverMethods = new HashSet<Integer>(serverMethodsCodes.length); for (int m : serverMethodsCodes) { this.serverMethods.add(Integer.valueOf(m)); } } serverMethodsFetched = true; }
/** * Return a protocol's signature and finger print from cache * * @param protocol a protocol class * @param serverVersion protocol version * @return its signature and finger print */ private static ProtocolSigFingerprint getSigFingerprint( Class <?> protocol, long serverVersion) { String protocolName = RPC.getProtocolName(protocol); synchronized (PROTOCOL_FINGERPRINT_CACHE) { ProtocolSigFingerprint sig = PROTOCOL_FINGERPRINT_CACHE.get(protocolName); if (sig == null) { int[] serverMethodHashcodes = getFingerprints(protocol.getMethods()); sig = new ProtocolSigFingerprint( new ProtocolSignature(serverVersion, serverMethodHashcodes), getFingerprint(serverMethodHashcodes)); PROTOCOL_FINGERPRINT_CACHE.put(protocolName, sig); } return sig; } }
private void writeConnectionContext(ConnectionId remoteId, AuthMethod authMethod) throws IOException { // Write out the ConnectionHeader IpcConnectionContextProto message = ProtoUtil.makeIpcConnectionContext( RPC.getProtocolName(remoteId.getProtocol()), remoteId.getTicket(), authMethod); RpcRequestHeaderProto connectionContextHeader = ProtoUtil .makeRpcRequestHeader(RpcKind.RPC_PROTOCOL_BUFFER, OperationProto.RPC_FINAL_PACKET, CONNECTION_CONTEXT_CALL_ID, RpcConstants.INVALID_RETRY_COUNT, clientId); // do not flush. the context and first ipc call request must be sent // together to avoid possibility of broken pipes upon authz failure. // see writeConnectionHeader final ResponseBuffer buf = new ResponseBuffer(); connectionContextHeader.writeDelimitedTo(buf); message.writeDelimitedTo(buf); synchronized (ipcStreams.out) { ipcStreams.sendRequest(buf.toByteArray()); } }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(ZKFCProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(ZKFCProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(ZKFCProtocolPB.class), HAServiceProtocolPB.class); }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(ZKFCProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(ZKFCProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(ZKFCProtocolPB.class), HAServiceProtocolPB.class); }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(TraceAdminProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(TraceAdminProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(TraceAdminProtocolPB.class), TraceAdminProtocolPB.class); } }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(TraceAdminProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(TraceAdminProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(TraceAdminProtocolPB.class), TraceAdminProtocolPB.class); } }
@Override public ProtocolSignature getProtocolSignature(String protocol, long clientVersion, int clientMethodsHash) throws IOException { if (!protocol.equals(RPC.getProtocolName(ZKFCProtocolPB.class))) { throw new IOException("Serverside implements " + RPC.getProtocolName(ZKFCProtocolPB.class) + ". The following requested protocol is unknown: " + protocol); } return ProtocolSignature.getProtocolSignature(clientMethodsHash, RPC.getProtocolVersion(ZKFCProtocolPB.class), HAServiceProtocolPB.class); }
/** * This constructor takes a connectionId, instead of creating a new one. */ private Invoker(Class<?> protocol, Client.ConnectionId connId, Configuration conf, SocketFactory factory) { this.remoteId = connId; this.client = CLIENTS.getClient(conf, factory, RpcResponseWrapper.class); this.protocolName = RPC.getProtocolName(protocol); this.clientProtocolVersion = RPC .getProtocolVersion(protocol); }
/** * This constructor takes a connectionId, instead of creating a new one. */ private Invoker(Class<?> protocol, Client.ConnectionId connId, Configuration conf, SocketFactory factory) { this.remoteId = connId; this.client = CLIENTS.getClient(conf, factory, RpcResponseWrapper.class); this.protocolName = RPC.getProtocolName(protocol); this.clientProtocolVersion = RPC .getProtocolVersion(protocol); }
/** * This constructor takes a connectionId, instead of creating a new one. */ private Invoker(Class<?> protocol, Client.ConnectionId connId, Configuration conf, SocketFactory factory) { this.remoteId = connId; this.client = CLIENTS.getClient(conf, factory, RpcResponseWrapper.class); this.protocolName = RPC.getProtocolName(protocol); this.clientProtocolVersion = RPC .getProtocolVersion(protocol); }
/** * This constructor takes a connectionId, instead of creating a new one. */ private Invoker(Class<?> protocol, Client.ConnectionId connId, Configuration conf, SocketFactory factory) { this.remoteId = connId; this.client = CLIENTS.getClient(conf, factory, RpcResponseWrapper.class); this.protocolName = RPC.getProtocolName(protocol); this.clientProtocolVersion = RPC .getProtocolVersion(protocol); }
/** * This constructor takes a connectionId, instead of creating a new one. */ private Invoker(Class<?> protocol, Client.ConnectionId connId, Configuration conf, SocketFactory factory) { this.remoteId = connId; this.client = CLIENTS.getClient(conf, factory, RpcWritable.Buffer.class); this.protocolName = RPC.getProtocolName(protocol); this.clientProtocolVersion = RPC .getProtocolVersion(protocol); }