Repository: phoenix
Updated Branches:
  refs/heads/master 52ec0a7d7 -> 763a3566e


PHOENIX-1261 Addendum to set the async attribute on the scan


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

Branch: refs/heads/master
Commit: 763a3566ed7ade82b7ffbd56cf90ff264cdbe20a
Parents: 52ec0a7
Author: Samarth <samarth.j...@salesforce.com>
Authored: Fri Jan 15 16:21:26 2016 -0800
Committer: Samarth <samarth.j...@salesforce.com>
Committed: Fri Jan 15 16:21:26 2016 -0800

----------------------------------------------------------------------
 .../org/apache/phoenix/schema/MetaDataClient.java     | 13 ++++++++++---
 .../schema/stats/StatisticsCollectionRunTracker.java  | 14 ++++++--------
 2 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/763a3566/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index decc944..995be86 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -21,6 +21,8 @@ import static 
com.google.common.collect.Lists.newArrayListWithExpectedSize;
 import static com.google.common.collect.Sets.newLinkedHashSet;
 import static com.google.common.collect.Sets.newLinkedHashSetWithExpectedSize;
 import static org.apache.hadoop.hbase.HColumnDescriptor.TTL;
+import static 
org.apache.phoenix.coprocessor.BaseScannerRegionObserver.ANALYZE_TABLE;
+import static 
org.apache.phoenix.coprocessor.BaseScannerRegionObserver.RUN_UPDATE_STATS_ASYNC;
 import static 
org.apache.phoenix.exception.SQLExceptionCode.INSUFFICIENT_MULTI_TENANT_COLUMNS;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARG_POSITION;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ARRAY_SIZE;
@@ -81,9 +83,12 @@ import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE;
 import static 
org.apache.phoenix.query.QueryConstants.BASE_TABLE_BASE_COLUMN_COUNT;
 import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB;
 import static 
org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA;
+import static 
org.apache.phoenix.query.QueryServicesOptions.DEFAULT_RUN_UPDATE_STATS_ASYNC;
 import static org.apache.phoenix.schema.PTable.ViewType.MAPPED;
 import static org.apache.phoenix.schema.PTableType.TABLE;
 import static org.apache.phoenix.schema.PTableType.VIEW;
+import static org.apache.phoenix.schema.types.PDataType.FALSE_BYTES;
+import static org.apache.phoenix.schema.types.PDataType.TRUE_BYTES;
 
 import java.io.IOException;
 import java.sql.Connection;
@@ -108,6 +113,8 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import co.cask.tephra.TxConstants;
+
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
@@ -210,8 +217,6 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.primitives.Ints;
 
-import co.cask.tephra.TxConstants;
-
 public class MetaDataClient {
     private static final Logger logger = 
LoggerFactory.getLogger(MetaDataClient.class);
 
@@ -949,7 +954,9 @@ public class MetaDataClient {
             MutationPlan plan = 
compiler.compile(Collections.singletonList(tableRef), null, null, null, 
clientTimeStamp);
             Scan scan = plan.getContext().getScan();
             scan.setCacheBlocks(false);
-            scan.setAttribute(BaseScannerRegionObserver.ANALYZE_TABLE, 
PDataType.TRUE_BYTES);
+            scan.setAttribute(ANALYZE_TABLE, TRUE_BYTES);
+            boolean runUpdateStatsAsync = 
props.getBoolean(RUN_UPDATE_STATS_ASYNC, DEFAULT_RUN_UPDATE_STATS_ASYNC);
+            scan.setAttribute(RUN_UPDATE_STATS_ASYNC, runUpdateStatsAsync ? 
TRUE_BYTES : FALSE_BYTES);
             if (statsProps != null) {
                 Object gp_width = 
statsProps.get(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB);
                 if (gp_width != null) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/763a3566/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
index 5f6be3f..4ed3325 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsCollectionRunTracker.java
@@ -31,6 +31,8 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.query.QueryServicesOptions;
 
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
 /**
  * Singleton that is used to track state associated with regions undergoing 
stats collection at the
  * region server's JVM level.
@@ -64,14 +66,10 @@ public class StatisticsCollectionRunTracker {
         int poolSize =
                 config.getInt(QueryServices.STATS_SERVER_POOL_SIZE,
                     QueryServicesOptions.DEFAULT_STATS_POOL_SIZE);
-        executor = Executors.newFixedThreadPool(poolSize, new ThreadFactory() {
-            @Override
-            public Thread newThread(Runnable r) {
-                Thread t = Executors.defaultThreadFactory().newThread(r);
-                t.setDaemon(true);
-                return t;
-            }
-        });
+        ThreadFactoryBuilder builder =
+                new ThreadFactoryBuilder().setDaemon(true).setNameFormat(
+                    "phoenix-update-statistics-%s");
+        executor = Executors.newFixedThreadPool(poolSize, builder.build());
     }
 
     /**

Reply via email to