Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.3 d525ba6a0 -> 3c18a2913
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/3c18a291 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3c18a291 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3c18a291 Branch: refs/heads/4.x-HBase-1.3 Commit: 3c18a29137a51ae23bf98c612453db2700110e4f Parents: d525ba6 Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Tue Apr 17 15:09:05 2018 +0530 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Tue Apr 17 15:09:05 2018 +0530 ---------------------------------------------------------------------- .../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/3c18a291/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/3c18a291/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 5985705..f5e83f2 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/3c18a291/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);