org.apache.hadoop.hbase.coprocessor
Class MultiRowMutationEndpoint
java.lang.Object
org.apache.hadoop.hbase.protobuf.generated.MultiRowMutation.MultiRowMutationService
org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint
- All Implemented Interfaces:
- com.google.protobuf.Service, Coprocessor, CoprocessorService
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class MultiRowMutationEndpoint
- extends MultiRowMutation.MultiRowMutationService
- implements CoprocessorService, Coprocessor
This class demonstrates how to implement atomic multi row transactions using
HRegion.mutateRowsWithLocks(java.util.Collection, java.util.Collection)
and Coprocessor endpoints.
Defines a protocol to perform multi row transactions.
See MultiRowMutationEndpoint
for the implementation.
See
HRegion.mutateRowsWithLocks(java.util.Collection, java.util.Collection)
for details and limitations.
Example:
List mutations = ...;
Put p1 = new Put(row1);
Put p2 = new Put(row2);
...
Mutate m1 = ProtobufUtil.toMutate(MutateType.PUT, p1);
Mutate m2 = ProtobufUtil.toMutate(MutateType.PUT, p2);
MultiMutateRequest.Builder mrmBuilder = MultiMutateRequest.newBuilder();
mrmBuilder.addMutationRequest(m1);
mrmBuilder.addMutationRequest(m2);
CoprocessorRpcChannel channel = t.coprocessorService(ROW);
MultiRowMutationService.BlockingInterface service =
MultiRowMutationService.newBlockingStub(channel);
MultiMutateRequest mrm = mrmBuilder.build();
service.mutateRows(null, mrm);
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiRowMutationEndpoint
public MultiRowMutationEndpoint()
mutateRows
public void mutateRows(com.google.protobuf.RpcController controller,
MultiRowMutation.MultiMutateRequest request,
com.google.protobuf.RpcCallback<MultiRowMutation.MultiMutateResponse> done)
- Specified by:
mutateRows
in class MultiRowMutation.MultiRowMutationService
getService
public com.google.protobuf.Service getService()
- Specified by:
getService
in interface CoprocessorService
start
public void start(CoprocessorEnvironment env)
throws IOException
- Stores a reference to the coprocessor environment provided by the
RegionCoprocessorHost
from the region where this
coprocessor is loaded. Since this is a coprocessor endpoint, it always expects to be loaded
on a table region, so always expects this to be an instance of
RegionCoprocessorEnvironment
.
- Specified by:
start
in interface Coprocessor
- Parameters:
env
- the environment provided by the coprocessor host
- Throws:
IOException
- if the provided environment is not an instance of
RegionCoprocessorEnvironment
stop
public void stop(CoprocessorEnvironment env)
throws IOException
- Specified by:
stop
in interface Coprocessor
- Throws:
IOException
Copyright © 2013 The Apache Software Foundation. All Rights Reserved.