Repository: phoenix Updated Branches: refs/heads/master 0675fe545 -> ea06a10a3
PHOENIX-4685 Properly handle connection caching for Phoenix inside RegionServers-addendum(Rajeshbabu) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/ea06a10a Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ea06a10a Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ea06a10a Branch: refs/heads/master Commit: ea06a10a35af8eb0773b077cbbe704275bb7869c Parents: 0675fe5 Author: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Authored: Tue May 8 20:32:04 2018 +0530 Committer: Rajeshbabu Chintaguntla <rajeshb...@apache.org> Committed: Tue May 8 20:32:04 2018 +0530 ---------------------------------------------------------------------- .../java/org/apache/phoenix/util/ServerUtil.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/ea06a10a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java index 1043fd2..d80b6fc 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java @@ -27,7 +27,6 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ExecutorService; -import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -345,16 +344,17 @@ public class ServerUtil { new ConcurrentHashMap<ConnectionType, ClusterConnection>(); public static ClusterConnection getConnection(final ConnectionType connectionType, final Configuration conf, final HRegionServer server) throws IOException { - return connections.computeIfAbsent(connectionType, new Function<ConnectionType, ClusterConnection>() { - @Override - public ClusterConnection apply(ConnectionType t) { - try { - return new CoprocessorHConnection(getTypeSpecificConfiguration(connectionType, conf), server); - } catch (IOException e) { - throw new RuntimeException(e); + ClusterConnection connection = null; + if((connection = connections.get(connectionType)) == null) { + synchronized (CoprocessorHConnectionTableFactory.class) { + if(connections.get(connectionType) == null) { + connection = new CoprocessorHConnection(conf, server); + connections.put(connectionType, connection); + return connection; } } - }); + } + return connection; } public static Configuration getTypeSpecificConfiguration(ConnectionType connectionType, Configuration conf) {