com.bigdata.service.ndx
Class AbstractScaleOutClientIndexView2

java.lang.Object
  extended by com.bigdata.service.ndx.AbstractScaleOutClientIndexView
      extended by com.bigdata.service.ndx.AbstractScaleOutClientIndexView2
All Implemented Interfaces:
IAutoboxBTree, IIndex, IRangeQuery, ISimpleBTree, IAsynchronousWriteBufferFactory, IClientIndex, IScaleOutClientIndex, ISplitter
Direct Known Subclasses:
ClientIndexViewRefactor

public abstract class AbstractScaleOutClientIndexView2
extends AbstractScaleOutClientIndexView

Abstract class encapsulating MOST of the logic for executing tasks corresponding to client index operations. StaleLocatorExceptions are handled by the recursive application of the various submit() methods.

A concrete subclass must implement runTasks(boolean, ArrayList).

Version:
$Id: AbstractScaleOutClientIndexView2.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson

Field Summary
 
Fields inherited from class com.bigdata.service.ndx.AbstractScaleOutClientIndexView
batchOnly, ERR_ABORT_TX, ERR_NEW_TX, fed, log, name, NON_BATCH_API, readConsistent, taskTimeout, timestamp, WARN
 
Fields inherited from interface com.bigdata.btree.IRangeQuery
ALL, CURSOR, DEFAULT, DELETED, FIXED_LENGTH_SUCCESSOR, KEYS, NONE, PARALLEL, READONLY, REMOVEALL, REVERSE, VALS
 
Constructor Summary
AbstractScaleOutClientIndexView2(AbstractScaleOutFederation fed, String name, long timestamp, IMetadataIndex metadataIndex)
          Create a view on a scale-out index.
 
Method Summary
 AtomicInteger getRecursionDepth()
          Return a ThreadLocal AtomicInteger whose value is the recursion depth of the current Thread.
protected abstract  void runTasks(boolean parallel, ArrayList<com.bigdata.service.ndx.AbstractDataServiceProcedureTask> tasks)
          Runs set of tasks.
protected  void submit(long ts, byte[] fromKey, byte[] toKey, IKeyRangeIndexProcedure proc, IResultHandler resultHandler)
          Variant uses the caller's timestamp.
protected  Object submit(long ts, byte[] key, ISimpleIndexProcedure proc)
          Variant uses the caller's timestamp.
protected  void submit(long ts, int fromIndex, int toIndex, byte[][] keys, byte[][] vals, AbstractKeyArrayIndexProcedureConstructor ctor, IResultHandler aggregator)
          Variant uses the caller's timestamp.
 
Methods inherited from class com.bigdata.service.ndx.AbstractScaleOutClientIndexView
contains, contains, getCounter, getCounters, getDataService, getFederation, getIndexMetadata, getMetadataIndex, getMetadataIndexMetadata, getMetadataService, getName, getResourceMetadata, getThreadPool, getTimestamp, getTupleSerializer, insert, insert, locatorScan, lookup, lookup, newWriteBuffer, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator, remove, remove, splitKeys, splitKeys, staleLocator, submit, submit, submit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractScaleOutClientIndexView2

public AbstractScaleOutClientIndexView2(AbstractScaleOutFederation fed,
                                        String name,
                                        long timestamp,
                                        IMetadataIndex metadataIndex)
Create a view on a scale-out index.

Parameters:
fed - The federation containing the index.
name - The index name.
timestamp - A transaction identifier, ITx.UNISOLATED for the unisolated index view, ITx.READ_COMMITTED, or timestamp for a historical view no later than the specified timestamp.
metadataIndex - The IMetadataIndex for the named scale-out index as of that timestamp. Note that the IndexMetadata on this object contains the template IndexMetadata for the scale-out index partitions.
Method Detail

getRecursionDepth

public final AtomicInteger getRecursionDepth()
Description copied from interface: IScaleOutClientIndex
Return a ThreadLocal AtomicInteger whose value is the recursion depth of the current Thread. This is initially zero when the task is submitted by the application. The value incremented when a task results in a StaleLocatorException and is decremented when returning from the recursive handling of the StaleLocatorException.

The recursion depth is used:

  1. to limit the #of retries due to StaleLocatorExceptions for a split of a task submitted by the application
  2. to force execution of retried tasks in the caller's thread.
The latter point is critical - if the retry tasks are run in the client thread pool then all threads in the pool can rapidly become busy awaiting retry tasks with the result that the client is essentially deadlocked.

Returns:
The recursion depth.

runTasks

protected abstract void runTasks(boolean parallel,
                                 ArrayList<com.bigdata.service.ndx.AbstractDataServiceProcedureTask> tasks)
Runs set of tasks.

Parameters:
parallel - true iff the tasks MAY be run in parallel.
tasks - The tasks to be executed.

submit

protected Object submit(long ts,
                        byte[] key,
                        ISimpleIndexProcedure proc)
Variant uses the caller's timestamp.

Specified by:
submit in class AbstractScaleOutClientIndexView
Parameters:
ts -
key -
proc -
Returns:

submit

protected void submit(long ts,
                      byte[] fromKey,
                      byte[] toKey,
                      IKeyRangeIndexProcedure proc,
                      IResultHandler resultHandler)
Variant uses the caller's timestamp.

Specified by:
submit in class AbstractScaleOutClientIndexView
Parameters:
ts -
fromKey -
toKey -
proc -
resultHandler -

submit

protected void submit(long ts,
                      int fromIndex,
                      int toIndex,
                      byte[][] keys,
                      byte[][] vals,
                      AbstractKeyArrayIndexProcedureConstructor ctor,
                      IResultHandler aggregator)
Variant uses the caller's timestamp.

Specified by:
submit in class AbstractScaleOutClientIndexView
Parameters:
ts -
fromIndex -
toIndex -
keys -
vals -
ctor -
aggregator -


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.