/** * A helper to get the info of a region server using admin protocol. * @return the server name */ public static ServerInfo getServerInfo(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException { GetServerInfoRequest request = buildGetServerInfoRequest(); try { GetServerInfoResponse response = admin.getServerInfo(controller, request); return response.getServerInfo(); } catch (ServiceException se) { throw getRemoteException(se); } }
@Test public void test() throws Exception { try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()); Table table = conn.getTable(TableName.META_TABLE_NAME)) { CoprocessorRpcChannel rpcChannel = table.coprocessorService(HConstants.EMPTY_START_ROW); AuthenticationProtos.AuthenticationService.BlockingInterface service = AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel); WhoAmIResponse response = service.whoAmI(null, WhoAmIRequest.getDefaultInstance()); assertEquals(USERNAME, response.getUsername()); assertEquals(AuthenticationMethod.TOKEN.name(), response.getAuthMethod()); try { service.getAuthenticationToken(null, GetAuthenticationTokenRequest.getDefaultInstance()); } catch (ServiceException e) { IOException ioe = ProtobufUtil.getRemoteException(e); assertThat(ioe, instanceOf(AccessDeniedException.class)); assertThat(ioe.getMessage(), containsString("Token generation only allowed for Kerberos authenticated clients")); } } } }
/** * A helper to get the info of a region server using admin protocol. * @return the server name */ public static ServerInfo getServerInfo(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException { GetServerInfoRequest request = buildGetServerInfoRequest(); try { GetServerInfoResponse response = admin.getServerInfo(controller, request); return response.getServerInfo(); } catch (ServiceException se) { throw getRemoteException(se); } }
@Override public ReplicateWALEntryResponse call(int callTimeout) throws IOException { try { replayToServer(this.regionInfo, this.entries); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } return null; }
/** * A helper to open a region using admin protocol. * @param admin * @param region * @throws IOException */ public static void openRegion(final AdminService.BlockingInterface admin, ServerName server, final HRegionInfo region) throws IOException { OpenRegionRequest request = RequestConverter.buildOpenRegionRequest(server, region, -1, null, null); try { admin.openRegion(null, request); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
@Override public void updateConfiguration(ServerName server) throws IOException { try { this.connection.getAdmin(server).updateConfiguration(null, UpdateConfigurationRequest.getDefaultInstance()); } catch (ServiceException e) { throw ProtobufUtil.getRemoteException(e); } }
private RollWALWriterResponse rollWALWriterImpl(final ServerName sn) throws IOException, FailedLogCloseException { AdminService.BlockingInterface admin = this.connection.getAdmin(sn); RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest(); try { return admin.rollWALWriter(null, request); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
/** * A helper to get the info of a region server using admin protocol. * @return the server name */ public static ServerInfo getServerInfo(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException { GetServerInfoRequest request = buildGetServerInfoRequest(); try { GetServerInfoResponse response = admin.getServerInfo(controller, request); return response.getServerInfo(); } catch (ServiceException se) { throw getRemoteException(se); } }
private void compact(final ServerName sn, final HRegionInfo hri, final boolean major, final byte [] family) throws IOException { AdminService.BlockingInterface admin = this.connection.getAdmin(sn); CompactRegionRequest request = RequestConverter.buildCompactRegionRequest(hri.getRegionName(), major, family); try { admin.compactRegion(null, request); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
private void flush(final ServerName sn, final HRegionInfo hri) throws IOException { AdminService.BlockingInterface admin = this.connection.getAdmin(sn); FlushRegionRequest request = RequestConverter.buildFlushRegionRequest(hri.getRegionName()); try { admin.flushRegion(null, request); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
private void replayToServer(HRegionInfo regionInfo, List<Entry> entries) throws IOException, ServiceException { if (entries.isEmpty()) return; Entry[] entriesArray = new Entry[entries.size()]; entriesArray = entries.toArray(entriesArray); AdminService.BlockingInterface remoteSvr = conn.getAdmin(getLocation().getServerName()); Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner> p = ReplicationProtbufUtil.buildReplicateWALEntryRequest(entriesArray); PayloadCarryingRpcController controller = rpcControllerFactory.newController(p.getSecond()); try { remoteSvr.replay(controller, p.getFirst()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } }
public static CoprocessorServiceResponse execService(final ClientService.BlockingInterface client, final CoprocessorServiceCall call, final byte[] regionName) throws IOException { CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder() .setCall(call).setRegion( RequestConverter.buildRegionSpecifier(REGION_NAME, regionName)).build(); try { CoprocessorServiceResponse response = client.execService(null, request); return response; } catch (ServiceException se) { throw getRemoteException(se); } }
public static CoprocessorServiceResponse execService( final MasterService.BlockingInterface client, final CoprocessorServiceCall call) throws IOException { CoprocessorServiceRequest request = CoprocessorServiceRequest.newBuilder() .setCall(call).setRegion( RequestConverter.buildRegionSpecifier(REGION_NAME, HConstants.EMPTY_BYTE_ARRAY)).build(); try { CoprocessorServiceResponse response = client.execMasterService(null, request); return response; } catch (ServiceException se) { throw getRemoteException(se); } }
@Override public Boolean call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(tableName); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), delete); MutateResponse response = getStub().mutate(controller, request); return Boolean.valueOf(response.getProcessed()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Boolean call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(tableName); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), row, family, qualifier, new BinaryComparator(value), CompareType.EQUAL, delete); MutateResponse response = getStub().mutate(controller, request); return Boolean.valueOf(response.getProcessed()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Boolean call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(tableName); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), row, family, qualifier, new BinaryComparator(value), CompareType.EQUAL, put); MutateResponse response = getStub().mutate(controller, request); return Boolean.valueOf(response.getProcessed()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Result call(int callTimeout) throws IOException { ClientProtos.GetRequest request = RequestConverter.buildGetRequest(getLocation().getRegionInfo().getRegionName(), getReq); PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(tableName); controller.setCallTimeout(callTimeout); try { ClientProtos.GetResponse response = getStub().get(controller, request); if (response == null) return null; return ProtobufUtil.toResult(response.getResult()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Result call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(tableName); controller.setCallTimeout(callTimeout); ClientProtos.GetRequest request = RequestConverter.buildGetRowOrBeforeRequest( getLocation().getRegionInfo().getRegionName(), row, family); try { ClientProtos.GetResponse response = getStub().get(controller, request); if (!response.hasResult()) return null; return ProtobufUtil.toResult(response.getResult()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Result call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(getTableName()); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), increment, nonceGroup, nonce); MutateResponse response = getStub().mutate(controller, request); return ProtobufUtil.toResult(response.getResult(), controller.cellScanner()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };
@Override public Result call(int callTimeout) throws IOException { PayloadCarryingRpcController controller = rpcControllerFactory.newController(); controller.setPriority(getTableName()); controller.setCallTimeout(callTimeout); try { MutateRequest request = RequestConverter.buildMutateRequest( getLocation().getRegionInfo().getRegionName(), append, nonceGroup, nonce); MutateResponse response = getStub().mutate(controller, request); if (!response.hasResult()) return null; return ProtobufUtil.toResult(response.getResult(), controller.cellScanner()); } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } } };