use of org.apache.hadoop.hbase.net.Address in project hbase by apache.
the class RSGroupInfoManagerImpl method moveServersAndTables.
@Override
public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException {
//get server's group
RSGroupInfo srcGroupInfo = getRSGroupInfo(srcGroup);
RSGroupInfo dstGroupInfo = getRSGroupInfo(dstGroup);
//move servers
for (Address el : servers) {
srcGroupInfo.removeServer(el);
dstGroupInfo.addServer(el);
}
//move tables
for (TableName tableName : tables) {
srcGroupInfo.removeTable(tableName);
dstGroupInfo.addTable(tableName);
}
//flush changed groupinfo
Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap);
newGroupMap.put(srcGroupInfo.getName(), srcGroupInfo);
newGroupMap.put(dstGroupInfo.getName(), dstGroupInfo);
flushConfig(newGroupMap);
}
use of org.apache.hadoop.hbase.net.Address in project hbase by apache.
the class RSGroupProtobufUtil method toProtoGroupInfo.
static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
List<HBaseProtos.TableName> tables = new ArrayList<>(pojo.getTables().size());
for (TableName arg : pojo.getTables()) {
tables.add(ProtobufUtil.toProtoTableName(arg));
}
List<HBaseProtos.ServerName> hostports = new ArrayList<>(pojo.getServers().size());
for (Address el : pojo.getServers()) {
hostports.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname()).setPort(el.getPort()).build());
}
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports).addAllTables(tables).build();
}
use of org.apache.hadoop.hbase.net.Address in project hbase by apache.
the class TestRSGroupBasedLoadBalancer method convertToGroupBasedMap.
private ArrayListMultimap<String, ServerAndLoad> convertToGroupBasedMap(final Map<ServerName, List<HRegionInfo>> serversMap) throws IOException {
ArrayListMultimap<String, ServerAndLoad> loadMap = ArrayListMultimap.create();
for (RSGroupInfo gInfo : getMockedGroupInfoManager().listRSGroups()) {
Set<Address> groupServers = gInfo.getServers();
for (Address hostPort : groupServers) {
ServerName actual = null;
for (ServerName entry : servers) {
if (entry.getAddress().equals(hostPort)) {
actual = entry;
break;
}
}
List<HRegionInfo> regions = serversMap.get(actual);
assertTrue("No load for " + actual, regions != null);
loadMap.put(gInfo.getName(), new ServerAndLoad(actual, regions.size()));
}
}
return loadMap;
}
Aggregations