Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4D827200D2D for ; Fri, 27 Oct 2017 20:26:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4C2D5160BF2; Fri, 27 Oct 2017 18:26:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 928E91609DD for ; Fri, 27 Oct 2017 20:26:54 +0200 (CEST) Received: (qmail 47748 invoked by uid 500); 27 Oct 2017 18:26:53 -0000 Mailing-List: contact commits-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list commits@geode.apache.org Received: (qmail 47739 invoked by uid 99); 27 Oct 2017 18:26:53 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Oct 2017 18:26:53 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B958E81C95; Fri, 27 Oct 2017 18:26:51 +0000 (UTC) Date: Fri, 27 Oct 2017 18:26:51 +0000 To: "commits@geode.apache.org" Subject: [geode] branch feature/GEODE-3781 updated: Made prepared statment cache thread safe. Now each thread has its own prepared statement cache. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <150912881116.23477.10178227489430606374@gitbox.apache.org> From: agingade@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: geode X-Git-Refname: refs/heads/feature/GEODE-3781 X-Git-Reftype: branch X-Git-Oldrev: fdbfb14bf96515d3d30cb8fc5725e57fff7d0601 X-Git-Newrev: e23aa67ef93e8c83472c8ff2fa0e1944276b5c58 X-Git-Rev: e23aa67ef93e8c83472c8ff2fa0e1944276b5c58 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated archived-at: Fri, 27 Oct 2017 18:26:55 -0000 This is an automated email from the ASF dual-hosted git repository. agingade pushed a commit to branch feature/GEODE-3781 in repository https://gitbox.apache.org/repos/asf/geode.git The following commit(s) were added to refs/heads/feature/GEODE-3781 by this push: new e23aa67 Made prepared statment cache thread safe. Now each thread has its own prepared statement cache. e23aa67 is described below commit e23aa67ef93e8c83472c8ff2fa0e1944276b5c58 Author: Anil AuthorDate: Fri Oct 27 11:24:48 2017 -0700 Made prepared statment cache thread safe. Now each thread has its own prepared statement cache. --- .../org/apache/geode/connectors/jdbc/JDBCManager.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java index 7c7ecea..afc59b2 100644 --- a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java +++ b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/JDBCManager.java @@ -23,7 +23,9 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -40,6 +42,18 @@ public class JDBCManager { private final ConcurrentMap tableToPrimaryKeyMap = new ConcurrentHashMap<>(); + private final ThreadLocal> preparedStatementCache = + new ThreadLocal<>(); + + private Map getPreparedStatementCache() { + Map result = preparedStatementCache.get(); + if (result == null) { + result = new HashMap<>(); + preparedStatementCache.set(result); + } + return result; + } + JDBCManager(JDBCConfiguration config) { this.config = config; } @@ -186,9 +200,6 @@ public class JDBCManager { return result; } - private final ConcurrentMap preparedStatementCache = - new ConcurrentHashMap<>(); - private static class StatementKey { private final int pdxTypeId; private final Operation operation; @@ -232,7 +243,7 @@ public class JDBCManager { System.out.println("getPreparedStatement : " + pdxTypeId + "operation: " + operation + " columns: " + columnList); StatementKey key = new StatementKey(pdxTypeId, operation, tableName); - return preparedStatementCache.computeIfAbsent(key, k -> { + return getPreparedStatementCache().computeIfAbsent(key, k -> { String query = getQueryString(tableName, columnList, operation); System.out.println("query=" + query); Connection con = getConnection(); -- To stop receiving notification emails like this one, please contact ['"commits@geode.apache.org" '].