hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [03/21] hbase git commit: HBASE-16456 Fix findbugs warnings in hbase-rsgroup module (Guangxu Cheng)
Date Wed, 19 Jul 2017 00:44:45 GMT
HBASE-16456 Fix findbugs warnings in hbase-rsgroup module (Guangxu Cheng)


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

Branch: refs/heads/HBASE-15631-branch-1
Commit: e560a6820fd23765cfa0af0e7748c27c6858e52f
Parents: 0ee1bf5
Author: Andrew Purtell <apurtell@apache.org>
Authored: Wed Jul 5 17:19:43 2017 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Tue Jul 18 17:44:31 2017 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java  | 16 +++++++++++++++-
 .../hadoop/hbase/rsgroup/RSGroupAdminServer.java    |  2 +-
 .../hbase/rsgroup/RSGroupBasedLoadBalancer.java     | 16 +++++++++-------
 .../hbase/rsgroup/RSGroupInfoManagerImpl.java       | 14 ++++++++++++--
 4 files changed, 37 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e560a682/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
index 8fa9fdc..e71470e 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
@@ -89,7 +89,7 @@ public class RSGroupAdminEndpoint extends RSGroupAdminService
   public void start(CoprocessorEnvironment env) throws IOException {
     MasterCoprocessorEnvironment menv = (MasterCoprocessorEnvironment)env;
     master = menv.getMasterServices();
-    groupInfoManager = new RSGroupInfoManagerImpl(master);
+    setGroupInfoManager(new RSGroupInfoManagerImpl(master));
     groupAdminServer = new RSGroupAdminServer(master, groupInfoManager);
     Class<?> clazz =
         master.getConfiguration().getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, null);
@@ -107,6 +107,20 @@ public class RSGroupAdminEndpoint extends RSGroupAdminService
     return this;
   }
 
+  private static void setStaticGroupInfoManager(RSGroupInfoManagerImpl groupInfoManager)
{
+    RSGroupAdminEndpoint.groupInfoManager = groupInfoManager;
+  }
+
+  private void setGroupInfoManager(RSGroupInfoManagerImpl groupInfoManager) throws IOException
{
+    if (groupInfoManager == null) {
+      groupInfoManager = new RSGroupInfoManagerImpl(master);
+      groupInfoManager.init();
+    } else if (!groupInfoManager.isInit()) {
+      groupInfoManager.init();
+    }
+    setStaticGroupInfoManager(groupInfoManager);
+  }
+
   public RSGroupInfoManager getGroupInfoManager() {
     return groupInfoManager;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e560a682/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
index 43ac3ad..e76e3e7 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
@@ -218,7 +218,7 @@ public class RSGroupAdminServer extends RSGroupAdmin {
             }
           }
           try {
-            Thread.sleep(1000);
+            manager.wait(1000);
           } catch (InterruptedException e) {
             LOG.warn("Sleep interrupted", e);
             Thread.currentThread().interrupt();

http://git-wip-us.apache.org/repos/asf/hbase/blob/e560a682/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
index c1b3c7d..519177c 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
@@ -322,18 +322,19 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer,
LoadBalanc
   private Set<HRegionInfo> getMisplacedRegions(
       Map<HRegionInfo, ServerName> regions) throws IOException {
     Set<HRegionInfo> misplacedRegions = new HashSet<HRegionInfo>();
-    for (HRegionInfo region : regions.keySet()) {
-      ServerName assignedServer = regions.get(region);
+    for(Map.Entry<HRegionInfo, ServerName> region : regions.entrySet()) {
+      HRegionInfo regionInfo = region.getKey();
+      ServerName assignedServer = region.getValue();
       RSGroupInfo info =
-          RSGroupInfoManager.getRSGroup(RSGroupInfoManager.getRSGroupOfTable(region.getTable()));
+          RSGroupInfoManager.getRSGroup(RSGroupInfoManager.getRSGroupOfTable(regionInfo.getTable()));
       if (assignedServer != null &&
           (info == null || !info.containsServer(assignedServer.getHostPort()))) {
-        LOG.debug("Found misplaced region: " + region.getRegionNameAsString() +
+        LOG.debug("Found misplaced region: " + regionInfo.getRegionNameAsString() +
             " on server: " + assignedServer +
             " found in group: " +
             RSGroupInfoManager.getRSGroupOfServer(assignedServer.getHostPort()) +
             " outside of group: " + (info == null ? "UNKNOWN" : info.getName()));
-        misplacedRegions.add(region);
+        misplacedRegions.add(regionInfo);
       }
     }
     return misplacedRegions;
@@ -345,9 +346,10 @@ public class RSGroupBasedLoadBalancer implements RSGroupableBalancer,
LoadBalanc
         new TreeMap<ServerName, List<HRegionInfo>>();
     List<HRegionInfo> misplacedRegions = new LinkedList<HRegionInfo>();
     correctAssignments.put(LoadBalancer.BOGUS_SERVER_NAME, new LinkedList<HRegionInfo>());
-    for (ServerName sName : existingAssignments.keySet()) {
+    for (Map.Entry<ServerName, List<HRegionInfo>> assignments : existingAssignments.entrySet()){
+      ServerName sName = assignments.getKey();
       correctAssignments.put(sName, new LinkedList<HRegionInfo>());
-      List<HRegionInfo> regions = existingAssignments.get(sName);
+      List<HRegionInfo> regions = assignments.getValue();
       for (HRegionInfo region : regions) {
         RSGroupInfo info = null;
         try {

http://git-wip-us.apache.org/repos/asf/hbase/blob/e560a682/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
index 5cb2e71..c46ad87 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
@@ -120,7 +120,7 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
   private volatile Set<String> prevRSGroups;
   private RSGroupSerDe rsGroupSerDe;
   private DefaultServerUpdater defaultServerUpdater;
-
+  private boolean isInit = false;
 
   public RSGroupInfoManagerImpl(MasterServices master) throws IOException {
     this.rsGroupMap = Collections.emptyMap();
@@ -129,13 +129,21 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
     this.master = master;
     this.watcher = master.getZooKeeper();
     this.conn = master.getConnection();
-    rsGroupStartupWorker = new RSGroupStartupWorker(this, master, conn);
     prevRSGroups = new HashSet<String>();
+  }
+
+  public void init() throws IOException{
+    rsGroupStartupWorker = new RSGroupStartupWorker(this, master, conn);
     refresh();
     rsGroupStartupWorker.start();
     defaultServerUpdater = new DefaultServerUpdater(this);
     master.getServerManager().registerListener(this);
     defaultServerUpdater.start();
+    isInit = true;
+  }
+
+  boolean isInit() {
+    return isInit;
   }
 
   /**
@@ -672,6 +680,8 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
             //flush any inconsistencies between ZK and HTable
             groupInfoManager.flushConfig(groupInfoManager.rsGroupMap);
           }
+        } catch (RuntimeException e) {
+          throw e;
         } catch(Exception e) {
           found.set(false);
           LOG.warn("Failed to perform check", e);


Mime
View raw message