@InterfaceAudience.Private public class BulkDeleteEndpoint extends BulkDeleteProtos.BulkDeleteService implements RegionCoprocessor
Scan scan = new Scan();
// set scan properties(rowkey range, filters, timerange etc).
HTable ht = ...;
long noOfDeletedRows = 0L;
Batch.Call<BulkDeleteService, BulkDeleteResponse> callable =
new Batch.Call<BulkDeleteService, BulkDeleteResponse>() {
ServerRpcController controller = new ServerRpcController();
BlockingRpcCallback<BulkDeleteResponse> rpcCallback =
new BlockingRpcCallback<BulkDeleteResponse>();
public BulkDeleteResponse call(BulkDeleteService service) throws IOException {
Builder builder = BulkDeleteRequest.newBuilder();
builder.setScan(ProtobufUtil.toScan(scan));
builder.setDeleteType(DeleteType.VERSION);
builder.setRowBatchSize(rowBatchSize);
// Set optional timestamp if needed
builder.setTimestamp(timeStamp);
service.delete(controller, builder.build(), rpcCallback);
return rpcCallback.get();
}
};
Map<byte[], BulkDeleteResponse> result = ht.coprocessorService(BulkDeleteService.class, scan
.getStartRow(), scan.getStopRow(), callable);
for (BulkDeleteResponse response : result.values()) {
noOfDeletedRows += response.getRowsDeleted();
}
BulkDeleteProtos.BulkDeleteService.BlockingInterface, BulkDeleteProtos.BulkDeleteService.Interface, BulkDeleteProtos.BulkDeleteService.StubCoprocessor.StatePRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION| Constructor and Description |
|---|
BulkDeleteEndpoint() |
| Modifier and Type | Method and Description |
|---|---|
void |
delete(com.google.protobuf.RpcController controller,
BulkDeleteProtos.BulkDeleteRequest request,
com.google.protobuf.RpcCallback<BulkDeleteProtos.BulkDeleteResponse> done)
rpc delete(.hbase.pb.BulkDeleteRequest) returns (.hbase.pb.BulkDeleteResponse); |
Iterable<com.google.protobuf.Service> |
getServices()
Coprocessor endpoints providing protobuf services should override this method.
|
void |
start(CoprocessorEnvironment env)
Called by the
CoprocessorEnvironment during it's own startup to initialize the
coprocessor. |
void |
stop(CoprocessorEnvironment env)
Called by the
CoprocessorEnvironment during it's own shutdown to stop the
coprocessor. |
callMethod, getDescriptor, getDescriptorForType, getRequestPrototype, getResponsePrototype, newBlockingStub, newReflectiveBlockingService, newReflectiveService, newStubclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBulkLoadObserver, getEndpointObserver, getRegionObserverpublic Iterable<com.google.protobuf.Service> getServices()
CoprocessorgetServices in interface CoprocessorServices or empty collection. Implementations should never
return null.public void delete(com.google.protobuf.RpcController controller,
BulkDeleteProtos.BulkDeleteRequest request,
com.google.protobuf.RpcCallback<BulkDeleteProtos.BulkDeleteResponse> done)
BulkDeleteProtos.BulkDeleteServicerpc delete(.hbase.pb.BulkDeleteRequest) returns (.hbase.pb.BulkDeleteResponse);delete in class BulkDeleteProtos.BulkDeleteServicepublic void start(CoprocessorEnvironment env) throws IOException
CoprocessorCoprocessorEnvironment during it's own startup to initialize the
coprocessor.start in interface CoprocessorIOExceptionpublic void stop(CoprocessorEnvironment env) throws IOException
CoprocessorCoprocessorEnvironment during it's own shutdown to stop the
coprocessor.stop in interface CoprocessorIOExceptionCopyright © 2007–2019 Cloudera. All rights reserved.