@InterfaceAudience.Private public class BulkDeleteEndpoint extends org.apache.hadoop.hbase.coprocessor.example.generated.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();
}
Modifier and Type | Class and Description |
---|---|
private static class |
BulkDeleteEndpoint.Column |
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService.BlockingInterface, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService.Interface, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService.Stub
Coprocessor.State
Modifier and Type | Field and Description |
---|---|
private RegionCoprocessorEnvironment |
env |
private static org.slf4j.Logger |
LOG |
private static String |
NO_OF_VERSIONS_TO_DELETE |
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
Constructor and Description |
---|
BulkDeleteEndpoint() |
Modifier and Type | Method and Description |
---|---|
private Delete |
createDeleteMutation(List<Cell> deleteRow,
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest.DeleteType deleteType,
Long timestamp) |
void |
delete(com.google.protobuf.RpcController controller,
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest request,
com.google.protobuf.RpcCallback<org.apache.hadoop.hbase.coprocessor.example.generated.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, newStub
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBulkLoadObserver, getEndpointObserver, getRegionObserver
private static final String NO_OF_VERSIONS_TO_DELETE
private static final org.slf4j.Logger LOG
private RegionCoprocessorEnvironment env
public BulkDeleteEndpoint()
public Iterable<com.google.protobuf.Service> getServices()
Coprocessor
getServices
in interface Coprocessor
Service
s or empty collection. Implementations should never
return null.public void delete(com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest request, com.google.protobuf.RpcCallback<org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteResponse> done)
org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService
rpc delete(.hbase.pb.BulkDeleteRequest) returns (.hbase.pb.BulkDeleteResponse);
delete
in class org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteService
private Delete createDeleteMutation(List<Cell> deleteRow, org.apache.hadoop.hbase.coprocessor.example.generated.BulkDeleteProtos.BulkDeleteRequest.DeleteType deleteType, Long timestamp)
public void start(CoprocessorEnvironment env) throws IOException
Coprocessor
CoprocessorEnvironment
during it's own startup to initialize the
coprocessor.start
in interface Coprocessor
IOException
public void stop(CoprocessorEnvironment env) throws IOException
Coprocessor
CoprocessorEnvironment
during it's own shutdown to stop the
coprocessor.stop
in interface Coprocessor
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.