use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse in project hbase by apache.
the class HBaseAdmin method coprocessorService.
@Override
public CoprocessorRpcChannel coprocessorService(final ServerName serverName) {
return new SyncCoprocessorRpcChannel() {
@Override
protected Message callExecService(RpcController controller, Descriptors.MethodDescriptor method, Message request, Message responsePrototype) throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
// TODO: Make this same as RegionCoprocessorRpcChannel and MasterCoprocessorRpcChannel. They
// are all different though should do same thing; e.g. RpcChannel setup.
ClientProtos.ClientService.BlockingInterface stub = connection.getClient(serverName);
CoprocessorServiceResponse result;
try {
result = stub.execRegionServerService(connection.getRpcControllerFactory().newController(), csr);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
};
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse in project hbase by apache.
the class RegionCoprocessorRpcChannel method callExecService.
@Override
protected Message callExecService(final RpcController controller, final Descriptors.MethodDescriptor method, final Message request, final Message responsePrototype) throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
if (row == null) {
throw new NullPointerException("Can't be null!");
}
ClientServiceCallable<CoprocessorServiceResponse> callable = new ClientServiceCallable<CoprocessorServiceResponse>(this.conn, this.table, this.row, this.conn.getRpcControllerFactory().newController()) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
byte[] regionName = getLocation().getRegionInfo().getRegionName();
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, regionName);
return getStub().execService(getRpcController(), csr);
}
};
CoprocessorServiceResponse result = this.rpcCallerFactory.<CoprocessorServiceResponse>newCaller().callWithRetries(callable, operationTimeout);
this.lastRegion = result.getRegion().getValue().toByteArray();
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse in project hbase by apache.
the class RegionCoprocessorRpcChannelImpl method rpcCall.
private CompletableFuture<Message> rpcCall(MethodDescriptor method, Message request, Message responsePrototype, HBaseRpcController controller, HRegionLocation loc, ClientService.Interface stub) {
CompletableFuture<Message> future = new CompletableFuture<>();
if (region != null && !Bytes.equals(loc.getRegionInfo().getRegionName(), region.getRegionName())) {
future.completeExceptionally(new DoNotRetryIOException("Region name is changed, expected " + region.getRegionNameAsString() + ", actual " + loc.getRegionInfo().getRegionNameAsString()));
return future;
}
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request, row, loc.getRegionInfo().getRegionName());
stub.execService(controller, csr, new org.apache.hadoop.hbase.shaded.com.google.protobuf.RpcCallback<CoprocessorServiceResponse>() {
@Override
public void run(CoprocessorServiceResponse resp) {
if (controller.failed()) {
future.completeExceptionally(controller.getFailed());
} else {
try {
future.complete(CoprocessorRpcUtils.getResponse(resp, responsePrototype));
} catch (IOException e) {
future.completeExceptionally(e);
}
}
}
});
return future;
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse in project hbase by apache.
the class HBaseAdmin method coprocessorService.
@Override
public // Coprocessor Endpoint against the Master.
CoprocessorRpcChannel coprocessorService() {
return new SyncCoprocessorRpcChannel() {
@Override
protected Message callExecService(final RpcController controller, final Descriptors.MethodDescriptor method, final Message request, final Message responsePrototype) throws IOException {
if (LOG.isTraceEnabled()) {
LOG.trace("Call: " + method.getName() + ", " + request.toString());
}
// Try-with-resources so close gets called when we are done.
try (MasterCallable<CoprocessorServiceResponse> callable = new MasterCallable<CoprocessorServiceResponse>(connection, connection.getRpcControllerFactory()) {
@Override
protected CoprocessorServiceResponse rpcCall() throws Exception {
CoprocessorServiceRequest csr = CoprocessorRpcUtils.getCoprocessorServiceRequest(method, request);
return this.master.execMasterService(getRpcController(), csr);
}
}) {
// TODO: Are we retrying here? Does not seem so. We should use RetryingRpcCaller
callable.prepare(false);
int operationTimeout = connection.getConnectionConfiguration().getOperationTimeout();
CoprocessorServiceResponse result = callable.call(operationTimeout);
return CoprocessorRpcUtils.getResponse(result, responsePrototype);
}
}
};
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse in project hbase by apache.
the class RSRpcServices method execService.
@Override
public CoprocessorServiceResponse execService(final RpcController controller, final CoprocessorServiceRequest request) throws ServiceException {
try {
checkOpen();
requestCount.increment();
Region region = getRegion(request.getRegion());
com.google.protobuf.Message result = execServiceOnRegion(region, request.getCall());
CoprocessorServiceResponse.Builder builder = CoprocessorServiceResponse.newBuilder();
builder.setRegion(RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, region.getRegionInfo().getRegionName()));
// TODO: COPIES!!!!!!
builder.setValue(builder.getValueBuilder().setName(result.getClass().getName()).setValue(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString.copyFrom(result.toByteArray())));
return builder.build();
} catch (IOException ie) {
throw new ServiceException(ie);
}
}
Aggregations