Ejemplo n.º 1
0
 @Override
 public void removeRSGroup(String name) throws IOException {
   RSGroupAdminProtos.RemoveRSGroupRequest request =
       RSGroupAdminProtos.RemoveRSGroupRequest.newBuilder().setRSGroupName(name).build();
   try {
     proxy.removeRSGroup(null, request);
   } catch (ServiceException e) {
     throw ProtobufUtil.handleRemoteException(e);
   }
 }
Ejemplo n.º 2
0
  @Override
  public boolean balanceRSGroup(String name) throws IOException {
    RSGroupAdminProtos.BalanceRSGroupRequest request =
        RSGroupAdminProtos.BalanceRSGroupRequest.newBuilder().setRSGroupName(name).build();

    try {
      return proxy.balanceRSGroup(null, request).getBalanceRan();
    } catch (ServiceException e) {
      throw ProtobufUtil.handleRemoteException(e);
    }
  }
Ejemplo n.º 3
0
 @Override
 public void moveTables(Set<TableName> tables, String targetGroup) throws IOException {
   RSGroupAdminProtos.MoveTablesRequest.Builder builder =
       RSGroupAdminProtos.MoveTablesRequest.newBuilder().setTargetGroup(targetGroup);
   for (TableName tableName : tables) {
     builder.addTableName(ProtobufUtil.toProtoTableName(tableName));
   }
   try {
     proxy.moveTables(null, builder.build());
   } catch (ServiceException e) {
     throw ProtobufUtil.handleRemoteException(e);
   }
 }
Ejemplo n.º 4
0
  @Override
  public RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException {
    RSGroupAdminProtos.GetRSGroupInfoOfTableRequest request =
        RSGroupAdminProtos.GetRSGroupInfoOfTableRequest.newBuilder()
            .setTableName(ProtobufUtil.toProtoTableName(tableName))
            .build();

    try {
      GetRSGroupInfoOfTableResponse resp = proxy.getRSGroupInfoOfTable(null, request);
      if (resp.hasRSGroupInfo()) {
        return RSGroupSerDe.toGroupInfo(resp.getRSGroupInfo());
      }
      return null;
    } catch (ServiceException e) {
      throw ProtobufUtil.handleRemoteException(e);
    }
  }
Ejemplo n.º 5
0
 @Override
 public RSGroupInfo getRSGroupInfo(String groupName) throws IOException {
   try {
     RSGroupAdminProtos.GetRSGroupInfoResponse resp =
         proxy.getRSGroupInfo(
             null,
             RSGroupAdminProtos.GetRSGroupInfoRequest.newBuilder()
                 .setRSGroupName(groupName)
                 .build());
     if (resp.hasRSGroupInfo()) {
       return RSGroupSerDe.toGroupInfo(resp.getRSGroupInfo());
     }
     return null;
   } catch (ServiceException e) {
     throw ProtobufUtil.handleRemoteException(e);
   }
 }
Ejemplo n.º 6
0
 @Override
 public List<RSGroupInfo> listRSGroups() throws IOException {
   try {
     List<RSGroupProtos.RSGroupInfo> resp =
         proxy
             .listRSGroupInfos(
                 null, RSGroupAdminProtos.ListRSGroupInfosRequest.newBuilder().build())
             .getRSGroupInfoList();
     List<RSGroupInfo> result = new ArrayList<RSGroupInfo>(resp.size());
     for (RSGroupProtos.RSGroupInfo entry : resp) {
       result.add(RSGroupSerDe.toGroupInfo(entry));
     }
     return result;
   } catch (ServiceException e) {
     throw ProtobufUtil.handleRemoteException(e);
   }
 }
Ejemplo n.º 7
0
 @Override
 public RSGroupInfo getRSGroupOfServer(HostAndPort hostPort) throws IOException {
   RSGroupAdminProtos.GetRSGroupInfoOfServerRequest request =
       RSGroupAdminProtos.GetRSGroupInfoOfServerRequest.newBuilder()
           .setServer(
               HBaseProtos.ServerName.newBuilder()
                   .setHostName(hostPort.getHostText())
                   .setPort(hostPort.getPort())
                   .build())
           .build();
   try {
     GetRSGroupInfoOfServerResponse resp = proxy.getRSGroupInfoOfServer(null, request);
     if (resp.hasRSGroupInfo()) {
       return RSGroupSerDe.toGroupInfo(resp.getRSGroupInfo());
     }
     return null;
   } catch (ServiceException e) {
     throw ProtobufUtil.handleRemoteException(e);
   }
 }
Ejemplo n.º 8
0
  @Override
  public void moveServers(Set<HostAndPort> servers, String targetGroup) throws IOException {
    Set<HBaseProtos.ServerName> hostPorts = Sets.newHashSet();
    for (HostAndPort el : servers) {
      hostPorts.add(
          HBaseProtos.ServerName.newBuilder()
              .setHostName(el.getHostText())
              .setPort(el.getPort())
              .build());
    }
    RSGroupAdminProtos.MoveServersRequest request =
        RSGroupAdminProtos.MoveServersRequest.newBuilder()
            .setTargetGroup(targetGroup)
            .addAllServers(hostPorts)
            .build();

    try {
      proxy.moveServers(null, request);
    } catch (ServiceException e) {
      throw ProtobufUtil.handleRemoteException(e);
    }
  }