org.apache.hadoop.hbase.regionserver
Interface RowProcessor<S extends com.google.protobuf.Message,T extends com.google.protobuf.Message>

All Known Implementing Classes:
BaseRowProcessor

@InterfaceAudience.LimitedPrivate(value="Coprocesssor")
@InterfaceStability.Evolving
public interface RowProcessor<S extends com.google.protobuf.Message,T extends com.google.protobuf.Message>

Defines the procedure to atomically perform multiple scans and mutations on a HRegion. This is invoked by HRegion#processRowsWithLocks(). This class performs scans and generates mutations and WAL edits. The locks and MVCC will be handled by HRegion. The RowProcessor user code could have data that needs to be sent across for proper initialization at the server side. The generic type parameter S is the type of the request data sent to the server. The generic type parameter T is the return type of RowProcessor.getResult().


Method Summary
 List<UUID> getClusterIds()
           
 String getName()
          Human readable name of the processor
 S getRequestData()
          This method should return any additional data that is needed on the server side to construct the RowProcessor.
 T getResult()
          Obtain the processing result.
 Collection<byte[]> getRowsToLock()
          Rows to lock while operation.
 void initialize(S msg)
          This method should initialize any field(s) of the RowProcessor with a parsing of the passed message bytes (used on the server side).
 void postBatchMutate(HRegion region)
          The hook to be executed after the process() and applying the Mutations to region.
 void postProcess(HRegion region, WALEdit walEdit, boolean success)
          The hook to be executed after process() and applying the Mutations to region.
 void preBatchMutate(HRegion region, WALEdit walEdit)
          The hook to be executed after the process() but before applying the Mutations to region.
 void preProcess(HRegion region, WALEdit walEdit)
          The hook to be executed before process().
 void process(long now, HRegion region, List<Mutation> mutations, WALEdit walEdit)
          HRegion handles the locks and MVCC and invokes this method properly.
 boolean readOnly()
          Is this operation read only? If this is true, process() should not add any mutations or it throws IOException.
 Durability useDurability()
           
 

Method Detail

getRowsToLock

Collection<byte[]> getRowsToLock()
Rows to lock while operation. They have to be sorted with RowProcessor to avoid deadlock.


getResult

T getResult()
Obtain the processing result. All row processor implementations must implement this, even if the method is simply returning an empty Message.


readOnly

boolean readOnly()
Is this operation read only? If this is true, process() should not add any mutations or it throws IOException.

Returns:
ture if read only operation

process

void process(long now,
             HRegion region,
             List<Mutation> mutations,
             WALEdit walEdit)
             throws IOException
HRegion handles the locks and MVCC and invokes this method properly. You should override this to create your own RowProcessor. If you are doing read-modify-write here, you should consider using IsolationLevel.READ_UNCOMMITTED for scan because we advance MVCC after releasing the locks for optimization purpose.

Parameters:
now - the current system millisecond
region - the HRegion
mutations - the output mutations to apply to memstore
walEdit - the output WAL edits to apply to write ahead log
Throws:
IOException

preProcess

void preProcess(HRegion region,
                WALEdit walEdit)
                throws IOException
The hook to be executed before process().

Parameters:
region - the HRegion
walEdit - the output WAL edits to apply to write ahead log
Throws:
IOException

preBatchMutate

void preBatchMutate(HRegion region,
                    WALEdit walEdit)
                    throws IOException
The hook to be executed after the process() but before applying the Mutations to region. Also by the time this hook is been called, mvcc transaction is started.

Parameters:
region -
walEdit - the output WAL edits to apply to write ahead log
Throws:
IOException

postBatchMutate

void postBatchMutate(HRegion region)
                     throws IOException
The hook to be executed after the process() and applying the Mutations to region. The difference of this one with postProcess(HRegion, WALEdit, boolean) is this hook will be executed before the mvcc transaction completion.

Parameters:
region -
Throws:
IOException

postProcess

void postProcess(HRegion region,
                 WALEdit walEdit,
                 boolean success)
                 throws IOException
The hook to be executed after process() and applying the Mutations to region.

Parameters:
region - the HRegion
walEdit - the output WAL edits to apply to write ahead log
success - true if batch operation is successful otherwise false.
Throws:
IOException

getClusterIds

List<UUID> getClusterIds()
Returns:
The cluster ids that have the change.

getName

String getName()
Human readable name of the processor

Returns:
The name of the processor

getRequestData

S getRequestData()
                                                     throws IOException
This method should return any additional data that is needed on the server side to construct the RowProcessor. The server will pass this to the initialize(Message msg) method. If there is no RowProcessor specific data then null should be returned.

Returns:
the PB message
Throws:
IOException

initialize

void initialize(S msg)
                throws IOException
This method should initialize any field(s) of the RowProcessor with a parsing of the passed message bytes (used on the server side).

Parameters:
msg -
Throws:
IOException

useDurability

Durability useDurability()
Returns:
The Durability to use


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.