Apache9 commented on a change in pull request #691: HBASE-23081 Add an option 
to enable/disable rs group feature
URL: https://github.com/apache/hbase/pull/691#discussion_r331792687
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/DisabledRSGroupInfoManager.java
 ##########
 @@ -0,0 +1,110 @@
+/**
+ * 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.rsgroup;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.master.ServerManager;
+import org.apache.hadoop.hbase.net.Address;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * A dummy RSGroupInfoManager which only contains a default rs group.
+ */
+@InterfaceAudience.Private
+class DisabledRSGroupInfoManager implements RSGroupInfoManager {
+
+  private final ServerManager serverManager;
+
+  public DisabledRSGroupInfoManager(ServerManager serverManager) {
+    this.serverManager = serverManager;
+  }
+
+  @Override
+  public void start() {
+  }
+
+  @Override
+  public void addRSGroup(RSGroupInfo rsGroupInfo) throws IOException {
+    throw new DoNotRetryIOException("RSGroup is disabled");
+  }
+
+  @Override
+  public void removeRSGroup(String groupName) throws IOException {
+    throw new DoNotRetryIOException("RSGroup is disabled");
+  }
+
+  @Override
+  public Set<Address> moveServers(Set<Address> servers, String srcGroup, 
String dstGroup)
+    throws IOException {
+    throw new DoNotRetryIOException("RSGroup is disabled");
+  }
+
+  private SortedSet<Address> getOnlineServers() {
+    SortedSet<Address> onlineServers = new TreeSet<Address>();
+    
serverManager.getOnlineServers().keySet().stream().map(ServerName::getAddress)
+      .forEach(onlineServers::add);
+    return onlineServers;
+  }
+
+  @Override
+  public RSGroupInfo getRSGroupOfServer(Address serverHostPort) throws 
IOException {
+    SortedSet<Address> onlineServers = getOnlineServers();
+    if (onlineServers.contains(serverHostPort)) {
+      return new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, onlineServers);
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public RSGroupInfo getRSGroup(String groupName) throws IOException {
+    if (RSGroupInfo.DEFAULT_GROUP.equals(groupName)) {
+      return new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, getOnlineServers());
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public List<RSGroupInfo> listRSGroups() throws IOException {
+    return Arrays.asList(new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, 
getOnlineServers()));
+  }
+
+  @Override
+  public boolean isOnline() {
+    return true;
+  }
+
+  @Override
+  public void removeServers(Set<Address> servers) throws IOException {
+    throw new DoNotRetryIOException("RSGroup is disabled");
+  }
+
+  @Override
+  public RSGroupInfo getRSGroupForTable(TableName tableName) throws 
IOException {
+    return null;
 
 Review comment:
   This method has been marked as deprecated. Now rs group will be stored in 
table descriptor, here this method is only useful during migration, where we 
still store the rs group info for a table is RSGroupInfo. As here we disabled 
rs group feature, just return null here. The upper layer will use the rs group 
gotten from the table descriptor.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to