phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pbo...@apache.org
Subject [2/5] phoenix git commit: Keep Ring buffer size small by default and avoid starting disruptor for server connection
Date Thu, 19 Apr 2018 21:02:52 GMT
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/803abe74
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/803abe74
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/803abe74

Branch: refs/heads/4.x-cdh5.13
Commit: 803abe749601cbfb222cfc45c04c2e214d70de3c
Parents: 3939c8d
Author: Ankit Singhal <ankitsinghal59@gmail.com>
Authored: Tue Apr 17 10:39:29 2018 +0100
Committer: Pedro Boado <pboado@apache.org>
Committed: Thu Apr 19 21:57:59 2018 +0100

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


http://git-wip-us.apache.org/repos/asf/phoenix/blob/803abe74/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/803abe74/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 02fcf24..aafcf12 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
@@ -195,7 +195,6 @@ import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
 import org.apache.phoenix.schema.EmptySequenceCacheException;
 import org.apache.phoenix.schema.FunctionNotFoundException;
 import org.apache.phoenix.schema.MetaDataClient;
-import org.apache.phoenix.schema.MetaDataSplitPolicy;
 import org.apache.phoenix.schema.NewerSchemaAlreadyExistsException;
 import org.apache.phoenix.schema.NewerTableAlreadyExistsException;
 import org.apache.phoenix.schema.PColumn;
@@ -243,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;
@@ -406,11 +406,14 @@ 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/803abe74/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 d7154a1..9d2e53c 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";
@@ -358,6 +359,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.
@@ -365,13 +375,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);


Mime
View raw message