You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by an...@apache.org on 2018/04/17 09:35:38 UTC
phoenix git commit: Keep Ring buffer size small by default and avoid
starting disruptor for server connection
Repository: phoenix
Updated Branches:
refs/heads/5.x-HBase-2.0 2a8f0c0fe -> 0e5c6e524
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/0e5c6e52
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0e5c6e52
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0e5c6e52
Branch: refs/heads/5.x-HBase-2.0
Commit: 0e5c6e52436360892e22e5a3981c236dfe7d6001
Parents: 2a8f0c0
Author: Ankit Singhal <an...@gmail.com>
Authored: Tue Apr 17 15:05:26 2018 +0530
Committer: Ankit Singhal <an...@gmail.com>
Committed: Tue Apr 17 15:05:26 2018 +0530
----------------------------------------------------------------------
.../apache/phoenix/log/QueryLoggerDisruptor.java | 2 +-
.../phoenix/query/ConnectionQueryServicesImpl.java | 16 +++++++++-------
.../java/org/apache/phoenix/util/QueryUtil.java | 14 ++++++++++++--
3 files changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/0e5c6e52/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/0e5c6e52/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 ffce2ea..44dce3f 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
@@ -102,7 +102,6 @@ import javax.annotation.concurrent.GuardedBy;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
-import org.apache.hadoop.hbase.KeepDeletedCells;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.TableExistsException;
@@ -201,7 +200,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;
@@ -249,6 +247,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;
@@ -412,11 +411,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/0e5c6e52/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);