@Override public List<RSGroupInfo> listRSGroups() throws IOException { try { List<RSGroupProtos.RSGroupInfo> resp = stub.listRSGroupInfos(null, ListRSGroupInfosRequest.getDefaultInstance()).getRSGroupInfoList(); List<RSGroupInfo> result = new ArrayList<>(resp.size()); for(RSGroupProtos.RSGroupInfo entry : resp) { result.add(RSGroupProtobufUtil.toGroupInfo(entry)); } return result; } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@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 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 boolean balanceRSGroup(String groupName) throws IOException { BalanceRSGroupRequest request = BalanceRSGroupRequest.newBuilder() .setRSGroupName(groupName).build(); try { return stub.balanceRSGroup(null, request).getBalanceRan(); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public RSGroupInfo getRSGroupInfo(String groupName) throws IOException { try { GetRSGroupInfoResponse resp = stub.getRSGroupInfo(null, GetRSGroupInfoRequest.newBuilder().setRSGroupName(groupName).build()); if(resp.hasRSGroupInfo()) { return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo()); } return null; } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public RSGroupInfo getRSGroupInfoOfTable(TableName tableName) throws IOException { GetRSGroupInfoOfTableRequest request = GetRSGroupInfoOfTableRequest.newBuilder().setTableName( ProtobufUtil.toProtoTableName(tableName)).build(); try { GetRSGroupInfoOfTableResponse resp = stub.getRSGroupInfoOfTable(null, request); if (resp.hasRSGroupInfo()) { return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo()); } return null; } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public void moveTables(Set<TableName> 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)) { throw new TableNotFoundException(tableName); } } try { stub.moveTables(null, builder.build()); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public void removeServers(Set<Address> servers) throws IOException { Set<HBaseProtos.ServerName> 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 moveServers(Set<Address> servers, String targetGroup) throws IOException { Set<HBaseProtos.ServerName> hostPorts = Sets.newHashSet(); for(Address el: servers) { hostPorts.add(HBaseProtos.ServerName.newBuilder() .setHostName(el.getHostname()) .setPort(el.getPort()) .build()); } MoveServersRequest request = MoveServersRequest.newBuilder() .setTargetGroup(targetGroup) .addAllServers(hostPorts) .build(); try { stub.moveServers(null, request); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
/** * Override that changes call Exception from {@link Exception} to {@link IOException}. * Also does set up of the rpcController. */ @Override public T call(int callTimeout) throws IOException { try { // Iff non-null and an instance of a SHADED rpcController, do config! Unshaded -- i.e. // com.google.protobuf.RpcController or null -- will just skip over this config. if (getRpcController() != null) { RpcController shadedRpcController = (RpcController)getRpcController(); // Do a reset to clear previous states, such as CellScanner. shadedRpcController.reset(); if (shadedRpcController instanceof HBaseRpcController) { HBaseRpcController hrc = (HBaseRpcController)getRpcController(); // If it is an instance of HBaseRpcController, we can set priority on the controller based // off the tableName. Set call timeout too. hrc.setPriority(tableName); hrc.setPriority(priority); hrc.setCallTimeout(callTimeout); } } return rpcCall(); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public RSGroupInfo getRSGroupOfServer(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 RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo()); } return null; } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public void moveServersAndTables(Set<Address> servers, Set<TableName> 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); } }
/** * Override that changes call Exception from {@link Exception} to {@link IOException}. * Also does set up of the rpcController. */ @Override public T call(int callTimeout) throws IOException { try { // Iff non-null and an instance of a SHADED rpcController, do config! Unshaded -- i.e. // com.google.protobuf.RpcController or null -- will just skip over this config. if (getRpcController() != null) { RpcController shadedRpcController = (RpcController)getRpcController(); // Do a reset to clear previous states, such as CellScanner. shadedRpcController.reset(); if (shadedRpcController instanceof HBaseRpcController) { HBaseRpcController hrc = (HBaseRpcController)getRpcController(); // If it is an instance of HBaseRpcController, we can set priority on the controller based // off the tableName. Set call timeout too. hrc.setPriority(tableName); hrc.setPriority(priority); hrc.setCallTimeout(callTimeout); } } return rpcCall(); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
@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 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 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 boolean balanceRSGroup(String groupName) throws IOException { BalanceRSGroupRequest request = BalanceRSGroupRequest.newBuilder() .setRSGroupName(groupName).build(); try { return stub.balanceRSGroup(null, request).getBalanceRan(); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public void moveTables(Set<TableName> tables, String targetGroup) throws IOException { MoveTablesRequest.Builder builder = MoveTablesRequest.newBuilder().setTargetGroup(targetGroup); for(TableName tableName: tables) { builder.addTableName(ProtobufUtil.toProtoTableName(tableName)); } try { stub.moveTables(null, builder.build()); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public void moveTables(Set<TableName> tables, String targetGroup) throws IOException { MoveTablesRequest.Builder builder = MoveTablesRequest.newBuilder().setTargetGroup(targetGroup); for(TableName tableName: tables) { builder.addTableName(ProtobufUtil.toProtoTableName(tableName)); } try { stub.moveTables(null, builder.build()); } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public RSGroupInfo getRSGroupInfo(String groupName) throws IOException { try { GetRSGroupInfoResponse resp = stub.getRSGroupInfo(null, GetRSGroupInfoRequest.newBuilder().setRSGroupName(groupName).build()); if(resp.hasRSGroupInfo()) { return RSGroupProtobufUtil.toGroupInfo(resp.getRSGroupInfo()); } return null; } catch (ServiceException e) { throw ProtobufUtil.handleRemoteException(e); } }