use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class ProtobufUtil method getOnlineRegions.
/**
* A helper to get the all the online regions on a region
* server using admin protocol.
* @return a list of online region info
*/
public static List<org.apache.hadoop.hbase.client.RegionInfo> getOnlineRegions(final RpcController controller, final AdminService.BlockingInterface admin) throws IOException {
GetOnlineRegionRequest request = RequestConverter.buildGetOnlineRegionRequest();
GetOnlineRegionResponse response = null;
try {
response = admin.getOnlineRegion(controller, request);
} catch (ServiceException se) {
throw getRemoteException(se);
}
return getRegionInfos(response);
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class HBaseHbck method setRegionStateInMeta.
@Override
public Map<String, RegionState.State> setRegionStateInMeta(Map<String, RegionState.State> nameOrEncodedName2State) throws IOException {
try {
if (LOG.isDebugEnabled()) {
nameOrEncodedName2State.forEach((k, v) -> LOG.debug("region={}, state={}", k, v));
}
MasterProtos.SetRegionStateInMetaResponse response = hbck.setRegionStateInMeta(rpcControllerFactory.newController(), RequestConverter.buildSetRegionStateInMetaRequest(nameOrEncodedName2State));
Map<String, RegionState.State> result = new HashMap<>();
for (RegionSpecifierAndState nameAndState : response.getStatesList()) {
result.put(nameAndState.getRegionSpecifier().getValue().toStringUtf8(), RegionState.State.convert(nameAndState.getState()));
}
return result;
} catch (ServiceException se) {
throw new IOException(se);
}
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class HBaseRpcServicesBase method updateConfiguration.
@Override
public UpdateConfigurationResponse updateConfiguration(RpcController controller, UpdateConfigurationRequest request) throws ServiceException {
try {
requirePermission("updateConfiguration", Permission.Action.ADMIN);
this.server.updateConfiguration();
} catch (Exception e) {
throw new ServiceException(e);
}
return UpdateConfigurationResponse.getDefaultInstance();
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class HBaseRpcServicesBase method getLogEntries.
@Override
@QosPriority(priority = HConstants.ADMIN_QOS)
public HBaseProtos.LogEntry getLogEntries(RpcController controller, HBaseProtos.LogRequest request) throws ServiceException {
try {
final String logClassName = request.getLogClassName();
Class<?> logClass = Class.forName(logClassName).asSubclass(Message.class);
Method method = logClass.getMethod("parseFrom", ByteString.class);
if (logClassName.contains("SlowLogResponseRequest")) {
SlowLogResponseRequest slowLogResponseRequest = (SlowLogResponseRequest) method.invoke(null, request.getLogMessage());
final NamedQueueRecorder namedQueueRecorder = this.server.getNamedQueueRecorder();
final List<SlowLogPayload> slowLogPayloads = getSlowLogPayloads(slowLogResponseRequest, namedQueueRecorder);
SlowLogResponses slowLogResponses = SlowLogResponses.newBuilder().addAllSlowLogPayloads(slowLogPayloads).build();
return HBaseProtos.LogEntry.newBuilder().setLogClassName(slowLogResponses.getClass().getName()).setLogMessage(slowLogResponses.toByteString()).build();
}
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
LOG.error("Error while retrieving log entries.", e);
throw new ServiceException(e);
}
throw new ServiceException("Invalid request params");
}
use of org.apache.hbase.thirdparty.com.google.protobuf.ServiceException in project hbase by apache.
the class AbstractTestIPC method testRpcMaxRequestSize.
/**
* Tests that the rpc scheduler is called when requests arrive.
*/
@Test
public void testRpcMaxRequestSize() throws IOException, ServiceException {
Configuration conf = new Configuration(CONF);
conf.setInt(RpcServer.MAX_REQUEST_SIZE, 1000);
RpcServer rpcServer = createRpcServer(null, "testRpcServer", Lists.newArrayList(new RpcServer.BlockingServiceAndInterface(SERVICE, null)), new InetSocketAddress("localhost", 0), conf, new FifoRpcScheduler(conf, 1));
try (AbstractRpcClient<?> client = createRpcClient(conf)) {
rpcServer.start();
BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
StringBuilder message = new StringBuilder(1200);
for (int i = 0; i < 200; i++) {
message.append("hello.");
}
// set total RPC size bigger than 100 bytes
EchoRequestProto param = EchoRequestProto.newBuilder().setMessage(message.toString()).build();
stub.echo(new HBaseRpcControllerImpl(CellUtil.createCellScanner(ImmutableList.<Cell>of(CELL))), param);
fail("RPC should have failed because it exceeds max request size");
} catch (ServiceException e) {
LOG.info("Caught expected exception: " + e);
assertTrue(e.toString(), StringUtils.stringifyException(e).contains("RequestTooBigException"));
} finally {
rpcServer.stop();
}
}
Aggregations