hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject [12/23] hbase git commit: HBASE-19077 Have Region*CoprocessorEnvironment provide an ImmutableOnlineRegions
Date Wed, 25 Oct 2017 12:37:33 GMT
HBASE-19077 Have Region*CoprocessorEnvironment provide an ImmutableOnlineRegions

Change name of Interface OnlineRegions to MutableOnlineRegions.
Change name of Interface ImmutableOnlineRegions to OnlineRegions.
Did this since OnlineRegions is for consumer other than internals.

Add a getOnlineRegions to the RegionCoprocessorEnvironment and to
RegionServerCoprocessorEnvironment so CPs can 'access' local
Regions directly.


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

Branch: refs/heads/HBASE-18410
Commit: 95528d12f33eeccb1bd1e80b3441c4f14153dcd2
Parents: 2e64813
Author: Michael Stack <stack@apache.org>
Authored: Tue Oct 24 15:37:32 2017 -0700
Committer: Michael Stack <stack@apache.org>
Committed: Tue Oct 24 21:58:14 2017 -0700

----------------------------------------------------------------------
 .../RegionCoprocessorEnvironment.java           |  6 ++
 .../RegionServerCoprocessorEnvironment.java     |  6 ++
 .../regionserver/ImmutableOnlineRegions.java    | 60 --------------------
 .../regionserver/MutableOnlineRegions.java      | 44 ++++++++++++++
 .../hbase/regionserver/OnlineRegions.java       | 47 +++++++++------
 .../regionserver/RegionCoprocessorHost.java     |  6 ++
 .../RegionServerCoprocessorHost.java            |  7 +++
 .../regionserver/RegionServerServices.java      |  2 +-
 .../regionserver/handler/OpenRegionHandler.java |  2 +-
 .../security/token/TestTokenAuthentication.java |  6 ++
 10 files changed, 108 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java
index 8058a9d..05df33d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionCoprocessorEnvironment.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.RegionInfo;
 import org.apache.hadoop.hbase.metrics.MetricRegistry;
+import org.apache.hadoop.hbase.regionserver.OnlineRegions;
 import org.apache.hadoop.hbase.regionserver.Region;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
@@ -40,6 +41,11 @@ public interface RegionCoprocessorEnvironment extends CoprocessorEnvironment<Reg
   /** @return region information for the region this coprocessor is running on */
   RegionInfo getRegionInfo();
 
+  /**
+   * @return Interface to Map of regions online on this RegionServer {@link #getServerName()}}.
+   */
+  OnlineRegions getOnlineRegions();
+
   /** @return shared data between all instances of this coprocessor */
   ConcurrentMap<String, Object> getSharedData();
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessorEnvironment.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessorEnvironment.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessorEnvironment.java
index d0a728e..116d86d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessorEnvironment.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerCoprocessorEnvironment.java
@@ -23,6 +23,7 @@ import org.apache.hadoop.hbase.HBaseInterfaceAudience;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.metrics.MetricRegistry;
+import org.apache.hadoop.hbase.regionserver.OnlineRegions;
 import org.apache.yetus.audience.InterfaceAudience;
 import org.apache.yetus.audience.InterfaceStability;
 
@@ -36,6 +37,11 @@ public interface RegionServerCoprocessorEnvironment
   ServerName getServerName();
 
   /**
+   * @return Interface to Map of regions online on this RegionServer {@link #getServerName()}}.
+   */
+  OnlineRegions getOnlineRegions();
+
+  /**
    * Be careful RPC'ing from a Coprocessor context.
    * RPC's will fail, stall, retry, and/or crawl because the remote side is not online, is
    * struggling or it is on the other side of a network partition. Any use of Connection
from

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ImmutableOnlineRegions.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ImmutableOnlineRegions.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ImmutableOnlineRegions.java
deleted file mode 100644
index ffd1fa7..0000000
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ImmutableOnlineRegions.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase.regionserver;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.hadoop.hbase.HBaseInterfaceAudience;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.yetus.audience.InterfaceStability;
-
-/**
- * Interface to Map of online regions.  In the  Map, the key is the region's
- * encoded name and the value is an {@link Region} instance.
- */
-@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
-@InterfaceStability.Evolving
-public interface ImmutableOnlineRegions {
-
-  /**
-   * Return {@link Region} instance.
-   * Only works if caller is in same context, in same JVM. Region is not
-   * serializable.
-   * @param encodedRegionName
-   * @return Region for the passed encoded <code>encodedRegionName</code> or
-   * null if named region is not member of the online regions.
-   */
-  Region getRegion(String encodedRegionName);
-
-   /**
-    * Get all online regions of a table in this RS.
-    * @param tableName
-    * @return List of Region
-    * @throws java.io.IOException
-    */
-   List<? extends Region> getRegions(TableName tableName) throws IOException;
-
-   /**
-    * Get all online regions in this RS.
-    * @return List of online Region
-    */
-   List<? extends Region> getRegions();
-}

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MutableOnlineRegions.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MutableOnlineRegions.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MutableOnlineRegions.java
new file mode 100644
index 0000000..11c9af9
--- /dev/null
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MutableOnlineRegions.java
@@ -0,0 +1,44 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.regionserver;
+
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Interface to Map of online regions.  In the  Map, the key is the region's
+ * encoded name and the value is an {@link Region} instance.
+ */
+@InterfaceAudience.Private
+public interface MutableOnlineRegions extends OnlineRegions {
+
+  /**
+   * Add to online regions.
+   * @param r
+   */
+  void addRegion(final HRegion r);
+
+  /**
+   * Removes the given Region from the list of onlineRegions.
+   * @param r Region to remove.
+   * @param destination Destination, if any, null otherwise.
+   * @return True if we removed a region from online list.
+   */
+  boolean removeRegion(final HRegion r, ServerName destination);
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnlineRegions.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnlineRegions.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnlineRegions.java
index c9f1c47..25594b7 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnlineRegions.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/OnlineRegions.java
@@ -18,28 +18,43 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
-import org.apache.hadoop.hbase.ServerName;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.hadoop.hbase.HBaseInterfaceAudience;
+import org.apache.hadoop.hbase.TableName;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
 
 /**
- * Interface to Map of online regions.  In the  Map, the key is the region's
- * encoded name and the value is an {@link Region} instance.
+ * Provides read-only access to the Regions presently online on the
+ * current RegionServer
  */
-@InterfaceAudience.Private
-public interface OnlineRegions extends ImmutableOnlineRegions {
+@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
+@InterfaceStability.Evolving
+public interface OnlineRegions {
 
   /**
-   * Add to online regions.
-   * @param r
+   * Return {@link Region} instance.
+   * Only works if caller is in same context, in same JVM. Region is not
+   * serializable.
+   * @param encodedRegionName
+   * @return Region for the passed encoded <code>encodedRegionName</code> or
+   * null if named region is not member of the online regions.
    */
-  void addRegion(final HRegion r);
+  Region getRegion(String encodedRegionName);
 
-  /**
-   * This method removes Region corresponding to hri from the Map of onlineRegions.
-   *
-   * @param r Region to remove.
-   * @param destination Destination, if any, null otherwise.
-   * @return True if we removed a region from online list.
-   */
-  boolean removeRegion(final HRegion r, ServerName destination);
+   /**
+    * Get all online regions of a table in this RS.
+    * @param tableName
+    * @return List of Region
+    * @throws java.io.IOException
+    */
+   List<? extends Region> getRegions(TableName tableName) throws IOException;
+
+   /**
+    * Get all online regions in this RS.
+    * @return List of online Region
+    */
+   List<? extends Region> getRegions();
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
index 735d7ba..42d7ac9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionCoprocessorHost.java
@@ -117,6 +117,7 @@ public class RegionCoprocessorHost
     private final MetricRegistry metricRegistry;
     private final Connection connection;
     private final ServerName serverName;
+    private final OnlineRegions onlineRegions;
 
     /**
      * Constructor
@@ -132,6 +133,7 @@ public class RegionCoprocessorHost
       this.connection = services != null? services.getConnection(): null;
       this.serverName = services != null? services.getServerName(): null;
       this.sharedData = sharedData;
+      this.onlineRegions = services;
       this.metricRegistry =
           MetricsCoprocessor.createRegistryForRegionCoprocessor(impl.getClass().getName());
     }
@@ -142,6 +144,10 @@ public class RegionCoprocessorHost
       return region;
     }
 
+    public OnlineRegions getOnlineRegions() {
+      return this.onlineRegions;
+    }
+
     @Override
     public Connection getConnection() {
       return this.connection;

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
index 33be479..27a3e20 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java
@@ -206,6 +206,7 @@ public class RegionServerCoprocessorHost extends
     private final MetricRegistry metricRegistry;
     private final Connection connection;
     private final ServerName serverName;
+    private final OnlineRegions onlineRegions;
 
     @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="BC_UNCONFIRMED_CAST",
         justification="Intentional; FB has trouble detecting isAssignableFrom")
@@ -216,6 +217,7 @@ public class RegionServerCoprocessorHost extends
       for (Service service : impl.getServices()) {
         services.registerService(service);
       }
+      this.onlineRegions = services;
       this.connection = services.getConnection();
       this.serverName = services.getServerName();
       this.metricRegistry =
@@ -223,6 +225,11 @@ public class RegionServerCoprocessorHost extends
     }
 
     @Override
+    public OnlineRegions getOnlineRegions() {
+      return this.onlineRegions;
+    }
+
+    @Override
     public ServerName getServerName() {
       return this.serverName;
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
index af883a3..2334302 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
@@ -48,7 +48,7 @@ import com.google.protobuf.Service;
  * the code base.
  */
 @InterfaceAudience.Private
-public interface RegionServerServices extends Server, OnlineRegions, FavoredNodesForRegion
{
+public interface RegionServerServices extends Server, MutableOnlineRegions, FavoredNodesForRegion
{
 
   /** @return the WAL for a particular region. Pass null for getting the
    * default (common) WAL */

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
index e664cd5..e4b3ed2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
@@ -121,7 +121,7 @@ public class OpenRegionHandler extends EventHandler {
         return;
       }
 
-      // Successful region open, and add it to OnlineRegions
+      // Successful region open, and add it to MutableOnlineRegions
       this.rsServices.addRegion(region);
       openSuccessful = true;
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/95528d12/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
index 11af0de..e849b30 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/token/TestTokenAuthentication.java
@@ -59,6 +59,7 @@ import org.apache.hadoop.hbase.ipc.SimpleRpcServer;
 import org.apache.hadoop.hbase.metrics.MetricRegistry;
 import org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos;
 import org.apache.hadoop.hbase.regionserver.HRegion;
+import org.apache.hadoop.hbase.regionserver.OnlineRegions;
 import org.apache.hadoop.hbase.regionserver.RegionServerServices;
 import org.apache.hadoop.hbase.security.SecurityInfo;
 import org.apache.hadoop.hbase.security.User;
@@ -273,6 +274,11 @@ public class TestTokenAuthentication {
         public HRegion getRegion() { return null; }
 
         @Override
+        public OnlineRegions getOnlineRegions() {
+          return null;
+        }
+
+        @Override
         public void startup() throws IOException {}
 
         @Override


Mime
View raw message