/** * Get the hash code of an array of methods * Methods are sorted before hashcode is calculated. * So the returned value is irrelevant of the method order in the array. * * @param methods an array of methods * @return the hash code */ static int getFingerprint(Method[] methods) { return getFingerprint(getFingerprints(methods)); }
/** * Convert an array of Method into an array of hash codes * * @param methods * @return array of hash codes */ private static int[] getFingerprints(Method[] methods) { if (methods == null) { return null; } int[] hashCodes = new int[methods.length]; for (int i = 0; i<methods.length; i++) { hashCodes[i] = getFingerprint(methods[i]); } return hashCodes; }
/** * 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; } }
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()); }
/** * Get the hash code of an array of methods * Methods are sorted before hashcode is calculated. * So the returned value is irrelevant of the method order in the array. * * @param methods an array of methods * @return the hash code */ static int getFingerprint(Method[] methods) { return getFingerprint(getFingerprints(methods)); }
Integer.valueOf(ProtocolSignature.getFingerprint(method)));
/** * Get the hash code of an array of methods * Methods are sorted before hashcode is calculated. * So the returned value is irrelevant of the method order in the array. * * @param methods an array of methods * @return the hash code */ static int getFingerprint(Method[] methods) { return getFingerprint(getFingerprints(methods)); }
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; }
/** * Get the hash code of an array of methods * Methods are sorted before hashcode is calculated. * So the returned value is irrelevant of the method order in the array. * * @param methods an array of methods * @return the hash code */ static int getFingerprint(Method[] methods) { return getFingerprint(getFingerprints(methods)); }
return false; int methodHash = ProtocolSignature.getFingerprint(desiredMethod); return methodExists(methodHash, version, versionMap);
/** * Get the hash code of an array of methods * Methods are sorted before hashcode is calculated. * So the returned value is irrelevant of the method order in the array. * * @param methods an array of methods * @return the hash code */ static int getFingerprint(Method[] methods) { return getFingerprint(getFingerprints(methods)); }
/** * Convert an array of Method into an array of hash codes * * @param methods * @return array of hash codes */ private static int[] getFingerprints(Method[] methods) { if (methods == null) { return null; } int[] hashCodes = new int[methods.length]; for (int i = 0; i<methods.length; i++) { hashCodes[i] = getFingerprint(methods[i]); } return hashCodes; }
/** * Get the hash code of an array of methods * Methods are sorted before hashcode is calculated. * So the returned value is irrelevant of the method order in the array. * * @param methods an array of methods * @return the hash code */ static int getFingerprint(Method[] methods) { return getFingerprint(getFingerprints(methods)); }
/** * Convert an array of Method into an array of hash codes * * @param methods * @return array of hash codes */ private static int[] getFingerprints(Method[] methods) { if (methods == null) { return null; } int[] hashCodes = new int[methods.length]; for (int i = 0; i<methods.length; i++) { hashCodes[i] = getFingerprint(methods[i]); } return hashCodes; }
/** * Convert an array of Method into an array of hash codes * * @param methods * @return array of hash codes */ private static int[] getFingerprints(Method[] methods) { if (methods == null) { return null; } int[] hashCodes = new int[methods.length]; for (int i = 0; i<methods.length; i++) { hashCodes[i] = getFingerprint(methods[i]); } return hashCodes; }
/** * Convert an array of Method into an array of hash codes * * @param methods * @return array of hash codes */ private static int[] getFingerprints(Method[] methods) { if (methods == null) { return null; } int[] hashCodes = new int[methods.length]; for (int i = 0; i<methods.length; i++) { hashCodes[i] = getFingerprint(methods[i]); } return hashCodes; }
/** * Convert an array of Method into an array of hash codes * * @param methods * @return array of hash codes */ private static int[] getFingerprints(Method[] methods) { if (methods == null) { return null; } int[] hashCodes = new int[methods.length]; for (int i = 0; i<methods.length; i++) { hashCodes[i] = getFingerprint(methods[i]); } return hashCodes; }
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()); }
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()); }
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()); }