You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/11/04 16:15:30 UTC

phoenix git commit: PHOENIX-3199 ServerCacheClient sends cache to all regions unnecessarily (chenglei)

Repository: phoenix
Updated Branches:
  refs/heads/master 51918bb81 -> e4e1570b8


PHOENIX-3199 ServerCacheClient sends cache to all regions unnecessarily (chenglei)


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

Branch: refs/heads/master
Commit: e4e1570b83ca0141fc19421a0bd5217ebb37f512
Parents: 51918bb
Author: James Taylor <ja...@apache.org>
Authored: Fri Nov 4 09:15:19 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Fri Nov 4 09:15:19 2016 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/cache/ServerCacheClient.java   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e4e1570b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
index 67fc410..0383251 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/ServerCacheClient.java
@@ -37,6 +37,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.HTableInterface;
@@ -81,6 +82,7 @@ import com.google.common.collect.ImmutableSet;
  */
 public class ServerCacheClient {
     public static final int UUID_LENGTH = Bytes.SIZEOF_LONG;
+    public static final byte[] KEY_IN_FIRST_REGION = new byte[]{0};
     private static final Log LOG = LogFactory.getLog(ServerCacheClient.class);
     private static final Random RANDOM = new Random();
     private final PhoenixConnection connection;
@@ -177,7 +179,7 @@ public class ServerCacheClient {
                     // Call RPC once per server
                     servers.add(entry);
                     if (LOG.isDebugEnabled()) {LOG.debug(addCustomAnnotations("Adding cache entry to be sent for " + entry, connection));}
-                    final byte[] key = entry.getRegionInfo().getStartKey();
+                    final byte[] key = getKeyInRegion(entry.getRegionInfo().getStartKey());
                     final HTableInterface htable = services.getTable(cacheUsingTableRef.getTable().getPhysicalName().getBytes());
                     closeables.add(htable);
                     futures.add(executor.submit(new JobCallable<Boolean>() {
@@ -319,7 +321,7 @@ public class ServerCacheClient {
     		for (HRegionLocation entry : locations) {
     			if (remainingOnServers.contains(entry)) {  // Call once per server
     				try {
-    					byte[] key = entry.getRegionInfo().getStartKey();
+                        byte[] key = getKeyInRegion(entry.getRegionInfo().getStartKey());
     					iterateOverTable.coprocessorService(ServerCachingService.class, key, key, 
     							new Batch.Call<ServerCachingService, RemoveServerCacheResponse>() {
     						@Override
@@ -382,4 +384,12 @@ public class ServerCacheClient {
         assert(uuid.length == Bytes.SIZEOF_LONG);
         return Long.toString(Bytes.toLong(uuid));
     }
+
+    private static byte[] getKeyInRegion(byte[] regionStartKey) {
+        assert (regionStartKey != null);
+        if (Bytes.equals(regionStartKey, HConstants.EMPTY_START_ROW)) {
+            return KEY_IN_FIRST_REGION;
+        }
+        return regionStartKey;
+    }
 }