diff --git a/hbase-annotations/src/test/java/org/apache/hadoop/hbase/testclassification/RSGroupTests.java b/hbase-annotations/src/test/java/org/apache/hadoop/hbase/testclassification/RSGroupTests.java
new file mode 100644
index 00000000000..80b04eb7e59
--- /dev/null
+++ b/hbase-annotations/src/test/java/org/apache/hadoop/hbase/testclassification/RSGroupTests.java
@@ -0,0 +1,24 @@
+/**
+ * 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.testclassification;
+
+/**
+ * Tag the tests related to rs group feature.
+ */
+public interface RSGroupTests {
+}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
index aeb51978f43..1e730228cd1 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
@@ -2338,7 +2338,7 @@ public interface Admin extends Abortable, Closeable {
* @param servers set of servers to remove
* @throws IOException if a remote or network exception occurs
*/
- void removeRSGroup(Set
servers) throws IOException;
+ void removeServersFromRSGroup(Set servers) throws IOException;
/**
* Move given set of servers to the specified target RegionServer group
@@ -2346,7 +2346,7 @@ public interface Admin extends Abortable, Closeable {
* @param targetGroup the group to move servers to
* @throws IOException if a remote or network exception occurs
*/
- void moveToRSGroup(Set servers, String targetGroup) throws IOException;
+ void moveServersToRSGroup(Set servers, String targetGroup) throws IOException;
/**
* Set the RegionServer group for tables
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java
index 293d5133045..c790cde68fc 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AdminOverAsyncAdmin.java
@@ -980,8 +980,8 @@ class AdminOverAsyncAdmin implements Admin {
}
@Override
- public void moveToRSGroup(Set servers, String groupName) throws IOException {
- get(admin.moveToRSGroup(servers, groupName));
+ public void moveServersToRSGroup(Set servers, String groupName) throws IOException {
+ get(admin.moveServersToRSGroup(servers, groupName));
}
@Override
@@ -1010,8 +1010,8 @@ class AdminOverAsyncAdmin implements Admin {
}
@Override
- public void removeRSGroup(Set servers) throws IOException {
- get(admin.removeRSGroup(servers));
+ public void removeServersFromRSGroup(Set servers) throws IOException {
+ get(admin.removeServersFromRSGroup(servers));
}
@Override
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java
index d53aab28562..70ce6066f84 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncAdmin.java
@@ -1580,7 +1580,7 @@ public interface AsyncAdmin {
* @param servers set of servers to remove
* @throws IOException if a remote or network exception occurs
*/
- CompletableFuture removeRSGroup(Set servers);
+ CompletableFuture removeServersFromRSGroup(Set servers);
/**
* Move given set of servers to the specified target RegionServer group
@@ -1588,7 +1588,7 @@ public interface AsyncAdmin {
* @param groupName the group to move servers to
* @throws IOException if a remote or network exception occurs
*/
- CompletableFuture moveToRSGroup(Set servers, String groupName);
+ CompletableFuture moveServersToRSGroup(Set servers, String groupName);
/**
* Set the RegionServer group for tables
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java
index 7939b80e220..edbd646c725 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncHBaseAdmin.java
@@ -858,8 +858,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture moveToRSGroup(Set servers, String groupName) {
- return wrap(rawAdmin.moveToRSGroup(servers, groupName));
+ public CompletableFuture moveServersToRSGroup(Set servers, String groupName) {
+ return wrap(rawAdmin.moveServersToRSGroup(servers, groupName));
}
@Override
@@ -888,8 +888,8 @@ class AsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture removeRSGroup(Set servers) {
- return wrap(rawAdmin.removeRSGroup(servers));
+ public CompletableFuture removeServersFromRSGroup(Set servers) {
+ return wrap(rawAdmin.removeServersFromRSGroup(servers));
}
@Override
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
index b9cb700d88c..4e0ad267794 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RawAsyncHBaseAdmin.java
@@ -289,6 +289,12 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddR
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddRSGroupResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.BalanceRSGroupRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.BalanceRSGroupResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfServerRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfServerResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.MoveServersRequest;
@@ -3885,7 +3891,7 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
}
@Override
- public CompletableFuture moveToRSGroup(Set servers, String groupName) {
+ public CompletableFuture moveServersToRSGroup(Set servers, String groupName) {
return this. newMasterCaller()
.action((controller, stub) -> this.
call(controller, stub,
@@ -3998,27 +4004,23 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
@Override
public CompletableFuture getRSGroup(Address hostPort) {
- CompletableFuture future = new CompletableFuture<>();
- addListener(listRSGroups(), (groups, err) -> {
- if (err != null) {
- future.completeExceptionally(err);
- return;
- }
- for (RSGroupInfo rsGroupInfo : groups) {
- if (rsGroupInfo.getServers().contains(hostPort)){
- future.complete(rsGroupInfo);
- return;
- }
- }
- future.complete(null);
- });
- return future;
+ return this. newMasterCaller()
+ .action(((controller, stub) -> this
+ . call(
+ controller, stub,
+ GetRSGroupInfoOfServerRequest.newBuilder()
+ .setServer(HBaseProtos.ServerName.newBuilder().setHostName(hostPort.getHostname())
+ .setPort(hostPort.getPort()).build())
+ .build(),
+ (s, c, req, done) -> s.getRSGroupInfoOfServer(c, req, done),
+ resp -> resp.hasRSGroupInfo() ? ProtobufUtil.toGroupInfo(resp.getRSGroupInfo()) : null)))
+ .call();
}
@Override
- public CompletableFuture removeRSGroup(Set servers) {
+ public CompletableFuture removeServersFromRSGroup(Set servers) {
return this. newMasterCaller()
- .action((controller, stub) -> this.
+ .action((controller, stub) -> this.
call(controller, stub,
RequestConverter.buildRemoveServersRequest(servers),
(s, c, req, done) -> s.removeServers(c, req, done), resp -> null))
@@ -4069,47 +4071,24 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
@Override
public CompletableFuture getRSGroup(TableName table) {
- CompletableFuture future = new CompletableFuture<>();
- addListener(getDescriptor(table), (td, err) -> {
- if (err != null) {
- // return null instead of err to keep compatible with old semantics
- // todo: need to change both this and UTs
- future.complete(null);
- return;
- }
- addListener(listRSGroups(), (groups, err2) -> {
- if (err2 != null) {
- future.completeExceptionally(err2);
- return;
- }
- for (RSGroupInfo rsGroupInfo : groups) {
- if (rsGroupInfo.getTables().contains(table)) {
- future.complete(rsGroupInfo);
- return;
- }
- }
- future.complete(null);
- });
- });
- return future;
+ return this. newMasterCaller().action(((controller, stub) -> this
+ . call(controller,
+ stub,
+ GetRSGroupInfoOfTableRequest.newBuilder().setTableName(ProtobufUtil.toProtoTableName(table))
+ .build(),
+ (s, c, req, done) -> s.getRSGroupInfoOfTable(c, req, done),
+ resp -> resp.hasRSGroupInfo() ? ProtobufUtil.toGroupInfo(resp.getRSGroupInfo()) : null)))
+ .call();
}
@Override
public CompletableFuture getRSGroup(String groupName) {
- CompletableFuture future = new CompletableFuture<>();
- addListener(listRSGroups(), (groups, err) -> {
- if (err != null) {
- future.completeExceptionally(err);
- return;
- }
- for (RSGroupInfo rsGroupInfo : groups) {
- if (rsGroupInfo.getName().equals(groupName)){
- future.complete(rsGroupInfo);
- return;
- }
- }
- future.complete(null);
- });
- return future;
+ return this. newMasterCaller()
+ .action(((controller, stub) -> this
+ . call(controller, stub,
+ GetRSGroupInfoRequest.newBuilder().setRSGroupName(groupName).build(),
+ (s, c, req, done) -> s.getRSGroupInfo(c, req, done),
+ resp -> resp.hasRSGroupInfo() ? ProtobufUtil.toGroupInfo(resp.getRSGroupInfo()) : null)))
+ .call();
}
}
diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/rsgroup/IntegrationTestRSGroup.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/rsgroup/IntegrationTestRSGroup.java
index ef3a93a077d..551d28051c0 100644
--- a/hbase-it/src/test/java/org/apache/hadoop/hbase/rsgroup/IntegrationTestRSGroup.java
+++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/rsgroup/IntegrationTestRSGroup.java
@@ -41,7 +41,7 @@ public class IntegrationTestRSGroup extends TestRSGroupsBase {
@Before
public void beforeMethod() throws Exception {
- if(!initialized) {
+ if (!initialized) {
LOG.info("Setting up IntegrationTestRSGroup");
LOG.info("Initializing cluster with " + NUM_SLAVES_BASE + " servers");
TEST_UTIL = new IntegrationTestingUtility();
@@ -49,16 +49,15 @@ public class IntegrationTestRSGroup extends TestRSGroupsBase {
RSGroupBasedLoadBalancer.class.getName());
TEST_UTIL.getConfiguration().set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY,
RSGroupAdminEndpoint.class.getName());
- ((IntegrationTestingUtility)TEST_UTIL).initializeCluster(NUM_SLAVES_BASE);
- //set shared configs
- admin = TEST_UTIL.getAdmin();
- cluster = TEST_UTIL.getHBaseClusterInterface();
- rsGroupAdmin = new VerifyingRSGroupAdminClient(new RSGroupAdminClient(TEST_UTIL.getConnection()),
- TEST_UTIL.getConfiguration());
+ ((IntegrationTestingUtility) TEST_UTIL).initializeCluster(NUM_SLAVES_BASE);
+ // set shared configs
+ ADMIN = TEST_UTIL.getAdmin();
+ CLUSTER = TEST_UTIL.getHBaseClusterInterface();
+ RS_GROUP_ADMIN_CLIENT = new RSGroupAdminClient(TEST_UTIL.getConnection());
LOG.info("Done initializing cluster");
initialized = true;
- //cluster may not be clean
- //cleanup when initializing
+ // cluster may not be clean
+ // cleanup when initializing
afterMethod();
}
}
@@ -70,7 +69,7 @@ public class IntegrationTestRSGroup extends TestRSGroupsBase {
deleteTableIfNecessary();
deleteNamespaceIfNecessary();
deleteGroups();
- admin.balancerSwitch(true, true);
+ ADMIN.balancerSwitch(true, true);
LOG.info("Restoring the cluster");
((IntegrationTestingUtility)TEST_UTIL).restoreCluster();
@@ -79,10 +78,10 @@ public class IntegrationTestRSGroup extends TestRSGroupsBase {
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- LOG.info("Waiting for cleanup to finish "+ rsGroupAdmin.listRSGroups());
+ LOG.info("Waiting for cleanup to finish "+ ADMIN.listRSGroups());
//Might be greater since moving servers back to default
//is after starting a server
- return rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size()
+ return ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size()
>= NUM_SLAVES_BASE;
}
});
@@ -90,10 +89,10 @@ public class IntegrationTestRSGroup extends TestRSGroupsBase {
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- LOG.info("Waiting for regionservers to be registered "+ rsGroupAdmin.listRSGroups());
+ LOG.info("Waiting for regionservers to be registered "+ ADMIN.listRSGroups());
//Might be greater since moving servers back to default
//is after starting a server
- return rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size()
+ return ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size()
== getNumServers();
}
});
diff --git a/hbase-protocol-shaded/src/main/protobuf/Master.proto b/hbase-protocol-shaded/src/main/protobuf/Master.proto
index 368328e6c4d..ff492ee2ba7 100644
--- a/hbase-protocol-shaded/src/main/protobuf/Master.proto
+++ b/hbase-protocol-shaded/src/main/protobuf/Master.proto
@@ -1087,6 +1087,15 @@ service MasterService {
rpc ListNamespaces(ListNamespacesRequest)
returns(ListNamespacesResponse);
+ rpc GetRSGroupInfo(GetRSGroupInfoRequest)
+ returns (GetRSGroupInfoResponse);
+
+ rpc GetRSGroupInfoOfTable(GetRSGroupInfoOfTableRequest)
+ returns (GetRSGroupInfoOfTableResponse);
+
+ rpc GetRSGroupInfoOfServer(GetRSGroupInfoOfServerRequest)
+ returns (GetRSGroupInfoOfServerResponse);
+
rpc MoveServers(MoveServersRequest)
returns (MoveServersResponse);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
index 223acc2cb46..52fc425ade4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
@@ -321,6 +321,12 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddR
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.AddRSGroupResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.BalanceRSGroupRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.BalanceRSGroupResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfServerRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfServerResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoOfTableResponse;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoRequest;
+import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosRequest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosResponse;
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.MoveServersRequest;
@@ -2918,6 +2924,94 @@ public class MasterRpcServices extends RSRpcServices implements
return response.build();
}
+ @Override
+ public GetRSGroupInfoResponse getRSGroupInfo(RpcController controller,
+ GetRSGroupInfoRequest request) throws ServiceException {
+ String groupName = request.getRSGroupName();
+ LOG.info(
+ master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, group=" + groupName);
+ try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preGetRSGroupInfo(groupName);
+ }
+ RSGroupInfo rsGroupInfo = master.getRSGroupInfoManager().getRSGroup(groupName);
+ GetRSGroupInfoResponse resp;
+ if (rsGroupInfo != null) {
+ resp = GetRSGroupInfoResponse.newBuilder()
+ .setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo)).build();
+ } else {
+ resp = GetRSGroupInfoResponse.getDefaultInstance();
+ }
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postGetRSGroupInfo(groupName);
+ }
+ return resp;
+ } catch (IOException e) {
+ throw new ServiceException(e);
+ }
+ }
+
+ @Override
+ public GetRSGroupInfoOfTableResponse getRSGroupInfoOfTable(RpcController controller,
+ GetRSGroupInfoOfTableRequest request) throws ServiceException {
+ TableName tableName = ProtobufUtil.toTableName(request.getTableName());
+ LOG.info(
+ master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table=" + tableName);
+ try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preGetRSGroupInfoOfTable(tableName);
+ }
+ GetRSGroupInfoOfTableResponse resp;
+ TableDescriptor td = master.getTableDescriptors().get(tableName);
+ if (td == null) {
+ resp = GetRSGroupInfoOfTableResponse.getDefaultInstance();
+ } else {
+ RSGroupInfo rsGroupInfo = null;
+ if (td.getRegionServerGroup().isPresent()) {
+ rsGroupInfo = master.getRSGroupInfoManager().getRSGroup(td.getRegionServerGroup().get());
+ }
+ if (rsGroupInfo == null) {
+ rsGroupInfo = master.getRSGroupInfoManager().getRSGroup(RSGroupInfo.DEFAULT_GROUP);
+ }
+ resp = GetRSGroupInfoOfTableResponse.newBuilder()
+ .setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo)).build();
+ }
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postGetRSGroupInfoOfTable(tableName);
+ }
+ return resp;
+ } catch (IOException e) {
+ throw new ServiceException(e);
+ }
+ }
+
+ @Override
+ public GetRSGroupInfoOfServerResponse getRSGroupInfoOfServer(RpcController controller,
+ GetRSGroupInfoOfServerRequest request) throws ServiceException {
+ Address hp =
+ Address.fromParts(request.getServer().getHostName(), request.getServer().getPort());
+ LOG.info(master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, server=" + hp);
+ try {
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().preGetRSGroupInfoOfServer(hp);
+ }
+ RSGroupInfo rsGroupInfo = master.getRSGroupInfoManager().getRSGroupOfServer(hp);
+ GetRSGroupInfoOfServerResponse resp;
+ if (rsGroupInfo != null) {
+ resp = GetRSGroupInfoOfServerResponse.newBuilder()
+ .setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo)).build();
+ } else {
+ resp = GetRSGroupInfoOfServerResponse.getDefaultInstance();
+ }
+ if (master.getMasterCoprocessorHost() != null) {
+ master.getMasterCoprocessorHost().postGetRSGroupInfoOfServer(hp);
+ }
+ return resp;
+ } catch (IOException e) {
+ throw new ServiceException(e);
+ }
+ }
+
@Override
public MoveServersResponse moveServers(RpcController controller, MoveServersRequest request)
throws ServiceException {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdmin.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdmin.java
deleted file mode 100644
index 3de6965efb3..00000000000
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdmin.java
+++ /dev/null
@@ -1,82 +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.rsgroup;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Set;
-import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.net.Address;
-import org.apache.yetus.audience.InterfaceAudience;
-
-/**
- * Group user API interface used between client and server.
- *
- * @deprecated Keep it here only for tests, using {@link Admin} instead.
- */
-@Deprecated
-@InterfaceAudience.Private
-public interface RSGroupAdmin {
- /**
- * Gets {@code RSGroupInfo} for given group name.
- */
- RSGroupInfo getRSGroupInfo(String groupName) throws IOException;
-
- /**
- * Move given set of servers to the specified target RegionServer group.
- */
- void moveServers(Set servers, String targetGroup) throws IOException;
-
- /**
- * Creates a new RegionServer group with the given name.
- */
- void addRSGroup(String groupName) throws IOException;
-
- /**
- * Removes RegionServer group associated with the given name.
- */
- void removeRSGroup(String groupName) throws IOException;
-
- /**
- * Balance regions in the given RegionServer group.
- *
- * @return boolean Whether balance ran or not
- */
- boolean balanceRSGroup(String groupName) throws IOException;
-
- /**
- * Lists current set of RegionServer groups.
- */
- List listRSGroups() throws IOException;
-
- /**
- * Retrieve the RSGroupInfo a server is affiliated to
- * @param hostPort HostPort to get RSGroupInfo for
- */
- RSGroupInfo getRSGroupOfServer(Address hostPort) throws IOException;
-
- /**
- * Remove decommissioned servers from rsgroup.
- * 1. Sometimes we may find the server aborted due to some hardware failure and we must offline
- * the server for repairing. Or we need to move some servers to join other clusters.
- * So we need to remove these servers from the rsgroup.
- * 2. Dead/recovering/live servers will be disallowed.
- * @param servers set of servers to remove
- */
- void removeServers(Set servers) throws IOException;
-}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminClient.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminClient.java
index 94ac353db66..3e17234c34b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminClient.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminClient.java
@@ -20,35 +20,12 @@ package org.apache.hadoop.hbase.rsgroup;
import com.google.protobuf.ServiceException;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.EnumSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Future;
-import java.util.regex.Pattern;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CacheEvictionStats;
-import org.apache.hadoop.hbase.ClusterMetrics;
-import org.apache.hadoop.hbase.NamespaceDescriptor;
-import org.apache.hadoop.hbase.NamespaceNotFoundException;
-import org.apache.hadoop.hbase.RegionMetrics;
-import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor;
-import org.apache.hadoop.hbase.client.CompactType;
-import org.apache.hadoop.hbase.client.CompactionState;
import org.apache.hadoop.hbase.client.Connection;
-import org.apache.hadoop.hbase.client.RegionInfo;
-import org.apache.hadoop.hbase.client.SlowLogQueryFilter;
-import org.apache.hadoop.hbase.client.SlowLogRecord;
-import org.apache.hadoop.hbase.client.SnapshotDescription;
-import org.apache.hadoop.hbase.client.TableDescriptor;
-import org.apache.hadoop.hbase.client.replication.TableCFs;
-import org.apache.hadoop.hbase.client.security.SecurityCapability;
-import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
@@ -61,39 +38,24 @@ import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupI
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoRequest;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.GetRSGroupInfoResponse;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.ListRSGroupInfosRequest;
+import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersAndTablesRequest;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveServersRequest;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveTablesRequest;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RSGroupAdminService;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupRequest;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveServersRequest;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupProtos;
-import org.apache.hadoop.hbase.quotas.QuotaFilter;
-import org.apache.hadoop.hbase.quotas.QuotaSettings;
-import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshotView;
-import org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException;
-import org.apache.hadoop.hbase.replication.ReplicationPeerConfig;
-import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
-import org.apache.hadoop.hbase.replication.SyncReplicationState;
-import org.apache.hadoop.hbase.security.access.GetUserPermissionsRequest;
-import org.apache.hadoop.hbase.security.access.Permission;
-import org.apache.hadoop.hbase.security.access.UserPermission;
-import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
-import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
-import org.apache.hadoop.hbase.snapshot.SnapshotCreationException;
-import org.apache.hadoop.hbase.snapshot.UnknownSnapshotException;
import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
/**
* Client used for managing region server group information.
- *
* @deprecated Keep it here only for tests, using {@link Admin} instead.
*/
@Deprecated
@InterfaceAudience.Private
-public class RSGroupAdminClient implements RSGroupAdmin, Admin {
+public class RSGroupAdminClient {
private RSGroupAdminService.BlockingInterface stub;
private Admin admin;
@@ -102,852 +64,13 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
stub = RSGroupAdminService.newBlockingStub(admin.coprocessorService());
}
- // for writing UTs
- @VisibleForTesting
- protected RSGroupAdminClient() {
- }
-
- @Override
- public int getOperationTimeout() {
- return 0;
- }
-
- @Override
- public int getSyncWaitTimeout() {
- return 0;
- }
-
- @Override
- public void abort(String why, Throwable e) {
-
- }
-
- @Override
- public boolean isAborted() {
- return false;
- }
-
- @Override
- public Connection getConnection() {
- return null;
- }
-
- @Override
- public boolean tableExists(TableName tableName) throws IOException {
- return false;
- }
-
- @Override
- public List listTableDescriptors() throws IOException {
- return null;
- }
-
- @Override
- public List listTableDescriptors(boolean includeSysTables) throws IOException {
- return null;
- }
-
- @Override
- public List listTableDescriptors(Pattern pattern) throws IOException {
- return null;
- }
-
- @Override
- public List listTableDescriptors(Pattern pattern, boolean includeSysTables)
- throws IOException {
- return null;
- }
-
- @Override
- public TableName[] listTableNames() throws IOException {
- return new TableName[0];
- }
-
- @Override
- public TableName[] listTableNames(Pattern pattern, boolean includeSysTables) throws IOException {
- return new TableName[0];
- }
-
- @Override
- public TableDescriptor getDescriptor(TableName tableName)
- throws TableNotFoundException, IOException {
- return null;
- }
-
- @Override
- public void createTable(TableDescriptor desc, byte[] startKey, byte[] endKey, int numRegions)
- throws IOException {
-
- }
-
- @Override
- public Future createTableAsync(TableDescriptor desc) throws IOException {
- return null;
- }
-
- @Override
- public Future createTableAsync(TableDescriptor desc, byte[][] splitKeys)
- throws IOException {
- return null;
- }
-
- @Override
- public Future deleteTableAsync(TableName tableName) throws IOException {
- return null;
- }
-
- @Override
- public Future truncateTableAsync(TableName tableName, boolean preserveSplits)
- throws IOException {
- return null;
- }
-
- @Override
- public Future enableTableAsync(TableName tableName) throws IOException {
- return null;
- }
-
- @Override
- public Future disableTableAsync(TableName tableName) throws IOException {
- return null;
- }
-
- @Override
- public boolean isTableEnabled(TableName tableName) throws IOException {
- return false;
- }
-
- @Override
- public boolean isTableDisabled(TableName tableName) throws IOException {
- return false;
- }
-
- @Override
- public boolean isTableAvailable(TableName tableName) throws IOException {
- return false;
- }
-
- @Override
- public Future addColumnFamilyAsync(TableName tableName, ColumnFamilyDescriptor columnFamily)
- throws IOException {
- return null;
- }
-
- @Override
- public Future deleteColumnFamilyAsync(TableName tableName, byte[] columnFamily)
- throws IOException {
- return null;
- }
-
- @Override
- public Future modifyColumnFamilyAsync(TableName tableName,
- ColumnFamilyDescriptor columnFamily) throws IOException {
- return null;
- }
-
- @Override
- public List getRegions(ServerName serverName) throws IOException {
- return null;
- }
-
- @Override
- public void flush(TableName tableName) throws IOException {
-
- }
-
- @Override
- public void flushRegion(byte[] regionName) throws IOException {
-
- }
-
- @Override
- public void flushRegionServer(ServerName serverName) throws IOException {
-
- }
-
- @Override
- public void compact(TableName tableName) throws IOException {
-
- }
-
- @Override
- public void compactRegion(byte[] regionName) throws IOException {
-
- }
-
- @Override
- public void compact(TableName tableName, byte[] columnFamily) throws IOException {
-
- }
-
- @Override
- public void compactRegion(byte[] regionName, byte[] columnFamily) throws IOException {
-
- }
-
- @Override
- public void compact(TableName tableName, CompactType compactType)
- throws IOException, InterruptedException {
-
- }
-
- @Override
- public void compact(TableName tableName, byte[] columnFamily, CompactType compactType)
- throws IOException, InterruptedException {
-
- }
-
- @Override
- public void majorCompact(TableName tableName) throws IOException {
-
- }
-
- @Override
- public void majorCompactRegion(byte[] regionName) throws IOException {
-
- }
-
- @Override
- public void majorCompact(TableName tableName, byte[] columnFamily) throws IOException {
-
- }
-
- @Override
- public void majorCompactRegion(byte[] regionName, byte[] columnFamily) throws IOException {
-
- }
-
- @Override
- public void majorCompact(TableName tableName, CompactType compactType)
- throws IOException, InterruptedException {
-
- }
-
- @Override
- public void majorCompact(TableName tableName, byte[] columnFamily, CompactType compactType)
- throws IOException, InterruptedException {
-
- }
-
- @Override
- public Map compactionSwitch(boolean switchState,
- List serverNamesList) throws IOException {
- return null;
- }
-
- @Override
- public void compactRegionServer(ServerName serverName) throws IOException {
-
- }
-
- @Override
- public void majorCompactRegionServer(ServerName serverName) throws IOException {
-
- }
-
- @Override
- public void move(byte[] encodedRegionName) throws IOException {
-
- }
-
- @Override
- public void move(byte[] encodedRegionName, ServerName destServerName) throws IOException {
-
- }
-
- @Override
- public void assign(byte[] regionName) throws IOException {
-
- }
-
- @Override
- public void unassign(byte[] regionName, boolean force) throws IOException {
-
- }
-
- @Override
- public void offline(byte[] regionName) throws IOException {
-
- }
-
- @Override
- public boolean balancerSwitch(boolean onOrOff, boolean synchronous) throws IOException {
- return false;
- }
-
- @Override
- public boolean balance() throws IOException {
- return false;
- }
-
- @Override
- public boolean balance(boolean force) throws IOException {
- return false;
- }
-
- @Override
- public boolean isBalancerEnabled() throws IOException {
- return false;
- }
-
- @Override
- public CacheEvictionStats clearBlockCache(TableName tableName) throws IOException {
- return null;
- }
-
- @Override
- public boolean normalize() throws IOException {
- return false;
- }
-
- @Override
- public boolean isNormalizerEnabled() throws IOException {
- return false;
- }
-
- @Override
- public boolean normalizerSwitch(boolean on) throws IOException {
- return false;
- }
-
- @Override
- public boolean catalogJanitorSwitch(boolean onOrOff) throws IOException {
- return false;
- }
-
- @Override
- public int runCatalogJanitor() throws IOException {
- return 0;
- }
-
- @Override
- public boolean isCatalogJanitorEnabled() throws IOException {
- return false;
- }
-
- @Override
- public boolean cleanerChoreSwitch(boolean onOrOff) throws IOException {
- return false;
- }
-
- @Override
- public boolean runCleanerChore() throws IOException {
- return false;
- }
-
- @Override
- public boolean isCleanerChoreEnabled() throws IOException {
- return false;
- }
-
- @Override
- public Future mergeRegionsAsync(byte[][] nameofRegionsToMerge, boolean forcible)
- throws IOException {
- return null;
- }
-
- @Override
- public void split(TableName tableName) throws IOException {
-
- }
-
- @Override
- public void split(TableName tableName, byte[] splitPoint) throws IOException {
-
- }
-
- @Override
- public Future splitRegionAsync(byte[] regionName) throws IOException {
- return null;
- }
-
- @Override
- public Future splitRegionAsync(byte[] regionName, byte[] splitPoint) throws IOException {
- return null;
- }
-
- @Override
- public Future modifyTableAsync(TableDescriptor td) throws IOException {
- return null;
- }
-
- @Override
- public void shutdown() throws IOException {
-
- }
-
- @Override
- public void stopMaster() throws IOException {
-
- }
-
- @Override
- public boolean isMasterInMaintenanceMode() throws IOException {
- return false;
- }
-
- @Override
- public void stopRegionServer(String hostnamePort) throws IOException {
-
- }
-
- @Override
- public ClusterMetrics getClusterMetrics(EnumSet options)
- throws IOException {
- return null;
- }
-
- @Override
- public List getRegionMetrics(ServerName serverName) throws IOException {
- return null;
- }
-
- @Override
- public List getRegionMetrics(ServerName serverName, TableName tableName)
- throws IOException {
- return null;
- }
-
- @Override
- public Configuration getConfiguration() {
- return null;
- }
-
- @Override
- public Future createNamespaceAsync(NamespaceDescriptor descriptor) throws IOException {
- return null;
- }
-
- @Override
- public Future modifyNamespaceAsync(NamespaceDescriptor descriptor) throws IOException {
- return null;
- }
-
- @Override
- public Future deleteNamespaceAsync(String name) throws IOException {
- return null;
- }
-
- @Override
- public NamespaceDescriptor getNamespaceDescriptor(String name)
- throws NamespaceNotFoundException, IOException {
- return null;
- }
-
- @Override
- public String[] listNamespaces() throws IOException {
- return new String[0];
- }
-
- @Override
- public NamespaceDescriptor[] listNamespaceDescriptors() throws IOException {
- return new NamespaceDescriptor[0];
- }
-
- @Override
- public List listTableDescriptorsByNamespace(byte[] name) throws IOException {
- return null;
- }
-
- @Override
- public TableName[] listTableNamesByNamespace(String name) throws IOException {
- return new TableName[0];
- }
-
- @Override
- public List getRegions(TableName tableName) throws IOException {
- return null;
- }
-
- @Override
- public void close() {
-
- }
-
- @Override
- public List listTableDescriptors(List tableNames) throws IOException {
- return null;
- }
-
- @Override
- public Future abortProcedureAsync(long procId, boolean mayInterruptIfRunning)
- throws IOException {
- return null;
- }
-
- @Override
- public String getProcedures() throws IOException {
- return null;
- }
-
- @Override
- public String getLocks() throws IOException {
- return null;
- }
-
- @Override
- public void rollWALWriter(ServerName serverName) throws IOException, FailedLogCloseException {
-
- }
-
- @Override
- public CompactionState getCompactionState(TableName tableName) throws IOException {
- return null;
- }
-
- @Override
- public CompactionState getCompactionState(TableName tableName, CompactType compactType)
- throws IOException {
- return null;
- }
-
- @Override
- public CompactionState getCompactionStateForRegion(byte[] regionName) throws IOException {
- return null;
- }
-
- @Override
- public long getLastMajorCompactionTimestamp(TableName tableName) throws IOException {
- return 0;
- }
-
- @Override
- public long getLastMajorCompactionTimestampForRegion(byte[] regionName) throws IOException {
- return 0;
- }
-
- @Override
- public void snapshot(SnapshotDescription snapshot)
- throws IOException, SnapshotCreationException, IllegalArgumentException {
-
- }
-
- @Override
- public Future snapshotAsync(SnapshotDescription snapshot)
- throws IOException, SnapshotCreationException {
- return null;
- }
-
- @Override
- public boolean isSnapshotFinished(SnapshotDescription snapshot)
- throws IOException, HBaseSnapshotException, UnknownSnapshotException {
- return false;
- }
-
- @Override
- public void restoreSnapshot(String snapshotName) throws IOException, RestoreSnapshotException {
-
- }
-
- @Override
- public void restoreSnapshot(String snapshotName, boolean takeFailSafeSnapshot, boolean restoreAcl)
- throws IOException, RestoreSnapshotException {
-
- }
-
- @Override
- public Future cloneSnapshotAsync(String snapshotName, TableName tableName,
- boolean restoreAcl) throws IOException, TableExistsException, RestoreSnapshotException {
- return null;
- }
-
- @Override
- public void execProcedure(String signature, String instance, Map props)
- throws IOException {
-
- }
-
- @Override
- public byte[] execProcedureWithReturn(String signature, String instance,
- Map props) throws IOException {
- return new byte[0];
- }
-
- @Override
- public boolean isProcedureFinished(String signature, String instance, Map props)
- throws IOException {
- return false;
- }
-
- @Override
- public List listSnapshots() throws IOException {
- return null;
- }
-
- @Override
- public List listSnapshots(Pattern pattern) throws IOException {
- return null;
- }
-
- @Override
- public List listTableSnapshots(Pattern tableNamePattern,
- Pattern snapshotNamePattern) throws IOException {
- return null;
- }
-
- @Override
- public void deleteSnapshot(String snapshotName) throws IOException {
-
- }
-
- @Override
- public void deleteSnapshots(Pattern pattern) throws IOException {
-
- }
-
- @Override
- public void deleteTableSnapshots(Pattern tableNamePattern, Pattern snapshotNamePattern)
- throws IOException {
-
- }
-
- @Override
- public void setQuota(QuotaSettings quota) throws IOException {
-
- }
-
- @Override
- public List getQuota(QuotaFilter filter) throws IOException {
- return null;
- }
-
- @Override
- public CoprocessorRpcChannel coprocessorService() {
- return null;
- }
-
- @Override
- public CoprocessorRpcChannel coprocessorService(ServerName serverName) {
- return null;
- }
-
- @Override
- public void updateConfiguration(ServerName server) throws IOException {
-
- }
-
- @Override
- public void updateConfiguration() throws IOException {
-
- }
-
- @Override
- public List getSecurityCapabilities() throws IOException {
- return null;
- }
-
- @Override
- public boolean splitSwitch(boolean enabled, boolean synchronous) throws IOException {
- return false;
- }
-
- @Override
- public boolean mergeSwitch(boolean enabled, boolean synchronous) throws IOException {
- return false;
- }
-
- @Override
- public boolean isSplitEnabled() throws IOException {
- return false;
- }
-
- @Override
- public boolean isMergeEnabled() throws IOException {
- return false;
- }
-
- @Override
- public Future addReplicationPeerAsync(String peerId, ReplicationPeerConfig peerConfig,
- boolean enabled) throws IOException {
- return null;
- }
-
- @Override
- public Future removeReplicationPeerAsync(String peerId) throws IOException {
- return null;
- }
-
- @Override
- public Future enableReplicationPeerAsync(String peerId) throws IOException {
- return null;
- }
-
- @Override
- public Future disableReplicationPeerAsync(String peerId) throws IOException {
- return null;
- }
-
- @Override
- public ReplicationPeerConfig getReplicationPeerConfig(String peerId) throws IOException {
- return null;
- }
-
- @Override
- public Future updateReplicationPeerConfigAsync(String peerId,
- ReplicationPeerConfig peerConfig) throws IOException {
- return null;
- }
-
- @Override
- public List listReplicationPeers() throws IOException {
- return null;
- }
-
- @Override
- public List listReplicationPeers(Pattern pattern) throws IOException {
- return null;
- }
-
- @Override
- public Future transitReplicationPeerSyncReplicationStateAsync(String peerId,
- SyncReplicationState state) throws IOException {
- return null;
- }
-
- @Override
- public void decommissionRegionServers(List servers, boolean offload)
- throws IOException {
-
- }
-
- @Override
- public List listDecommissionedRegionServers() throws IOException {
- return null;
- }
-
- @Override
- public void recommissionRegionServer(ServerName server, List encodedRegionNames)
- throws IOException {
-
- }
-
- @Override
- public List listReplicatedTableCFs() throws IOException {
- return null;
- }
-
- @Override
- public void enableTableReplication(TableName tableName) throws IOException {
-
- }
-
- @Override
- public void disableTableReplication(TableName tableName) throws IOException {
-
- }
-
- @Override
- public void clearCompactionQueues(ServerName serverName, Set queues)
- throws IOException, InterruptedException {
-
- }
-
- @Override
- public List clearDeadServers(List servers) throws IOException {
- return null;
- }
-
- @Override
- public void cloneTableSchema(TableName tableName, TableName newTableName, boolean preserveSplits)
- throws IOException {
-
- }
-
- @Override
- public boolean switchRpcThrottle(boolean enable) throws IOException {
- return false;
- }
-
- @Override
- public boolean isRpcThrottleEnabled() throws IOException {
- return false;
- }
-
- @Override
- public boolean exceedThrottleQuotaSwitch(boolean enable) throws IOException {
- return false;
- }
-
- @Override
- public Map getSpaceQuotaTableSizes() throws IOException {
- return null;
- }
-
- @Override
- public Map getRegionServerSpaceQuotaSnapshots(
- ServerName serverName) throws IOException {
- return null;
- }
-
- @Override
- public SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(String namespace) throws IOException {
- return null;
- }
-
- @Override
- public SpaceQuotaSnapshotView getCurrentSpaceQuotaSnapshot(TableName tableName)
- throws IOException {
- return null;
- }
-
- @Override
- public void grant(UserPermission userPermission, boolean mergeExistingPermissions)
- throws IOException {
-
- }
-
- @Override
- public void revoke(UserPermission userPermission) throws IOException {
-
- }
-
- @Override
- public List getUserPermissions(
- GetUserPermissionsRequest getUserPermissionsRequest) throws IOException {
- return null;
- }
-
- @Override
- public List hasUserPermissions(String userName, List permissions)
- throws IOException {
- return null;
- }
-
- @Override
- public boolean snapshotCleanupSwitch(boolean on, boolean synchronous) throws IOException {
- return false;
- }
-
- @Override
- public boolean isSnapshotCleanupEnabled() throws IOException {
- return false;
- }
-
- @Override
+ /**
+ * Gets {@code RSGroupInfo} for given group name.
+ */
public RSGroupInfo getRSGroupInfo(String groupName) throws IOException {
- return getRSGroup(groupName);
- }
-
- @Override
- public void moveServers(Set servers, String targetGroup) throws IOException {
- moveToRSGroup(servers, targetGroup);
- }
-
- @Override
- public void addRSGroup(String groupName) throws IOException {
- AddRSGroupRequest request = AddRSGroupRequest.newBuilder().setRSGroupName(groupName).build();
- try {
- stub.addRSGroup(null, request);
- } catch (ServiceException e) {
- throw ProtobufUtil.handleRemoteException(e);
- }
- }
-
- @Override
- public RSGroupInfo getRSGroup(String groupName) throws IOException {
try {
GetRSGroupInfoResponse resp = stub.getRSGroupInfo(null,
- GetRSGroupInfoRequest.newBuilder().setRSGroupName(groupName).build());
+ GetRSGroupInfoRequest.newBuilder().setRSGroupName(groupName).build());
if (resp.hasRSGroupInfo()) {
return ProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
}
@@ -957,26 +80,12 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
}
}
- @Override
- public RSGroupInfo getRSGroup(Address hostPort) throws IOException {
- GetRSGroupInfoOfServerRequest request = GetRSGroupInfoOfServerRequest.newBuilder().setServer(
- HBaseProtos.ServerName.newBuilder().setHostName(hostPort.getHostname())
- .setPort(hostPort.getPort()).build()).build();
- try {
- GetRSGroupInfoOfServerResponse resp = stub.getRSGroupInfoOfServer(null, request);
- if (resp.hasRSGroupInfo()) {
- return ProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
- }
- return null;
- } catch (ServiceException e) {
- throw ProtobufUtil.handleRemoteException(e);
- }
- }
-
- @Override
- public RSGroupInfo getRSGroup(TableName tableName) throws IOException {
+ /**
+ * Gets {@code RSGroupInfo} for the given table's group.
+ */
+ public RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException {
GetRSGroupInfoOfTableRequest request = GetRSGroupInfoOfTableRequest.newBuilder()
- .setTableName(ProtobufUtil.toProtoTableName(tableName)).build();
+ .setTableName(ProtobufUtil.toProtoTableName(tableName)).build();
try {
GetRSGroupInfoOfTableResponse resp = stub.getRSGroupInfoOfTable(null, request);
if (resp.hasRSGroupInfo()) {
@@ -988,44 +97,17 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
}
}
- @Override
- public void removeRSGroup(String name) throws IOException {
- RemoveRSGroupRequest request = RemoveRSGroupRequest.newBuilder().setRSGroupName(name).build();
- try {
- stub.removeRSGroup(null, request);
- } catch (ServiceException e) {
- throw ProtobufUtil.handleRemoteException(e);
- }
- }
-
- @Override
- public void removeRSGroup(Set servers) throws IOException {
+ /**
+ * Move given set of servers to the specified target RegionServer group.
+ */
+ public void moveServers(Set servers, String targetGroup) throws IOException {
Set hostPorts = Sets.newHashSet();
for (Address el : servers) {
- hostPorts.add(
- HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname()).setPort(el.getPort())
- .build());
- }
- RemoveServersRequest request =
- RemoveServersRequest.newBuilder().addAllServers(hostPorts).build();
- try {
- stub.removeServers(null, request);
- } catch (ServiceException e) {
- throw ProtobufUtil.handleRemoteException(e);
- }
- }
-
- @Override
- public void moveToRSGroup(Set servers, String targetGroup) throws IOException {
- Set hostPorts = Sets.newHashSet();
- for (Address el : servers) {
- hostPorts.add(
- HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname()).setPort(el.getPort())
- .build());
+ hostPorts.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
+ .setPort(el.getPort()).build());
}
MoveServersRequest request =
- MoveServersRequest.newBuilder().setTargetGroup(targetGroup).addAllServers(hostPorts)
- .build();
+ MoveServersRequest.newBuilder().setTargetGroup(targetGroup).addAllServers(hostPorts).build();
try {
stub.moveServers(null, request);
} catch (ServiceException e) {
@@ -1033,9 +115,12 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
}
}
- @Override
- public void setRSGroup(Set tables, String groupName) throws IOException {
- MoveTablesRequest.Builder builder = MoveTablesRequest.newBuilder().setTargetGroup(groupName);
+ /**
+ * Move given set of tables to the specified target RegionServer group. This will unassign all of
+ * a table's region so it can be reassigned to the correct group.
+ */
+ public void moveTables(Set tables, String targetGroup) throws IOException {
+ MoveTablesRequest.Builder builder = MoveTablesRequest.newBuilder().setTargetGroup(targetGroup);
for (TableName tableName : tables) {
builder.addTableName(ProtobufUtil.toProtoTableName(tableName));
if (!admin.tableExists(tableName)) {
@@ -1049,10 +134,37 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
}
}
- @Override
+ /**
+ * Creates a new RegionServer group with the given name.
+ */
+ public void addRSGroup(String groupName) throws IOException {
+ AddRSGroupRequest request = AddRSGroupRequest.newBuilder().setRSGroupName(groupName).build();
+ try {
+ stub.addRSGroup(null, request);
+ } catch (ServiceException e) {
+ throw ProtobufUtil.handleRemoteException(e);
+ }
+ }
+
+ /**
+ * Removes RegionServer group associated with the given name.
+ */
+ public void removeRSGroup(String name) throws IOException {
+ RemoveRSGroupRequest request = RemoveRSGroupRequest.newBuilder().setRSGroupName(name).build();
+ try {
+ stub.removeRSGroup(null, request);
+ } catch (ServiceException e) {
+ throw ProtobufUtil.handleRemoteException(e);
+ }
+ }
+
+ /**
+ * Balance regions in the given RegionServer group.
+ * @return boolean Whether balance ran or not
+ */
public boolean balanceRSGroup(String groupName) throws IOException {
BalanceRSGroupRequest request =
- BalanceRSGroupRequest.newBuilder().setRSGroupName(groupName).build();
+ BalanceRSGroupRequest.newBuilder().setRSGroupName(groupName).build();
try {
return stub.balanceRSGroup(null, request).getBalanceRan();
} catch (ServiceException e) {
@@ -1060,12 +172,13 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
}
}
- @Override
+ /**
+ * Lists current set of RegionServer groups.
+ */
public List listRSGroups() throws IOException {
try {
- List resp =
- stub.listRSGroupInfos(null, ListRSGroupInfosRequest.getDefaultInstance())
- .getRSGroupInfoList();
+ List resp = stub
+ .listRSGroupInfos(null, ListRSGroupInfosRequest.getDefaultInstance()).getRSGroupInfoList();
List result = new ArrayList<>(resp.size());
for (RSGroupProtos.RSGroupInfo entry : resp) {
result.add(ProtobufUtil.toGroupInfo(entry));
@@ -1076,24 +189,72 @@ public class RSGroupAdminClient implements RSGroupAdmin, Admin {
}
}
- @Override
+ /**
+ * Retrieve the RSGroupInfo a server is affiliated to
+ * @param hostPort HostPort to get RSGroupInfo for
+ */
public RSGroupInfo getRSGroupOfServer(Address hostPort) throws IOException {
- return getRSGroup(hostPort);
+ GetRSGroupInfoOfServerRequest request =
+ GetRSGroupInfoOfServerRequest.newBuilder().setServer(HBaseProtos.ServerName.newBuilder()
+ .setHostName(hostPort.getHostname()).setPort(hostPort.getPort()).build()).build();
+ try {
+ GetRSGroupInfoOfServerResponse resp = stub.getRSGroupInfoOfServer(null, request);
+ if (resp.hasRSGroupInfo()) {
+ return ProtobufUtil.toGroupInfo(resp.getRSGroupInfo());
+ }
+ return null;
+ } catch (ServiceException e) {
+ throw ProtobufUtil.handleRemoteException(e);
+ }
}
- @Override
+ /**
+ * Move given set of servers and tables to the specified target RegionServer group.
+ * @param servers set of servers to move
+ * @param tables set of tables to move
+ * @param targetGroup the target group name
+ * @throws IOException if moving the server and tables fail
+ */
+ public void moveServersAndTables(Set servers, Set tables, String targetGroup)
+ throws IOException {
+ MoveServersAndTablesRequest.Builder builder =
+ MoveServersAndTablesRequest.newBuilder().setTargetGroup(targetGroup);
+ for (Address el : servers) {
+ builder.addServers(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
+ .setPort(el.getPort()).build());
+ }
+ for (TableName tableName : tables) {
+ builder.addTableName(ProtobufUtil.toProtoTableName(tableName));
+ if (!admin.tableExists(tableName)) {
+ throw new TableNotFoundException(tableName);
+ }
+ }
+ try {
+ stub.moveServersAndTables(null, builder.build());
+ } catch (ServiceException e) {
+ throw ProtobufUtil.handleRemoteException(e);
+ }
+ }
+
+ /**
+ * Remove decommissioned servers from rsgroup. 1. Sometimes we may find the server aborted due to
+ * some hardware failure and we must offline the server for repairing. Or we need to move some
+ * servers to join other clusters. So we need to remove these servers from the rsgroup. 2.
+ * Dead/recovering/live servers will be disallowed.
+ * @param servers set of servers to remove
+ */
public void removeServers(Set servers) throws IOException {
- removeRSGroup(servers);
- }
-
- @Override
- public List getSlowLogResponses(Set serverNames,
- SlowLogQueryFilter slowLogQueryFilter) throws IOException {
- return null;
- }
-
- @Override
- public List clearSlowLogResponses(Set serverNames) throws IOException {
- return null;
+ Set hostPorts = Sets.newHashSet();
+ for (Address el : servers) {
+ hostPorts.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
+ .setPort(el.getPort()).build());
+ }
+ RemoveServersRequest request =
+ RemoveServersRequest.newBuilder().addAllServers(hostPorts).build();
+ try {
+ stub.removeServers(null, request);
+ } catch (ServiceException e) {
+ throw ProtobufUtil.handleRemoteException(e);
+ }
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java
new file mode 100644
index 00000000000..dc3144f3718
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/EnableRSGroupsTestBase.java
@@ -0,0 +1,80 @@
+/**
+ * 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 static java.lang.Thread.sleep;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class EnableRSGroupsTestBase {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TestEnableRSGroupsCompatibility.class);
+
+ private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ final Configuration conf = TEST_UTIL.getConfiguration();
+ conf.setBoolean(CoprocessorHost.COPROCESSORS_ENABLED_CONF_KEY, true);
+ TEST_UTIL.startMiniCluster(5);
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ LOG.info("to stop miniCluster");
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ protected abstract void enableRSGroup(Configuration conf);
+
+ @Test
+ public void testEnableRSGroup() throws IOException, InterruptedException {
+ TEST_UTIL.getMiniHBaseCluster().stopMaster(0);
+ TEST_UTIL.getMiniHBaseCluster().waitOnMaster(0);
+
+ LOG.info("stopped master...");
+ enableRSGroup(TEST_UTIL.getMiniHBaseCluster().getConfiguration());
+
+ TEST_UTIL.getMiniHBaseCluster().startMaster();
+ TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(60000);
+ LOG.info("started master...");
+
+ // check if master started successfully
+ assertTrue(TEST_UTIL.getMiniHBaseCluster().getMaster() != null);
+
+ // wait RSGroupBasedLoadBalancer online
+ RSGroupBasedLoadBalancer loadBalancer =
+ (RSGroupBasedLoadBalancer) TEST_UTIL.getMiniHBaseCluster().getMaster().getLoadBalancer();
+ long start = System.currentTimeMillis();
+ while (System.currentTimeMillis() - start <= 60000 && !loadBalancer.isOnline()) {
+ LOG.info("waiting for rsgroup load balancer onLine...");
+ sleep(200);
+ }
+
+ assertTrue(loadBalancer.isOnline());
+ }
+}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java
index d15c7a89f86..72dacb59ff6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroups.java
@@ -17,80 +17,23 @@
*/
package org.apache.hadoop.hbase.rsgroup;
-import static java.lang.Thread.sleep;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.junit.ClassRule;
-import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-/**
- * Test enable RSGroup
- */
-@Category({ MediumTests.class })
-public class TestEnableRSGroups {
+@Category({ RSGroupTests.class, MediumTests.class })
+public class TestEnableRSGroups extends EnableRSGroupsTestBase {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestEnableRSGroups.class);
+ HBaseClassTestRule.forClass(TestEnableRSGroups.class);
- protected static final Logger LOG = LoggerFactory.getLogger(TestEnableRSGroups.class);
-
- private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
-
- @BeforeClass
- public static void setUp() throws Exception {
- final Configuration conf = TEST_UTIL.getConfiguration();
- conf.setBoolean(CoprocessorHost.COPROCESSORS_ENABLED_CONF_KEY, true);
- TEST_UTIL.startMiniCluster(5);
- }
-
- @AfterClass
- public static void tearDown() throws Exception {
- LOG.info("to stop miniCluster");
- TEST_UTIL.shutdownMiniCluster();
- }
-
- @Test
- public void testEnableRSGroup() throws IOException, InterruptedException {
- TEST_UTIL.getMiniHBaseCluster().stopMaster(0);
- TEST_UTIL.getMiniHBaseCluster().waitOnMaster(0);
-
- LOG.info("stopped master...");
- final Configuration conf = TEST_UTIL.getMiniHBaseCluster().getConfiguration();
- conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName());
- conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS,
- RSGroupBasedLoadBalancer.class.getName());
-
- TEST_UTIL.getMiniHBaseCluster().startMaster();
- TEST_UTIL.getMiniHBaseCluster().waitForActiveAndReadyMaster(60000);
- LOG.info("started master...");
-
- // check if master started successfully
- assertTrue(TEST_UTIL.getMiniHBaseCluster().getMaster() != null);
-
- // wait RSGroupBasedLoadBalancer online
- RSGroupBasedLoadBalancer loadBalancer =
- (RSGroupBasedLoadBalancer) TEST_UTIL.getMiniHBaseCluster().getMaster().getLoadBalancer();
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start <= 60000 && !loadBalancer.isOnline()) {
- LOG.info("waiting for rsgroup load balancer onLine...");
- sleep(200);
- }
-
- assertTrue(loadBalancer.isOnline());
+ @Override
+ protected void enableRSGroup(Configuration conf) {
+ conf.setBoolean(RSGroupInfoManager.RS_GROUP_ENABLED, true);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java
new file mode 100644
index 00000000000..92faa5bd9d8
--- /dev/null
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestEnableRSGroupsCompatibility.java
@@ -0,0 +1,45 @@
+/**
+ * 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 org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
+import org.junit.ClassRule;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Test enable RSGroup using the old coprocessor way, to make sure that we keep compatible with old
+ * config way.
+ */
+@Category({ RSGroupTests.class, MediumTests.class })
+public class TestEnableRSGroupsCompatibility extends EnableRSGroupsTestBase {
+
+ @ClassRule
+ public static final HBaseClassTestRule CLASS_RULE =
+ HBaseClassTestRule.forClass(TestEnableRSGroupsCompatibility.class);
+
+ @Override
+ protected void enableRSGroup(Configuration conf) {
+ conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName());
+ conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, RSGroupBasedLoadBalancer.class.getName());
+ }
+}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java
index 2b43f3e887c..f4433600231 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestMigrateRSGroupInfo.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.RSGroupProtos;
import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.zookeeper.KeeperException;
import org.junit.After;
@@ -46,14 +47,11 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
/**
* Testcase for HBASE-22819
*/
-@RunWith(Parameterized.class)
-@Category({ MediumTests.class })
+@Category({ RSGroupTests.class, MediumTests.class })
public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
@ClassRule
@@ -109,10 +107,9 @@ public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
@Test
public void testMigrate() throws IOException, InterruptedException {
- setAdmin();
String groupName = getNameWithoutIndex(name.getMethodName());
addGroup(groupName, TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().size() - 1);
- RSGroupInfo rsGroupInfo = rsGroupAdmin.getRSGroup(groupName);
+ RSGroupInfo rsGroupInfo = ADMIN.getRSGroup(groupName);
assertTrue(rsGroupInfo.getTables().isEmpty());
for (int i = 0; i < NUM_TABLES; i++) {
rsGroupInfo.addTable(TableName.valueOf(TABLE_NAME_PREFIX + i));
@@ -131,7 +128,7 @@ public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
// wait until we can get the rs group info for a table
TEST_UTIL.waitFor(30000, () -> {
try {
- rsGroupAdmin.getRSGroup(TableName.valueOf(TABLE_NAME_PREFIX + 0));
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfoOfTable(TableName.valueOf(TABLE_NAME_PREFIX + 0));
return true;
} catch (IOException e) {
return false;
@@ -140,7 +137,7 @@ public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
// confirm that before migrating, we could still get the correct rs group for a table.
for (int i = 0; i < NUM_TABLES; i++) {
RSGroupInfo info =
- rsGroupAdmin.getRSGroup(TableName.valueOf(TABLE_NAME_PREFIX + i));
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfoOfTable(TableName.valueOf(TABLE_NAME_PREFIX + i));
assertEquals(rsGroupInfo.getName(), info.getName());
assertEquals(NUM_TABLES, info.getTables().size());
}
@@ -176,7 +173,7 @@ public class TestMigrateRSGroupInfo extends TestRSGroupsBase {
// make sure we could still get the correct rs group info after migration
for (int i = 0; i < NUM_TABLES; i++) {
RSGroupInfo info =
- rsGroupAdmin.getRSGroup(TableName.valueOf(TABLE_NAME_PREFIX + i));
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfoOfTable(TableName.valueOf(TABLE_NAME_PREFIX + i));
assertEquals(rsGroupInfo.getName(), info.getName());
assertEquals(NUM_TABLES, info.getTables().size());
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMajorCompactionTTL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMajorCompactionTTL.java
index 9b3dcbbc39e..6725cf0e2cb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMajorCompactionTTL.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupMajorCompactionTTL.java
@@ -6,38 +6,41 @@
* 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
+ *
+ * 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 static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.Waiter;
-import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.ServerManager;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.compaction.TestMajorCompactorTTL;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
+@Category({ RSGroupTests.class, MediumTests.class })
public class TestRSGroupMajorCompactionTTL extends TestMajorCompactorTTL {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
@@ -50,8 +53,7 @@ public class TestRSGroupMajorCompactionTTL extends TestMajorCompactorTTL {
public void setUp() throws Exception {
utility = new HBaseTestingUtility();
Configuration conf = utility.getConfiguration();
- conf.set(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, RSGroupBasedLoadBalancer.class.getName());
- conf.set(CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, RSGroupAdminEndpoint.class.getName());
+ conf.setBoolean(RSGroupInfoManager.RS_GROUP_ENABLED, true);
conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, NUM_SLAVES_BASE);
conf.setInt("hbase.hfile.compaction.discharger.interval", 10);
utility.startMiniCluster(NUM_SLAVES_BASE);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
index 614b6c4595e..255f80d2b1e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin1.java
@@ -24,13 +24,11 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableExistsException;
@@ -45,31 +43,28 @@ import org.apache.hadoop.hbase.constraint.ConstraintException;
import org.apache.hadoop.hbase.master.TableNamespaceManager;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
-@RunWith(Parameterized.class)
-@Category({ MediumTests.class })
+@Category({ RSGroupTests.class, MediumTests.class })
public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestRSGroupsAdmin1.class);
- protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsAdmin1.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsAdmin1.class);
@BeforeClass
public static void setUp() throws Exception {
@@ -98,7 +93,7 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
for (String entry : badNames) {
try {
- rsGroupAdmin.addRSGroup(entry);
+ ADMIN.addRSGroup(entry);
fail("Expected a constraint exception for: " + entry);
} catch (ConstraintException ex) {
// expected
@@ -106,42 +101,41 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
}
for (String entry : goodNames) {
- rsGroupAdmin.addRSGroup(entry);
+ ADMIN.addRSGroup(entry);
}
}
@Test
public void testBogusArgs() throws Exception {
- assertNull(rsGroupAdmin.getRSGroup(TableName.valueOf("nonexistent")));
- assertNull(rsGroupAdmin.getRSGroup(Address.fromParts("bogus", 123)));
- assertNull(rsGroupAdmin.getRSGroup("bogus"));
+ assertNull(ADMIN.getRSGroup(TableName.valueOf("nonexistent")));
+ assertNull(ADMIN.getRSGroup(Address.fromParts("bogus", 123)));
+ assertNull(ADMIN.getRSGroup("bogus"));
try {
- rsGroupAdmin.removeRSGroup("bogus");
+ ADMIN.removeRSGroup("bogus");
fail("Expected removing bogus group to fail");
} catch (ConstraintException ex) {
// expected
}
try {
- rsGroupAdmin.setRSGroup(Sets.newHashSet(TableName.valueOf("bogustable")), "bogus");
+ ADMIN.setRSGroup(Sets.newHashSet(TableName.valueOf("bogustable")), "bogus");
fail("Expected set table to bogus group fail");
} catch (ConstraintException | TableNotFoundException ex) {
// expected
}
try {
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(Address.fromParts("bogus", 123)),
- "bogus");
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(Address.fromParts("bogus", 123)), "bogus");
fail("Expected move with bogus group to fail");
} catch (ConstraintException ex) {
// expected
}
try {
- admin.balancerSwitch(true, true);
- rsGroupAdmin.balanceRSGroup("bogus");
- admin.balancerSwitch(false, true);
+ ADMIN.balancerSwitch(true, true);
+ ADMIN.balanceRSGroup("bogus");
+ ADMIN.balancerSwitch(false, true);
fail("Expected move with bogus group to fail");
} catch (ConstraintException ex) {
// expected
@@ -150,127 +144,81 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
@Test
public void testNamespaceConstraint() throws Exception {
- String nsName = tablePrefix + "_foo";
- String groupName = tablePrefix + "_foo";
+ String nsName = TABLE_PREFIX + "_foo";
+ String groupName = TABLE_PREFIX + "_foo";
LOG.info("testNamespaceConstraint");
addGroup(groupName, 1);
- assertTrue(observer.preAddRSGroupCalled);
- assertTrue(observer.postAddRSGroupCalled);
+ assertTrue(OBSERVER.preAddRSGroupCalled);
+ assertTrue(OBSERVER.postAddRSGroupCalled);
- admin.createNamespace(NamespaceDescriptor.create(nsName)
+ ADMIN.createNamespace(NamespaceDescriptor.create(nsName)
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, groupName).build());
- RSGroupInfo rsGroupInfo = rsGroupAdmin.getRSGroup(groupName);
- rsGroupAdmin.moveToRSGroup(rsGroupInfo.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ RSGroupInfo rsGroupInfo = ADMIN.getRSGroup(groupName);
+ ADMIN.moveServersToRSGroup(rsGroupInfo.getServers(), RSGroupInfo.DEFAULT_GROUP);
// test removing a referenced group
try {
- rsGroupAdmin.removeRSGroup(groupName);
+ ADMIN.removeRSGroup(groupName);
fail("Expected a constraint exception");
} catch (IOException ex) {
}
// test modify group
// changing with the same name is fine
- admin.modifyNamespace(NamespaceDescriptor.create(nsName)
+ ADMIN.modifyNamespace(NamespaceDescriptor.create(nsName)
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, groupName).build());
- String anotherGroup = tablePrefix + "_anotherGroup";
- rsGroupAdmin.addRSGroup(anotherGroup);
+ String anotherGroup = TABLE_PREFIX + "_anotherGroup";
+ ADMIN.addRSGroup(anotherGroup);
// test add non-existent group
- admin.deleteNamespace(nsName);
- rsGroupAdmin.removeRSGroup(groupName);
- assertTrue(observer.preRemoveRSGroupCalled);
- assertTrue(observer.postRemoveRSGroupCalled);
+ ADMIN.deleteNamespace(nsName);
+ ADMIN.removeRSGroup(groupName);
+ assertTrue(OBSERVER.preRemoveRSGroupCalled);
+ assertTrue(OBSERVER.postRemoveRSGroupCalled);
try {
- admin.createNamespace(NamespaceDescriptor.create(nsName)
+ ADMIN.createNamespace(NamespaceDescriptor.create(nsName)
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, "foo").build());
fail("Expected a constraint exception");
} catch (IOException ex) {
}
}
- @Test
- public void testGroupInfoMultiAccessing() throws Exception {
- RSGroupInfoManager manager = rsGroupAdminEndpoint.getGroupInfoManager();
- RSGroupInfo defaultGroup = manager.getRSGroup("default");
- // getRSGroup updates default group's server list
- // this process must not affect other threads iterating the list
- Iterator it = defaultGroup.getServers().iterator();
- manager.getRSGroup("default");
- it.next();
- }
-
- @Test
- public void testGetRSGroupInfoCPHookCalled() throws Exception {
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
- if (rsGroupAdmin instanceof RSGroupAdminClient) {
- assertTrue(observer.preGetRSGroupInfoCalled);
- assertTrue(observer.postGetRSGroupInfoCalled);
- }
- }
-
- @Test
- public void testGetRSGroupInfoOfTableCPHookCalled() throws Exception {
- rsGroupAdmin.getRSGroup(TableName.META_TABLE_NAME);
- if (rsGroupAdmin instanceof RSGroupAdminClient) {
- assertTrue(observer.preGetRSGroupInfoOfTableCalled);
- assertTrue(observer.postGetRSGroupInfoOfTableCalled);
- }
- }
-
- @Test
- public void testListRSGroupsCPHookCalled() throws Exception {
- rsGroupAdmin.listRSGroups();
- assertTrue(observer.preListRSGroupsCalled);
- assertTrue(observer.postListRSGroupsCalled);
- }
-
- @Test
- public void testGetRSGroupInfoOfServerCPHookCalled() throws Exception {
- ServerName masterServerName = ((MiniHBaseCluster) cluster).getMaster().getServerName();
- rsGroupAdmin.getRSGroup(masterServerName.getAddress());
- if (rsGroupAdmin instanceof RSGroupAdminClient) {
- assertTrue(observer.preGetRSGroupInfoOfServerCalled);
- assertTrue(observer.postGetRSGroupInfoOfServerCalled);
- }
- }
-
@Test
public void testFailRemoveGroup() throws IOException, InterruptedException {
- int initNumGroups = rsGroupAdmin.listRSGroups().size();
+ int initNumGroups = ADMIN.listRSGroups().size();
addGroup("bar", 3);
TEST_UTIL.createTable(tableName, Bytes.toBytes("f"));
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), "bar");
- RSGroupInfo barGroup = rsGroupAdmin.getRSGroup("bar");
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), "bar");
+ RSGroupInfo barGroup = RS_GROUP_ADMIN_CLIENT.getRSGroupInfo("bar");
// group is not empty therefore it should fail
try {
- rsGroupAdmin.removeRSGroup(barGroup.getName());
+ ADMIN.removeRSGroup(barGroup.getName());
fail("Expected remove group to fail");
} catch (IOException e) {
}
// group cannot lose all it's servers therefore it should fail
try {
- rsGroupAdmin.moveToRSGroup(barGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.moveServersToRSGroup(barGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
fail("Expected move servers to fail");
} catch (IOException e) {
}
- rsGroupAdmin.setRSGroup(barGroup.getTables(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.setRSGroup(barGroup.getTables(), RSGroupInfo.DEFAULT_GROUP);
try {
- rsGroupAdmin.removeRSGroup(barGroup.getName());
+ ADMIN.removeRSGroup(barGroup.getName());
fail("Expected move servers to fail");
} catch (IOException e) {
}
- rsGroupAdmin.moveToRSGroup(barGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
- rsGroupAdmin.removeRSGroup(barGroup.getName());
+ ADMIN.moveServersToRSGroup(barGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.removeRSGroup(barGroup.getName());
- Assert.assertEquals(initNumGroups, rsGroupAdmin.listRSGroups().size());
+ assertEquals(initNumGroups, ADMIN.listRSGroups().size());
}
@Test
public void testMultiTableMove() throws Exception {
- final TableName tableNameA = TableName.valueOf(tablePrefix +
- getNameWithoutIndex(name.getMethodName()) + "A");
- final TableName tableNameB = TableName.valueOf(tablePrefix +
- getNameWithoutIndex(name.getMethodName()) + "B");
+ final TableName tableNameA =
+ TableName.valueOf(TABLE_PREFIX + getNameWithoutIndex(name.getMethodName()) + "A");
+ final TableName tableNameB =
+ TableName.valueOf(TABLE_PREFIX + getNameWithoutIndex(name.getMethodName()) + "B");
final byte[] familyNameBytes = Bytes.toBytes("f");
String newGroupName = getGroupName(getNameWithoutIndex(name.getMethodName()));
final RSGroupInfo newGroup = addGroup(newGroupName, 1);
@@ -293,30 +241,28 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
}
});
- RSGroupInfo tableGrpA = rsGroupAdmin.getRSGroup(tableNameA);
+ RSGroupInfo tableGrpA = ADMIN.getRSGroup(tableNameA);
assertTrue(tableGrpA.getName().equals(RSGroupInfo.DEFAULT_GROUP));
- RSGroupInfo tableGrpB = rsGroupAdmin.getRSGroup(tableNameB);
+ RSGroupInfo tableGrpB = ADMIN.getRSGroup(tableNameB);
assertTrue(tableGrpB.getName().equals(RSGroupInfo.DEFAULT_GROUP));
// change table's group
LOG.info("Moving table [" + tableNameA + "," + tableNameB + "] to " + newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableNameA, tableNameB), newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(tableNameA, tableNameB), newGroup.getName());
// verify group change
- Assert.assertEquals(newGroup.getName(),
- rsGroupAdmin.getRSGroup(tableNameA).getName());
+ assertEquals(newGroup.getName(), ADMIN.getRSGroup(tableNameA).getName());
- Assert.assertEquals(newGroup.getName(),
- rsGroupAdmin.getRSGroup(tableNameB).getName());
+ assertEquals(newGroup.getName(), ADMIN.getRSGroup(tableNameB).getName());
// verify tables' not exist in old group
- Set DefaultTables =
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getTables();
- assertFalse(DefaultTables.contains(tableNameA));
- assertFalse(DefaultTables.contains(tableNameB));
+ Set defaultTables =
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables();
+ assertFalse(defaultTables.contains(tableNameA));
+ assertFalse(defaultTables.contains(tableNameB));
// verify tables' exist in new group
- Set newGroupTables = rsGroupAdmin.getRSGroup(newGroupName).getTables();
+ Set newGroupTables = RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(newGroupName).getTables();
assertTrue(newGroupTables.contains(tableNameA));
assertTrue(newGroupTables.contains(tableNameB));
}
@@ -340,17 +286,16 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
}
});
- RSGroupInfo tableGrp = rsGroupAdmin.getRSGroup(tableName);
+ RSGroupInfo tableGrp = ADMIN.getRSGroup(tableName);
LOG.info("got table group info is {}", tableGrp);
assertTrue(tableGrp.getName().equals(RSGroupInfo.DEFAULT_GROUP));
// change table's group
LOG.info("Moving table " + tableName + " to " + newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
// verify group change
- Assert.assertEquals(newGroup.getName(),
- rsGroupAdmin.getRSGroup(tableName).getName());
+ assertEquals(newGroup.getName(), ADMIN.getRSGroup(tableName).getName());
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
@@ -369,16 +314,15 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
});
// test truncate
- admin.disableTable(tableName);
- admin.truncateTable(tableName, true);
- Assert.assertEquals(1, rsGroupAdmin.getRSGroup(newGroup.getName()).getTables().size());
- Assert.assertEquals(tableName,
- rsGroupAdmin.getRSGroup(newGroup.getName()).getTables().first());
+ ADMIN.disableTable(tableName);
+ ADMIN.truncateTable(tableName, true);
+ assertEquals(1, RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(newGroup.getName()).getTables().size());
+ assertEquals(tableName,
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(newGroup.getName()).getTables().first());
// verify removed table is removed from group
TEST_UTIL.deleteTable(tableName);
- Assert.assertEquals(0, rsGroupAdmin.getRSGroup(newGroup.getName()).getTables().size());
-
+ assertEquals(0, RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(newGroup.getName()).getTables().size());
}
@Test
@@ -399,50 +343,49 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
}
});
- RSGroupInfo tableGrp = rsGroupAdmin.getRSGroup(tableName);
+ RSGroupInfo tableGrp = ADMIN.getRSGroup(tableName);
assertTrue(tableGrp.getName().equals(RSGroupInfo.DEFAULT_GROUP));
// test disable table
- admin.disableTable(tableName);
+ ADMIN.disableTable(tableName);
// change table's group
LOG.info("Moving table " + tableName + " to " + newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
// verify group change
- Assert.assertEquals(newGroup.getName(),
- rsGroupAdmin.getRSGroup(tableName).getName());
+ assertEquals(newGroup.getName(), ADMIN.getRSGroup(tableName).getName());
}
@Test
public void testNonExistentTableMove() throws Exception {
- TableName tableName = TableName.valueOf(tablePrefix +
- getNameWithoutIndex(name.getMethodName()));
- RSGroupInfo tableGrp = rsGroupAdmin.getRSGroup(tableName);
+ TableName tableName =
+ TableName.valueOf(TABLE_PREFIX + getNameWithoutIndex(name.getMethodName()));
+ RSGroupInfo tableGrp = ADMIN.getRSGroup(tableName);
assertNull(tableGrp);
// test if table exists already.
- boolean exist = admin.tableExists(tableName);
+ boolean exist = ADMIN.tableExists(tableName);
assertFalse(exist);
LOG.info("Moving table " + tableName + " to " + RSGroupInfo.DEFAULT_GROUP);
try {
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
fail("Table " + tableName + " shouldn't have been successfully moved.");
} catch (IOException ex) {
assertTrue(ex instanceof TableNotFoundException);
}
try {
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(Address.fromParts("bogus", 123)),
- RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(Address.fromParts("bogus", 123)),
+ RSGroupInfo.DEFAULT_GROUP);
fail("Table " + tableName + " shouldn't have been successfully moved.");
} catch (IOException ex) {
assertTrue(ex instanceof TableNotFoundException);
}
// verify group change
- assertNull(rsGroupAdmin.getRSGroup(tableName));
+ assertNull(ADMIN.getRSGroup(tableName));
}
@Test
@@ -452,13 +395,13 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
NamespaceDescriptor nspDesc =
NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_REGIONS, "5")
.addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "2").build();
- admin.createNamespace(nspDesc);
- assertEquals(3, admin.listNamespaceDescriptors().length);
+ ADMIN.createNamespace(nspDesc);
+ assertEquals(3, ADMIN.listNamespaceDescriptors().length);
ColumnFamilyDescriptor fam1 = ColumnFamilyDescriptorBuilder.of("fam1");
TableDescriptor tableDescOne = TableDescriptorBuilder
.newBuilder(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1"))
.setColumnFamily(fam1).build();
- admin.createTable(tableDescOne);
+ ADMIN.createTable(tableDescOne);
TableDescriptor tableDescTwo = TableDescriptorBuilder
.newBuilder(TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2"))
@@ -466,8 +409,8 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
boolean constraintViolated = false;
try {
- admin.createTable(tableDescTwo, Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 6);
- Assert.fail("Creation table should fail because of quota violation.");
+ ADMIN.createTable(tableDescTwo, Bytes.toBytes("AAA"), Bytes.toBytes("ZZZ"), 6);
+ fail("Creation table should fail because of quota violation.");
} catch (Exception exp) {
assertTrue(exp instanceof IOException);
constraintViolated = true;
@@ -475,7 +418,7 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
assertTrue("Constraint not violated for table " + tableDescTwo.getTableName(),
constraintViolated);
}
- List rsGroupInfoList = rsGroupAdmin.listRSGroups();
+ List rsGroupInfoList = RS_GROUP_ADMIN_CLIENT.listRSGroups();
boolean foundTable2 = false;
boolean foundTable1 = false;
for (int i = 0; i < rsGroupInfoList.size(); i++) {
@@ -490,14 +433,13 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
assertTrue("Did not find table1 in rsgroup list", foundTable1);
TEST_UTIL.deleteTable(tableDescOne.getTableName());
- admin.deleteNamespace(nspDesc.getName());
+ ADMIN.deleteNamespace(nspDesc.getName());
toggleQuotaCheckAndRestartMiniCluster(false);
}
@Test
- public void testNotMoveTableToNullRSGroupWhenCreatingExistingTable()
- throws Exception {
+ public void testNotMoveTableToNullRSGroupWhenCreatingExistingTable() throws Exception {
// Trigger
TableName tn1 = TableName.valueOf("t1");
TEST_UTIL.createTable(tn1, "cf1");
@@ -509,19 +451,18 @@ public class TestRSGroupsAdmin1 extends TestRSGroupsBase {
}
// Wait then verify
- // Could not verify until the rollback of CreateTableProcedure is done
- // (that is, the coprocessor finishes its work),
- // or the table is still in the "default" rsgroup even though HBASE-21866
- // is not fixed.
+ // Could not verify until the rollback of CreateTableProcedure is done
+ // (that is, the coprocessor finishes its work),
+ // or the table is still in the "default" rsgroup even though HBASE-21866
+ // is not fixed.
TEST_UTIL.waitFor(5000, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- return
- (master.getMasterProcedureExecutor().getActiveExecutorCount() == 0);
+ return (MASTER.getMasterProcedureExecutor().getActiveExecutorCount() == 0);
}
});
- SortedSet tables
- = rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getTables();
+ SortedSet tables =
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables();
assertTrue("Table 't1' must be in 'default' rsgroup", tables.contains(tn1));
// Cleanup
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
index eb808e38292..2faa7868325 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsAdmin2.java
@@ -44,33 +44,30 @@ import org.apache.hadoop.hbase.master.RegionState;
import org.apache.hadoop.hbase.master.assignment.RegionStateNode;
import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.testclassification.LargeTests;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.junit.After;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
-@RunWith(Parameterized.class)
-@Category({ LargeTests.class })
+@Category({ RSGroupTests.class, LargeTests.class })
public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestRSGroupsAdmin2.class);
- protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsAdmin2.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsAdmin2.class);
@BeforeClass
public static void setUp() throws Exception {
@@ -121,7 +118,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
// get server which is not a member of new group
ServerName tmpTargetServer = null;
- for (ServerName server : admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS))
+ for (ServerName server : ADMIN.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS))
.getLiveServerMetrics().keySet()) {
if (!newGroup.containsServer(server.getAddress())) {
tmpTargetServer = server;
@@ -130,11 +127,11 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
final ServerName targetServer = tmpTargetServer;
// move target server to group
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(targetServer.getAddress()), newGroup.getName());
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(targetServer.getAddress()), newGroup.getName());
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- return admin.getRegions(targetServer).size() <= 0;
+ return ADMIN.getRegions(targetServer).size() <= 0;
}
});
@@ -146,13 +143,13 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
public boolean evaluate() throws Exception {
return getTableRegionMap().get(tableName) != null &&
getTableRegionMap().get(tableName).size() == 6 &&
- admin.getClusterMetrics(EnumSet.of(Option.REGIONS_IN_TRANSITION))
+ ADMIN.getClusterMetrics(EnumSet.of(Option.REGIONS_IN_TRANSITION))
.getRegionStatesInTransition().size() < 1;
}
});
// verify that targetServer didn't open it
- for (RegionInfo region : admin.getRegions(targetServer)) {
+ for (RegionInfo region : ADMIN.getRegions(targetServer)) {
if (targetRegion.equals(region.getRegionNameAsString())) {
fail("Target server opened region");
}
@@ -161,35 +158,35 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
@Test
public void testRegionServerMove() throws IOException, InterruptedException {
- int initNumGroups = rsGroupAdmin.listRSGroups().size();
+ int initNumGroups = ADMIN.listRSGroups().size();
RSGroupInfo appInfo = addGroup(getGroupName(name.getMethodName()), 1);
RSGroupInfo adminInfo = addGroup(getGroupName(name.getMethodName()), 1);
- RSGroupInfo dInfo = rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
- Assert.assertEquals(initNumGroups + 2, rsGroupAdmin.listRSGroups().size());
+ RSGroupInfo dInfo = ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
+ assertEquals(initNumGroups + 2, ADMIN.listRSGroups().size());
assertEquals(1, adminInfo.getServers().size());
assertEquals(1, appInfo.getServers().size());
assertEquals(getNumServers() - 2, dInfo.getServers().size());
- rsGroupAdmin.moveToRSGroup(appInfo.getServers(), RSGroupInfo.DEFAULT_GROUP);
- rsGroupAdmin.removeRSGroup(appInfo.getName());
- rsGroupAdmin.moveToRSGroup(adminInfo.getServers(), RSGroupInfo.DEFAULT_GROUP);
- rsGroupAdmin.removeRSGroup(adminInfo.getName());
- Assert.assertEquals(rsGroupAdmin.listRSGroups().size(), initNumGroups);
+ ADMIN.moveServersToRSGroup(appInfo.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.removeRSGroup(appInfo.getName());
+ ADMIN.moveServersToRSGroup(adminInfo.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.removeRSGroup(adminInfo.getName());
+ assertEquals(ADMIN.listRSGroups().size(), initNumGroups);
}
@Test
public void testMoveServers() throws Exception {
// create groups and assign servers
addGroup("bar", 3);
- rsGroupAdmin.addRSGroup("foo");
+ ADMIN.addRSGroup("foo");
- RSGroupInfo barGroup = rsGroupAdmin.getRSGroup("bar");
- RSGroupInfo fooGroup = rsGroupAdmin.getRSGroup("foo");
+ RSGroupInfo barGroup = ADMIN.getRSGroup("bar");
+ RSGroupInfo fooGroup = ADMIN.getRSGroup("foo");
assertEquals(3, barGroup.getServers().size());
assertEquals(0, fooGroup.getServers().size());
// test fail bogus server move
try {
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(Address.fromString("foo:9999")), "foo");
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(Address.fromString("foo:9999")), "foo");
fail("Bogus servers shouldn't have been successfully moved.");
} catch (IOException ex) {
String exp = "Source RSGroup for server foo:9999 does not exist.";
@@ -199,34 +196,33 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
// test success case
LOG.info("moving servers " + barGroup.getServers() + " to group foo");
- rsGroupAdmin.moveToRSGroup(barGroup.getServers(), fooGroup.getName());
+ ADMIN.moveServersToRSGroup(barGroup.getServers(), fooGroup.getName());
- barGroup = rsGroupAdmin.getRSGroup("bar");
- fooGroup = rsGroupAdmin.getRSGroup("foo");
+ barGroup = ADMIN.getRSGroup("bar");
+ fooGroup = ADMIN.getRSGroup("foo");
assertEquals(0, barGroup.getServers().size());
assertEquals(3, fooGroup.getServers().size());
LOG.info("moving servers " + fooGroup.getServers() + " to group default");
- rsGroupAdmin.moveToRSGroup(fooGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.moveServersToRSGroup(fooGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- return getNumServers() == rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP)
- .getServers().size();
+ return getNumServers() == ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size();
}
});
- fooGroup = rsGroupAdmin.getRSGroup("foo");
+ fooGroup = ADMIN.getRSGroup("foo");
assertEquals(0, fooGroup.getServers().size());
// test group removal
LOG.info("Remove group " + barGroup.getName());
- rsGroupAdmin.removeRSGroup(barGroup.getName());
- Assert.assertEquals(null, rsGroupAdmin.getRSGroup(barGroup.getName()));
+ ADMIN.removeRSGroup(barGroup.getName());
+ assertEquals(null, ADMIN.getRSGroup(barGroup.getName()));
LOG.info("Remove group " + fooGroup.getName());
- rsGroupAdmin.removeRSGroup(fooGroup.getName());
- Assert.assertEquals(null, rsGroupAdmin.getRSGroup(fooGroup.getName()));
+ ADMIN.removeRSGroup(fooGroup.getName());
+ assertEquals(null, ADMIN.getRSGroup(fooGroup.getName()));
}
@Test
@@ -238,7 +234,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
// remove online servers
try {
- rsGroupAdmin.removeRSGroup(Sets.newHashSet(targetServer.getAddress()));
+ ADMIN.removeServersFromRSGroup(Sets.newHashSet(targetServer.getAddress()));
fail("Online servers shouldn't have been successfully removed.");
} catch (IOException ex) {
String exp =
@@ -249,12 +245,12 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
assertTrue(newGroup.getServers().contains(targetServer.getAddress()));
// remove dead servers
- NUM_DEAD_SERVERS = cluster.getClusterMetrics().getDeadServerNames().size();
+ NUM_DEAD_SERVERS = CLUSTER.getClusterMetrics().getDeadServerNames().size();
try {
// stopping may cause an exception
// due to the connection loss
LOG.info("stopping server " + targetServer.getServerName());
- admin.stopRegionServer(targetServer.getAddress().toString());
+ ADMIN.stopRegionServer(targetServer.getAddress().toString());
NUM_DEAD_SERVERS++;
} catch (Exception e) {
}
@@ -263,13 +259,13 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- return !master.getServerManager().areDeadServersInProgress() &&
- cluster.getClusterMetrics().getDeadServerNames().size() == NUM_DEAD_SERVERS;
+ return !MASTER.getServerManager().areDeadServersInProgress() &&
+ CLUSTER.getClusterMetrics().getDeadServerNames().size() == NUM_DEAD_SERVERS;
}
});
try {
- rsGroupAdmin.removeRSGroup(Sets.newHashSet(targetServer.getAddress()));
+ ADMIN.removeServersFromRSGroup(Sets.newHashSet(targetServer.getAddress()));
fail("Dead servers shouldn't have been successfully removed.");
} catch (IOException ex) {
String exp = "Server " + targetServer.getAddress() + " is on the dead servers list," +
@@ -282,20 +278,20 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
// remove decommissioned servers
List serversToDecommission = new ArrayList<>();
targetServer = getServerName(iterator.next());
- assertTrue(master.getServerManager().getOnlineServers().containsKey(targetServer));
+ assertTrue(MASTER.getServerManager().getOnlineServers().containsKey(targetServer));
serversToDecommission.add(targetServer);
- admin.decommissionRegionServers(serversToDecommission, true);
- assertEquals(1, admin.listDecommissionedRegionServers().size());
+ ADMIN.decommissionRegionServers(serversToDecommission, true);
+ assertEquals(1, ADMIN.listDecommissionedRegionServers().size());
assertTrue(newGroup.getServers().contains(targetServer.getAddress()));
- rsGroupAdmin.removeRSGroup(Sets.newHashSet(targetServer.getAddress()));
- Set newGroupServers = rsGroupAdmin.getRSGroup(newGroup.getName()).getServers();
+ ADMIN.removeServersFromRSGroup(Sets.newHashSet(targetServer.getAddress()));
+ Set newGroupServers = ADMIN.getRSGroup(newGroup.getName()).getServers();
assertFalse(newGroupServers.contains(targetServer.getAddress()));
assertEquals(2, newGroupServers.size());
- assertTrue(observer.preRemoveServersCalled);
- assertTrue(observer.postRemoveServersCalled);
+ assertTrue(OBSERVER.preRemoveServersCalled);
+ assertTrue(OBSERVER.postRemoveServersCalled);
}
@Test
@@ -319,26 +315,25 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
// get server which is not a member of new group
ServerName targetServer = null;
- for (ServerName server : admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS))
+ for (ServerName server : ADMIN.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS))
.getLiveServerMetrics().keySet()) {
if (!newGroup.containsServer(server.getAddress()) &&
- !rsGroupAdmin.getRSGroup("master").containsServer(server.getAddress())) {
+ !ADMIN.getRSGroup("master").containsServer(server.getAddress())) {
targetServer = server;
break;
}
}
- LOG.debug("Print group info : " + rsGroupAdmin.listRSGroups());
- int oldDefaultGroupServerSize =
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size();
+ LOG.debug("Print group info : " + ADMIN.listRSGroups());
+ int oldDefaultGroupServerSize = ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size();
int oldDefaultGroupTableSize =
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getTables().size();
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables().size();
// test fail bogus server move
try {
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(Address.fromString("foo:9999")),
- newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(Address.fromString("foo:9999")),
+ newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
fail("Bogus servers shouldn't have been successfully moved.");
} catch (IOException ex) {
String exp = "Source RSGroup for server foo:9999 does not exist.";
@@ -347,19 +342,19 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
// test move when src = dst
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(targetServer.getAddress()),
- RSGroupInfo.DEFAULT_GROUP);
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(targetServer.getAddress()),
+ RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), RSGroupInfo.DEFAULT_GROUP);
// verify default group info
- Assert.assertEquals(oldDefaultGroupServerSize,
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size());
- Assert.assertEquals(oldDefaultGroupTableSize,
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getTables().size());
+ assertEquals(oldDefaultGroupServerSize,
+ ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size());
+ assertEquals(oldDefaultGroupTableSize,
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables().size());
// verify new group info
- Assert.assertEquals(1, rsGroupAdmin.getRSGroup(newGroup.getName()).getServers().size());
- Assert.assertEquals(0, rsGroupAdmin.getRSGroup(newGroup.getName()).getTables().size());
+ assertEquals(1, ADMIN.getRSGroup(newGroup.getName()).getServers().size());
+ assertEquals(0, RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(newGroup.getName()).getTables().size());
// get all region to move targetServer
List regionList = getTableRegionMap().get(tableName);
@@ -375,63 +370,61 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
return getTableRegionMap().get(tableName) != null &&
getTableRegionMap().get(tableName).size() == 5 &&
getTableServerRegionMap().get(tableName).size() == 1 &&
- admin.getClusterMetrics(EnumSet.of(Option.REGIONS_IN_TRANSITION))
+ ADMIN.getClusterMetrics(EnumSet.of(Option.REGIONS_IN_TRANSITION))
.getRegionStatesInTransition().size() < 1;
}
});
// verify that all region move to targetServer
- Assert.assertEquals(5, getTableServerRegionMap().get(tableName).get(targetServer).size());
+ assertEquals(5, getTableServerRegionMap().get(tableName).get(targetServer).size());
// move targetServer and table to newGroup
LOG.info("moving server and table to newGroup");
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(targetServer.getAddress()),
- newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(targetServer.getAddress()), newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(tableName), newGroup.getName());
// verify group change
- Assert.assertEquals(newGroup.getName(),
- rsGroupAdmin.getRSGroup(tableName).getName());
+ assertEquals(newGroup.getName(), ADMIN.getRSGroup(tableName).getName());
// verify servers' not exist in old group
- Set defaultServers =
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers();
+ Set defaultServers = ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers();
assertFalse(defaultServers.contains(targetServer.getAddress()));
// verify servers' exist in new group
- Set newGroupServers = rsGroupAdmin.getRSGroup(newGroup.getName()).getServers();
+ Set newGroupServers = ADMIN.getRSGroup(newGroup.getName()).getServers();
assertTrue(newGroupServers.contains(targetServer.getAddress()));
// verify tables' not exist in old group
Set defaultTables =
- rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getTables();
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(RSGroupInfo.DEFAULT_GROUP).getTables();
assertFalse(defaultTables.contains(tableName));
// verify tables' exist in new group
- Set newGroupTables = rsGroupAdmin.getRSGroup(newGroup.getName()).getTables();
+ Set newGroupTables =
+ RS_GROUP_ADMIN_CLIENT.getRSGroupInfo(newGroup.getName()).getTables();
assertTrue(newGroupTables.contains(tableName));
- // verify that all region still assgin on targetServer
+ // verify that all region still assign on targetServer
// TODO: uncomment after we reimplement moveServersAndTables, now the implementation is
// moveToRSGroup first and then moveTables, so the region will be moved to other region servers.
- // Assert.assertEquals(5, getTableServerRegionMap().get(tableName).get(targetServer).size());
+ // assertEquals(5, getTableServerRegionMap().get(tableName).get(targetServer).size());
- assertTrue(observer.preMoveServersCalled);
- assertTrue(observer.postMoveServersCalled);
+ assertTrue(OBSERVER.preMoveServersCalled);
+ assertTrue(OBSERVER.postMoveServersCalled);
}
@Test
public void testMoveServersFromDefaultGroup() throws Exception {
// create groups and assign servers
- rsGroupAdmin.addRSGroup("foo");
+ ADMIN.addRSGroup("foo");
- RSGroupInfo fooGroup = rsGroupAdmin.getRSGroup("foo");
+ RSGroupInfo fooGroup = ADMIN.getRSGroup("foo");
assertEquals(0, fooGroup.getServers().size());
- RSGroupInfo defaultGroup = rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
+ RSGroupInfo defaultGroup = ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP);
// test remove all servers from default
try {
- rsGroupAdmin.moveToRSGroup(defaultGroup.getServers(), fooGroup.getName());
+ ADMIN.moveServersToRSGroup(defaultGroup.getServers(), fooGroup.getName());
fail(RSGroupInfoManagerImpl.KEEP_ONE_SERVER_IN_DEFAULT_ERROR_MESSAGE);
} catch (ConstraintException ex) {
assertTrue(
@@ -443,51 +436,49 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
Address serverInDefaultGroup = defaultGroup.getServers().iterator().next();
LOG.info("moving server " + serverInDefaultGroup + " from group default to group " +
fooGroup.getName());
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(serverInDefaultGroup), fooGroup.getName());
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(serverInDefaultGroup), fooGroup.getName());
}
- fooGroup = rsGroupAdmin.getRSGroup("foo");
+ fooGroup = ADMIN.getRSGroup("foo");
LOG.info("moving servers " + fooGroup.getServers() + " to group default");
- rsGroupAdmin.moveToRSGroup(fooGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.moveServersToRSGroup(fooGroup.getServers(), RSGroupInfo.DEFAULT_GROUP);
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
- return getNumServers() == rsGroupAdmin.getRSGroup(RSGroupInfo.DEFAULT_GROUP)
- .getServers().size();
+ return getNumServers() == ADMIN.getRSGroup(RSGroupInfo.DEFAULT_GROUP).getServers().size();
}
});
- fooGroup = rsGroupAdmin.getRSGroup("foo");
+ fooGroup = ADMIN.getRSGroup("foo");
assertEquals(0, fooGroup.getServers().size());
// test group removal
LOG.info("Remove group " + fooGroup.getName());
- rsGroupAdmin.removeRSGroup(fooGroup.getName());
- Assert.assertEquals(null, rsGroupAdmin.getRSGroup(fooGroup.getName()));
+ ADMIN.removeRSGroup(fooGroup.getName());
+ assertEquals(null, ADMIN.getRSGroup(fooGroup.getName()));
}
@Test
public void testFailedMoveBeforeRetryExhaustedWhenMoveServer() throws Exception {
String groupName = getGroupName(name.getMethodName());
- rsGroupAdmin.addRSGroup(groupName);
- final RSGroupInfo newGroup = rsGroupAdmin.getRSGroup(groupName);
- Pair gotPair = createTableWithRegionSplitting(newGroup,
- 10);
+ ADMIN.addRSGroup(groupName);
+ final RSGroupInfo newGroup = ADMIN.getRSGroup(groupName);
+ Pair gotPair = createTableWithRegionSplitting(newGroup, 10);
// start thread to recover region state
final ServerName movedServer = gotPair.getFirst();
final RegionStateNode rsn = gotPair.getSecond();
AtomicBoolean changed = new AtomicBoolean(false);
Thread t1 = recoverRegionStateThread(movedServer,
- server -> master.getAssignmentManager().getRegionsOnServer(movedServer), rsn, changed);
+ server -> MASTER.getAssignmentManager().getRegionsOnServer(movedServer), rsn, changed);
t1.start();
// move target server to group
Thread t2 = new Thread(() -> {
LOG.info("thread2 start running, to move regions");
try {
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(movedServer.getAddress()), newGroup.getName());
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(movedServer.getAddress()), newGroup.getName());
} catch (IOException e) {
LOG.error("move server error", e);
}
@@ -501,8 +492,8 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
@Override
public boolean evaluate() {
if (changed.get()) {
- return master.getAssignmentManager().getRegionsOnServer(movedServer).size() == 0 && !rsn
- .getRegionLocation().equals(movedServer);
+ return MASTER.getAssignmentManager().getRegionsOnServer(movedServer).size() == 0 &&
+ !rsn.getRegionLocation().equals(movedServer);
}
return false;
}
@@ -510,15 +501,15 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
private Thread recoverRegionStateThread(T owner, Function> getRegions,
- RegionStateNode rsn, AtomicBoolean changed){
+ RegionStateNode rsn, AtomicBoolean changed) {
return new Thread(() -> {
LOG.info("thread1 start running, will recover region state");
long current = System.currentTimeMillis();
// wait until there is only left the region we changed state and recover its state.
// wait time is set according to the number of max retries, all except failed regions will be
// moved in one retry, and will sleep 1s until next retry.
- while (System.currentTimeMillis() - current <=
- RSGroupInfoManagerImpl.DEFAULT_MAX_RETRY_VALUE * 1000) {
+ while (System.currentTimeMillis() -
+ current <= RSGroupInfoManagerImpl.DEFAULT_MAX_RETRY_VALUE * 1000) {
List regions = getRegions.apply(owner);
LOG.debug("server table region size is:{}", regions.size());
assert regions.size() >= 1;
@@ -526,7 +517,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
// exception caused by the strange region state.
if (regions.size() == 1) {
assertEquals(regions.get(0).getRegionNameAsString(),
- rsn.getRegionInfo().getRegionNameAsString());
+ rsn.getRegionInfo().getRegionNameAsString());
rsn.setState(RegionState.State.OPEN);
LOG.info("set region {} state OPEN", rsn.getRegionInfo().getRegionNameAsString());
changed.set(true);
@@ -538,7 +529,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
private Pair createTableWithRegionSplitting(RSGroupInfo rsGroupInfo,
- int tableRegionCount) throws Exception{
+ int tableRegionCount) throws Exception {
final byte[] familyNameBytes = Bytes.toBytes("f");
// All the regions created below will be assigned to the default group.
TEST_UTIL.createMultiRegionTable(tableName, familyNameBytes, tableRegionCount);
@@ -562,11 +553,11 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
* @return source server of region, and region state
* @throws IOException if methods called throw
*/
- private Pair randomlySetOneRegionStateToSplitting(
- RSGroupInfo newGroup) throws IOException{
+ private Pair
+ randomlySetOneRegionStateToSplitting(RSGroupInfo newGroup) throws IOException {
// get target server to move, which should has more than one regions
// randomly set a region state to SPLITTING to make move fail
- return randomlySetRegionState(newGroup, RegionState.State.SPLITTING,tableName);
+ return randomlySetRegionState(newGroup, RegionState.State.SPLITTING, tableName);
}
private Pair randomlySetRegionState(RSGroupInfo groupInfo,
@@ -605,7 +596,7 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
}
@Test
- public void testFailedMoveServersAndRepair() throws Exception{
+ public void testFailedMoveServersAndRepair() throws Exception {
// This UT calls moveToRSGroup() twice to test the idempotency of it.
// The first time, movement fails because a region is made in SPLITTING state
// which will not be moved.
@@ -615,35 +606,36 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
// create table
// randomly set a region state to SPLITTING to make move abort
- Pair gotPair = createTableWithRegionSplitting(newGroup,
- new Random().nextInt(8) + 4);
+ Pair gotPair =
+ createTableWithRegionSplitting(newGroup, new Random().nextInt(8) + 4);
RegionStateNode rsn = gotPair.getSecond();
ServerName srcServer = rsn.getRegionLocation();
// move server to newGroup and check regions
try {
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
- fail("should get IOException when retry exhausted but there still exists failed moved "
- + "regions");
- }catch (Exception e){
- assertTrue(e.getMessage().contains(
- gotPair.getSecond().getRegionInfo().getRegionNameAsString()));
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
+ fail("should get IOException when retry exhausted but there still exists failed moved " +
+ "regions");
+ } catch (Exception e) {
+ assertTrue(
+ e.getMessage().contains(gotPair.getSecond().getRegionInfo().getRegionNameAsString()));
}
- for(RegionInfo regionInfo : master.getAssignmentManager().getAssignedRegions()){
+ for (RegionInfo regionInfo : MASTER.getAssignmentManager().getAssignedRegions()) {
if (regionInfo.getTable().equals(tableName) && regionInfo.equals(rsn.getRegionInfo())) {
- assertEquals(master.getAssignmentManager().getRegionStates()
- .getRegionServerOfRegion(regionInfo), srcServer);
+ assertEquals(
+ MASTER.getAssignmentManager().getRegionStates().getRegionServerOfRegion(regionInfo),
+ srcServer);
}
}
// retry move server to newGroup and check if all regions on srcServer was moved
rsn.setState(RegionState.State.OPEN);
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
- assertEquals(master.getAssignmentManager().getRegionsOnServer(srcServer).size(), 0);
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
+ assertEquals(MASTER.getAssignmentManager().getRegionsOnServer(srcServer).size(), 0);
}
@Test
- public void testFailedMoveServersTablesAndRepair() throws Exception{
+ public void testFailedMoveServersTablesAndRepair() throws Exception {
// This UT calls moveTablesAndServers() twice to test the idempotency of it.
// The first time, movement fails because a region is made in SPLITTING state
// which will not be moved.
@@ -654,40 +646,39 @@ public class TestRSGroupsAdmin2 extends TestRSGroupsBase {
final byte[] familyNameBytes = Bytes.toBytes("f");
TableName table1 = TableName.valueOf(tableName.getNameAsString() + "_1");
TableName table2 = TableName.valueOf(tableName.getNameAsString() + "_2");
- TEST_UTIL.createMultiRegionTable(table1, familyNameBytes,
- new Random().nextInt(12) + 4);
- TEST_UTIL.createMultiRegionTable(table2, familyNameBytes,
- new Random().nextInt(12) + 4);
+ TEST_UTIL.createMultiRegionTable(table1, familyNameBytes, new Random().nextInt(12) + 4);
+ TEST_UTIL.createMultiRegionTable(table2, familyNameBytes, new Random().nextInt(12) + 4);
// randomly set a region state to SPLITTING to make move abort
Pair gotPair =
- randomlySetRegionState(newGroup, RegionState.State.SPLITTING, table1, table2);
+ randomlySetRegionState(newGroup, RegionState.State.SPLITTING, table1, table2);
RegionStateNode rsn = gotPair.getSecond();
ServerName srcServer = rsn.getRegionLocation();
// move server and table to newGroup and check regions
try {
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(table2), newGroup.getName());
- fail("should get IOException when retry exhausted but there still exists failed moved "
- + "regions");
- }catch (Exception e){
- assertTrue(e.getMessage().contains(
- gotPair.getSecond().getRegionInfo().getRegionNameAsString()));
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(table2), newGroup.getName());
+ fail("should get IOException when retry exhausted but there still exists failed moved " +
+ "regions");
+ } catch (Exception e) {
+ assertTrue(
+ e.getMessage().contains(gotPair.getSecond().getRegionInfo().getRegionNameAsString()));
}
- for(RegionInfo regionInfo : master.getAssignmentManager().getAssignedRegions()){
+ for (RegionInfo regionInfo : MASTER.getAssignmentManager().getAssignedRegions()) {
if (regionInfo.getTable().equals(table1) && regionInfo.equals(rsn.getRegionInfo())) {
- assertEquals(master.getAssignmentManager().getRegionStates()
- .getRegionServerOfRegion(regionInfo), srcServer);
+ assertEquals(
+ MASTER.getAssignmentManager().getRegionStates().getRegionServerOfRegion(regionInfo),
+ srcServer);
}
}
// retry moveServersAndTables to newGroup and check if all regions on srcServer belongs to
// table2
rsn.setState(RegionState.State.OPEN);
- rsGroupAdmin.moveToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
- rsGroupAdmin.setRSGroup(Sets.newHashSet(table2), newGroup.getName());
- for(RegionInfo regionsInfo : master.getAssignmentManager().getRegionsOnServer(srcServer)){
+ ADMIN.moveServersToRSGroup(Sets.newHashSet(srcServer.getAddress()), newGroup.getName());
+ ADMIN.setRSGroup(Sets.newHashSet(table2), newGroup.getName());
+ for (RegionInfo regionsInfo : MASTER.getAssignmentManager().getRegionsOnServer(srcServer)) {
assertEquals(regionsInfo.getTable(), table2);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java
index be9318600d9..02306716898 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBalance.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.testclassification.MediumTests;
+import org.apache.hadoop.hbase.testclassification.RSGroupTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After;
import org.junit.AfterClass;
@@ -42,13 +43,10 @@ import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@RunWith(Parameterized.class)
-@Category({ MediumTests.class })
+@Category({ RSGroupTests.class, MediumTests.class })
public class TestRSGroupsBalance extends TestRSGroupsBase {
@ClassRule
@@ -83,15 +81,15 @@ public class TestRSGroupsBalance extends TestRSGroupsBase {
String newGroupName = getGroupName(name.getMethodName());
addGroup(newGroupName, 3);
- final TableName tableName = TableName.valueOf(tablePrefix + "_ns",
- getNameWithoutIndex(name.getMethodName()));
- admin.createNamespace(NamespaceDescriptor.create(tableName.getNamespaceAsString())
+ final TableName tableName =
+ TableName.valueOf(TABLE_PREFIX + "_ns", getNameWithoutIndex(name.getMethodName()));
+ ADMIN.createNamespace(NamespaceDescriptor.create(tableName.getNamespaceAsString())
.addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, newGroupName).build());
final TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.of("f")).build();
byte[] startKey = Bytes.toBytes("aaaaa");
byte[] endKey = Bytes.toBytes("zzzzz");
- admin.createTable(desc, startKey, endKey, 6);
+ ADMIN.createTable(desc, startKey, endKey, 6);
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
@@ -106,9 +104,9 @@ public class TestRSGroupsBalance extends TestRSGroupsBase {
// make assignment uneven, move all regions to one server
Map> assignMap = getTableServerRegionMap().get(tableName);
final ServerName first = assignMap.entrySet().iterator().next().getKey();
- for (RegionInfo region : admin.getRegions(tableName)) {
+ for (RegionInfo region : ADMIN.getRegions(tableName)) {
if (!assignMap.get(first).contains(region.getRegionNameAsString())) {
- admin.move(region.getEncodedNameAsBytes(), first);
+ ADMIN.move(region.getEncodedNameAsBytes(), first);
}
}
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@@ -127,18 +125,18 @@ public class TestRSGroupsBalance extends TestRSGroupsBase {
});
// balance the other group and make sure it doesn't affect the new group
- admin.balancerSwitch(true, true);
- rsGroupAdmin.balanceRSGroup(RSGroupInfo.DEFAULT_GROUP);
+ ADMIN.balancerSwitch(true, true);
+ ADMIN.balanceRSGroup(RSGroupInfo.DEFAULT_GROUP);
assertEquals(6, getTableServerRegionMap().get(tableName).get(first).size());
// disable balance, balancer will not be run and return false
- admin.balancerSwitch(false, true);
- assertFalse(rsGroupAdmin.balanceRSGroup(newGroupName));
+ ADMIN.balancerSwitch(false, true);
+ assertFalse(ADMIN.balanceRSGroup(newGroupName));
assertEquals(6, getTableServerRegionMap().get(tableName).get(first).size());
// enable balance
- admin.balancerSwitch(true, true);
- rsGroupAdmin.balanceRSGroup(newGroupName);
+ ADMIN.balancerSwitch(true, true);
+ ADMIN.balanceRSGroup(newGroupName);
TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate() {
@Override
public boolean evaluate() throws Exception {
@@ -150,35 +148,35 @@ public class TestRSGroupsBalance extends TestRSGroupsBase {
return true;
}
});
- admin.balancerSwitch(false, true);
+ ADMIN.balancerSwitch(false, true);
}
@Test
public void testMisplacedRegions() throws Exception {
- String namespace = tablePrefix + "_" + getNameWithoutIndex(name.getMethodName());
+ String namespace = TABLE_PREFIX + "_" + getNameWithoutIndex(name.getMethodName());
TEST_UTIL.getAdmin().createNamespace(NamespaceDescriptor.create(namespace).build());
- final TableName tableName = TableName.valueOf(namespace, tablePrefix + "_" +
- getNameWithoutIndex(name.getMethodName()));
+ final TableName tableName =
+ TableName.valueOf(namespace, TABLE_PREFIX + "_" + getNameWithoutIndex(name.getMethodName()));
final RSGroupInfo rsGroupInfo = addGroup(getGroupName(name.getMethodName()), 1);
TEST_UTIL.createMultiRegionTable(tableName, new byte[] { 'f' }, 15);
TEST_UTIL.waitUntilAllRegionsAssigned(tableName);
TEST_UTIL.getAdmin().modifyNamespace(NamespaceDescriptor.create(namespace)
- .addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, rsGroupInfo.getName()).build());
+ .addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, rsGroupInfo.getName()).build());
- admin.balancerSwitch(true, true);
- assertTrue(rsGroupAdmin.balanceRSGroup(rsGroupInfo.getName()));
- admin.balancerSwitch(false, true);
- assertTrue(observer.preBalanceRSGroupCalled);
- assertTrue(observer.postBalanceRSGroupCalled);
+ ADMIN.balancerSwitch(true, true);
+ assertTrue(ADMIN.balanceRSGroup(rsGroupInfo.getName()));
+ ADMIN.balancerSwitch(false, true);
+ assertTrue(OBSERVER.preBalanceRSGroupCalled);
+ assertTrue(OBSERVER.postBalanceRSGroupCalled);
TEST_UTIL.waitFor(60000, new Predicate() {
@Override
public boolean evaluate() throws Exception {
ServerName serverName =
- ServerName.valueOf(rsGroupInfo.getServers().iterator().next().toString(), 1);
- return admin.getConnection().getAdmin().getRegions(serverName).size() == 15;
+ ServerName.valueOf(rsGroupInfo.getServers().iterator().next().toString(), 1);
+ return ADMIN.getConnection().getAdmin().getRegions(serverName).size() == 15;
}
});
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
index 6626fbab230..7963126109c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
@@ -21,23 +21,20 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
-import java.util.function.Supplier;
+import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Pattern;
import org.apache.hadoop.hbase.ClusterMetrics;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
import org.apache.hadoop.hbase.HBaseCluster;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniHBaseCluster;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
@@ -59,7 +56,6 @@ import org.apache.hadoop.hbase.net.Address;
import org.apache.hadoop.hbase.quotas.QuotaUtil;
import org.junit.Rule;
import org.junit.rules.TestName;
-import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,22 +65,21 @@ import org.apache.hbase.thirdparty.com.google.common.collect.Sets;
public abstract class TestRSGroupsBase {
protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupsBase.class);
- //shared
- protected final static String groupPrefix = "Group";
- protected final static String tablePrefix = "Group";
- protected final static Random rand = new Random();
+ // shared
+ protected static final String GROUP_PREFIX = "Group";
+ protected static final String TABLE_PREFIX = "Group";
- //shared, cluster type specific
+ // shared, cluster type specific
protected static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- protected static Admin admin;
- protected static HBaseCluster cluster;
- protected static HMaster master;
+ protected static Admin ADMIN;
+ protected static HBaseCluster CLUSTER;
+ protected static HMaster MASTER;
protected boolean INIT = false;
- protected static RSGroupAdminEndpoint rsGroupAdminEndpoint;
- protected static CPMasterObserver observer;
+ protected static CPMasterObserver OBSERVER;
+ protected static RSGroupAdminClient RS_GROUP_ADMIN_CLIENT;
public final static long WAIT_TIMEOUT = 60000;
- public final static int NUM_SLAVES_BASE = 4; //number of slaves for the smallest cluster
+ public final static int NUM_SLAVES_BASE = 4; // number of slaves for the smallest cluster
public static int NUM_DEAD_SERVERS = 0;
// Per test variables
@@ -92,59 +87,17 @@ public abstract class TestRSGroupsBase {
public TestName name = new TestName();
protected TableName tableName;
- protected Admin rsGroupAdmin;
-
- @Parameterized.Parameter
- public Supplier