You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by je...@apache.org on 2014/04/14 22:51:42 UTC

git commit: PHOENIX-909: Handle scan time range for low time resolution OS

Repository: incubator-phoenix
Updated Branches:
  refs/heads/4.0 67656f558 -> 856f34b69


PHOENIX-909: Handle scan time range for low time resolution OS


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

Branch: refs/heads/4.0
Commit: 856f34b6920589563f2babcd7b568dc5e021e36f
Parents: 67656f5
Author: Jeffrey Zhong <jz...@JZhongs-MacBook-Pro.local>
Authored: Tue Apr 1 17:49:46 2014 -0700
Committer: Jeffrey Zhong <jz...@JZhongs-MacBook-Pro.local>
Committed: Mon Apr 14 11:36:47 2014 -0700

----------------------------------------------------------------------
 .../phoenix/coprocessor/MetaDataRegionObserver.java      |  2 +-
 .../phoenix/coprocessor/SequenceRegionObserver.java      |  4 ----
 .../java/org/apache/phoenix/execute/BasicQueryPlan.java  | 11 ++++++++++-
 .../org/apache/phoenix/query/QueryServicesOptions.java   |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/856f34b6/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 5530989..2ef8b3a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -46,7 +46,7 @@ public class MetaDataRegionObserver extends BaseRegionObserver {
       // among region servers because we relies on server time of RS which is hosting
       // SYSTEM.CATALOG
       long sleepTime = env.getConfiguration().getLong(QueryServices.CLOCK_SKEW_INTERVAL_ATTRIB, 
-          QueryServicesOptions.DEFAULT_PHOENIX_CLOCK_SKEW_INTERVAL_VALUES);
+          QueryServicesOptions.DEFAULT_CLOCK_SKEW_INTERVAL);
       try {
           if(sleepTime > 0) {
               Thread.sleep(sleepTime);

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/856f34b6/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
index 0d0a300..94008fc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/SequenceRegionObserver.java
@@ -121,10 +121,6 @@ public class SequenceRegionObserver extends BaseRegionObserver {
             acquireLock(region, row, locks);
             try {
                 long maxTimestamp = tr.getMax();
-                if (maxTimestamp == HConstants.LATEST_TIMESTAMP) {
-                    maxTimestamp = EnvironmentEdgeManager.currentTimeMillis();
-                    tr = new TimeRange(tr.getMin(), maxTimestamp);
-                }
                 boolean validateOnly = true;
                 Get get = new Get(row);
                 get.setTimeRange(tr.getMin(), tr.getMax());

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/856f34b6/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java
index cc1193c..d0c97bd 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BasicQueryPlan.java
@@ -22,6 +22,7 @@ import java.sql.SQLException;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.phoenix.compile.ExplainPlan;
 import org.apache.phoenix.compile.GroupByCompiler.GroupBy;
@@ -139,7 +140,15 @@ public abstract class BasicQueryPlan implements QueryPlan {
         // TODO: include time range in explain plan?
         PhoenixConnection connection = context.getConnection();
         Long scn = connection.getSCN();
-        ScanUtil.setTimeRange(scan, scn == null ? context.getCurrentTime() : scn);
+        if(scn == null) {
+            scn = context.getCurrentTime();
+            // Add one to server time since max of time range is exclusive
+            // and we need to account of OSs with lower resolution clocks.
+            if(scn < HConstants.LATEST_TIMESTAMP) {
+                scn++;
+            }
+        }
+        ScanUtil.setTimeRange(scan, scn);
         ScanUtil.setTenantId(scan, connection.getTenantId() == null ? null : connection.getTenantId().getBytes());
         ResultIterator iterator = newIterator();
         return dependencies.isEmpty() ? 

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/856f34b6/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index d4acd83..764ffb5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -118,7 +118,7 @@ public class QueryServicesOptions {
     public static final long DEFAULT_MAX_SERVER_METADATA_CACHE_SIZE =  1024L*1024L*20L; // 20 Mb
     public static final long DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE =  1024L*1024L*10L; // 10 Mb
     public static final int DEFAULT_GROUPBY_ESTIMATED_DISTINCT_VALUES = 1000;
-    public static final int DEFAULT_PHOENIX_CLOCK_SKEW_INTERVAL_VALUES = 2000;
+    public static final int DEFAULT_CLOCK_SKEW_INTERVAL = 2000;
     
     private final Configuration config;