phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-3199 ServerCacheClient sends cache to all regions unnecessarily (chenglei)
Date Fri, 04 Nov 2016 16:19:56 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 83ed28f4e -> 87421ede3


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/87421ede
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/87421ede
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/87421ede

Branch: refs/heads/4.x-HBase-0.98
Commit: 87421ede3e9c22f9e567950c6a0acf735437f3a4
Parents: 83ed28f
Author: James Taylor <jamestaylor@apache.org>
Authored: Fri Nov 4 09:15:19 2016 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Fri Nov 4 09:18:53 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/87421ede/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;
+    }
 }


Mime
View raw message