commit e2e9bc9980015df82982d46e8655174f97bdee4b Author: Todd Lipcon Date: Mon Apr 30 00:29:18 2012 -0700 HBASE-5912. Cache for method fingerprint diff --git src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java index bb6ab3b..810851a 100644 --- src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java +++ src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java @@ -55,6 +55,8 @@ public class Invocation extends VersionedWritable implements Configurable { // such as protobuf interfaces. private static final Map, Long> PROTOCOL_VERSION = new HashMap, Long>(); + private static final Map, Integer> + METHOD_HASH_CACHE = new HashMap, Integer>(); static { PROTOCOL_VERSION.put(ClientService.BlockingInterface.class, @@ -100,8 +102,16 @@ public class Invocation extends VersionedWritable implements Configurable { } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } - this.clientMethodsHash = ProtocolSignature.getFingerprint( - declaringClass.getMethods()); + Integer hash; + synchronized (METHOD_HASH_CACHE) { + hash = METHOD_HASH_CACHE.get(declaringClass); + if (hash == null) { + hash = ProtocolSignature.getFingerprint( + declaringClass.getMethods()); + METHOD_HASH_CACHE.put(declaringClass, hash); + } + } + this.clientMethodsHash = hash; } } @@ -206,4 +216,4 @@ public class Invocation extends VersionedWritable implements Configurable { public byte getVersion() { return RPC_VERSION; } -} \ No newline at end of file +}