Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 07125f25e -> eda63737e


Keep Ring buffer size small by default and avoid starting disruptor for server 
connection


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/eda63737
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/eda63737
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/eda63737

Branch: refs/heads/4.x-HBase-0.98
Commit: eda63737ebb1754c205580c45d3169303dd1143c
Parents: 07125f2
Author: Ankit Singhal <[email protected]>
Authored: Tue Apr 17 15:18:22 2018 +0530
Committer: Ankit Singhal <[email protected]>
Committed: Tue Apr 17 15:18:22 2018 +0530

----------------------------------------------------------------------
 .../apache/phoenix/log/QueryLoggerDisruptor.java    |  2 +-
 .../phoenix/query/ConnectionQueryServicesImpl.java  | 16 ++++++++++------
 .../java/org/apache/phoenix/util/QueryUtil.java     | 14 ++++++++++++--
 3 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/eda63737/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerDisruptor.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerDisruptor.java 
b/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerDisruptor.java
index b548d6c..1f2240e 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerDisruptor.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/log/QueryLoggerDisruptor.java
@@ -43,7 +43,7 @@ public class QueryLoggerDisruptor implements Closeable{
     private volatile Disruptor<RingBufferEvent> disruptor;
     private boolean isClosed = false;
     //number of elements to create within the ring buffer.
-    private static final int RING_BUFFER_SIZE = 256 * 1024;
+    private static final int RING_BUFFER_SIZE = 8 * 1024;
     private static final Log LOG = 
LogFactory.getLog(QueryLoggerDisruptor.class);
     private static final String DEFAULT_WAIT_STRATEGY = 
BlockingWaitStrategy.class.getName();
     

http://git-wip-us.apache.org/repos/asf/phoenix/blob/eda63737/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 7a5b8d7..3d22f5b 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -242,6 +242,7 @@ import org.apache.phoenix.util.PhoenixContextExecutor;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PhoenixStopWatch;
 import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.ServerUtil;
@@ -405,12 +406,15 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
         this.maxConnectionsAllowed = 
config.getInt(QueryServices.CLIENT_CONNECTION_MAX_ALLOWED_CONNECTIONS,
             
QueryServicesOptions.DEFAULT_CLIENT_CONNECTION_MAX_ALLOWED_CONNECTIONS);
         this.shouldThrottleNumConnections = (maxConnectionsAllowed > 0);
-        try {
-            this.queryDisruptor = new QueryLoggerDisruptor(this.config);
-        } catch (SQLException e) {
-            logger.warn("Unable to initiate qeuery logging service !!");
-            e.printStackTrace();
-        }
+        if (!QueryUtil.isServerConnection(props)) {
+             //Start queryDistruptor everytime as log level can be change at 
connection level as well, but we can avoid starting for server connections.
+             try {
+                 this.queryDisruptor = new QueryLoggerDisruptor(this.config);
+             } catch (SQLException e) {
+                 logger.warn("Unable to initiate qeuery logging service !!");
+                 e.printStackTrace();
+             }
+          }
 
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/eda63737/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
index 24760b2..f5f04a6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
@@ -82,6 +82,7 @@ public final class QueryUtil {
      */
     public static final int DATA_TYPE_NAME_POSITION = 6;
 
+    public static final String IS_SERVER_CONNECTION = "IS_SERVER_CONNECTION";
     private static final String SELECT = "SELECT";
     private static final String FROM = "FROM";
     private static final String WHERE = "WHERE";
@@ -359,6 +360,15 @@ public final class QueryUtil {
             SQLException {
         return getConnectionOnServer(new Properties(), conf);
     }
+    
+    public static void setServerConnection(Properties props){
+        UpgradeUtil.doNotUpgradeOnFirstConnection(props);
+        props.setProperty(IS_SERVER_CONNECTION, Boolean.TRUE.toString());
+    }
+    
+    public static boolean isServerConnection(ReadOnlyProps props) {
+        return props.getBoolean(IS_SERVER_CONNECTION, false);
+    }
 
     /**
      * @return {@link PhoenixConnection} with {@value 
UpgradeUtil#DO_NOT_UPGRADE} set so that we don't initiate metadata upgrade.
@@ -366,13 +376,13 @@ public final class QueryUtil {
     public static Connection getConnectionOnServer(Properties props, 
Configuration conf)
             throws ClassNotFoundException,
             SQLException {
-        UpgradeUtil.doNotUpgradeOnFirstConnection(props);
+        setServerConnection(props);
         return getConnection(props, conf);
     }
 
     public static Connection getConnectionOnServerWithCustomUrl(Properties 
props, String principal)
             throws SQLException, ClassNotFoundException {
-        UpgradeUtil.doNotUpgradeOnFirstConnection(props);
+        setServerConnection(props);
         String url = getConnectionUrl(props, null, principal);
         LOG.info("Creating connection with the jdbc url: " + url);
         return DriverManager.getConnection(url, props);

Reply via email to