org.apache.hadoop.hbase.coprocessor
Class MultiRowMutationEndpoint

java.lang.Object
  extended by org.apache.hadoop.hbase.protobuf.generated.MultiRowMutation.MultiRowMutationService
      extended by 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);
 


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hbase.protobuf.generated.MultiRowMutation.MultiRowMutationService
MultiRowMutation.MultiRowMutationService.BlockingInterface, MultiRowMutation.MultiRowMutationService.Interface, MultiRowMutation.MultiRowMutationService.Stub
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.Coprocessor
Coprocessor.State
 
Field Summary
 
Fields inherited from interface org.apache.hadoop.hbase.Coprocessor
PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SYSTEM, PRIORITY_USER, VERSION
 
Constructor Summary
MultiRowMutationEndpoint()
           
 
Method Summary
 com.google.protobuf.Service getService()
           
 void mutateRows(com.google.protobuf.RpcController controller, MultiRowMutation.MultiMutateRequest request, com.google.protobuf.RpcCallback<MultiRowMutation.MultiMutateResponse> done)
           
 void start(CoprocessorEnvironment env)
          Stores a reference to the coprocessor environment provided by the RegionCoprocessorHost from the region where this coprocessor is loaded.
 void stop(CoprocessorEnvironment env)
           
 
Methods inherited from class org.apache.hadoop.hbase.protobuf.generated.MultiRowMutation.MultiRowMutationService
callMethod, getDescriptor, getDescriptorForType, getRequestPrototype, getResponsePrototype, newBlockingStub, newReflectiveBlockingService, newReflectiveService, newStub
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiRowMutationEndpoint

public MultiRowMutationEndpoint()
Method Detail

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.