Search in sources :

Example 11 with Address

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);
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Address(org.apache.hadoop.hbase.net.Address)

Example 12 with Address

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();
}
Also used : TableName(org.apache.hadoop.hbase.TableName) Address(org.apache.hadoop.hbase.net.Address) ArrayList(java.util.ArrayList)

Example 13 with Address

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;
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) Address(org.apache.hadoop.hbase.net.Address) RSGroupInfo(org.apache.hadoop.hbase.rsgroup.RSGroupInfo) ServerName(org.apache.hadoop.hbase.ServerName)

Aggregations

Address (org.apache.hadoop.hbase.net.Address)13 TableName (org.apache.hadoop.hbase.TableName)6 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)5 ServerName (org.apache.hadoop.hbase.ServerName)5 ConstraintException (org.apache.hadoop.hbase.constraint.ConstraintException)5 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Waiter (org.apache.hadoop.hbase.Waiter)2 Test (org.junit.Test)2 ServiceException (com.google.protobuf.ServiceException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 ClusterConnection (org.apache.hadoop.hbase.client.ClusterConnection)1