com.bigdata.resources
Class SplitIndexPartitionTask

java.lang.Object
  extended by com.bigdata.journal.AbstractTask<T>
      extended by com.bigdata.resources.AbstractResourceManagerTask<T>
          extended by com.bigdata.resources.AbstractPrepareTask<AbstractResult>
              extended by com.bigdata.resources.SplitIndexPartitionTask
All Implemented Interfaces:
ITask<AbstractResult>, Callable<AbstractResult>

public class SplitIndexPartitionTask
extends AbstractPrepareTask<AbstractResult>

Task splits an index partition which is a compact view (no more than one journal and one index segment) and should be invoked when the size of the index segment on the disk exceeds the nominal size of an index partition. The index partition is the result of a compacting merge, which could have been created by IncrementalBuildTask or CompactingMergeTask. The index partition is passed into this task because it is not yet part of the view. Based on the nominal size of the index partition and the size of the segment, N=segSize/nominalSize splits will be generated, requiring N-1 separator keys.

The task uses the linear list API to identify N-1 separator key which would split the index segment and assumes that the data is evenly distributed across the keys within the index segment. The buffered writes are ignored when determining the separator keys (most data will be on the index segment if the journal extent roughly the same as the nominal index segment extent and multiple index partitions are registered on the journal). Application constraints on the choice of the separator keys will be honored and can result in fewer splits being generated.

Once the N-1 split points have been selected, N index segments are built - one from each of the N key ranges which those N-1 split points define. Once the index segment for each split has been built, an SplitIndexPartitionTask.AtomicUpdateSplitIndexPartitionTask will atomically re-define the source index partition as N new index partition and copy the buffered writes into the appropriate index partition. During the atomic update the original index partition becomes un-defined and new index partitions are defined in its place which span the same total key range and have the same data.

Version:
$Id: SplitIndexPartitionTask.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
AtomicUpdateSplitIndexPartitionTask, which MUST be invoked in order to update the index partition definitions on the live journal and the {@link MetadataIndex} as an atomic operation.

Nested Class Summary
protected static class SplitIndexPartitionTask.AtomicUpdateSplitIndexPartitionTask
          An ITx.UNISOLATED operation that splits the live index using the same Split points, generating new index partitions with new partition identifiers.
 
Nested classes/interfaces inherited from class com.bigdata.journal.AbstractTask
AbstractTask.DelegateTask<T>, AbstractTask.InnerReadWriteTxServiceCallable, AbstractTask.InnerWriteServiceCallable<T>, AbstractTask.ResubmitException
 
Field Summary
protected  UUID[] moveTargets
           
protected  com.bigdata.resources.ViewMetadata vmd
           
 
Fields inherited from class com.bigdata.resources.AbstractResourceManagerTask
DEBUG, INFO, log, resourceManager
 
Fields inherited from class com.bigdata.journal.AbstractTask
checkpointNanoTime, concurrencyManager, isReadWriteTx, nanoTime_assignedWorker, nanoTime_beginWork, nanoTime_finishedWork, nanoTime_submitTask, readOnly, taskCounters, timestamp, transactionManager, tx
 
Constructor Summary
protected SplitIndexPartitionTask(com.bigdata.resources.ViewMetadata vmd, UUID moveTarget)
           
protected SplitIndexPartitionTask(com.bigdata.resources.ViewMetadata vmd, UUID[] moveTargets)
           
 
Method Summary
protected  void clearRefs()
          Method is responsible for clearing the SoftReferences held by ViewMetadata for the source view(s) on the old journal.
protected static void doSplitAtomicUpdate(ResourceManager resourceManager, com.bigdata.resources.ViewMetadata vmd, SplitResult result, OverflowActionEnum action, AtomicLong counter, Event parentEvent)
           
protected  AbstractResult doTask()
          Decides how many index partitions should be generated (N) and builds N IndexSegments from the source index partition.
 
Methods inherited from class com.bigdata.resources.AbstractResourceManagerTask
toString
 
Methods inherited from class com.bigdata.journal.AbstractTask
assertResource, assertRunning, assertUnisolated, call, clearLoggingContext, dropIndex, getCommitTime, getIndex, getJournal, getOnlyResource, getResource, getResourceManager, getTaskCounters, getTaskName, getTimestamp, isResource, registerIndex, setupLoggingContext, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vmd

protected final com.bigdata.resources.ViewMetadata vmd

moveTargets

protected final UUID[] moveTargets
Constructor Detail

SplitIndexPartitionTask

protected SplitIndexPartitionTask(com.bigdata.resources.ViewMetadata vmd,
                                  UUID moveTarget)
Parameters:
vmd -
moveTarget - When non-null the new right-sibling (the tail) will be moved to the specified data service after the split.

SplitIndexPartitionTask

protected SplitIndexPartitionTask(com.bigdata.resources.ViewMetadata vmd,
                                  UUID[] moveTargets)
Parameters:
vmd -
moveTargets - When non-null the index partitions generated by the split will be moved to the identified data services. If this data service is included in the array, then an index partition will be left on this data service. If the array contains a single element, then only the rightSibling of the split will be moved.
Method Detail

clearRefs

protected void clearRefs()
Description copied from class: AbstractPrepareTask
Method is responsible for clearing the SoftReferences held by ViewMetadata for the source view(s) on the old journal.

Note: This method MUST be invoked in order to permit those references to be cleared more eagerly than the end of the entire asynchronous overflow operation (which is when the task references would themselves go out of scope and become available for GC).

Specified by:
clearRefs in class AbstractPrepareTask<AbstractResult>

doTask

protected AbstractResult doTask()
                         throws Exception
Decides how many index partitions should be generated (N) and builds N IndexSegments from the source index partition. If N will be ONE (1) if a detailed inspection of the source index partition reveals that it SHOULD NOT be split.

Specified by:
doTask in class AbstractTask<AbstractResult>
Returns:
A SplitResult if the index partition was split into 2 or more index partitions -or- a BuildResult iff the index partition was not split.
Throws:
Exception - The exception that will be thrown by AbstractTask.call() iff the operation fails.
InterruptedException - This exception SHOULD be thrown if Thread.interrupted() becomes true during execution.

doSplitAtomicUpdate

protected static void doSplitAtomicUpdate(ResourceManager resourceManager,
                                          com.bigdata.resources.ViewMetadata vmd,
                                          SplitResult result,
                                          OverflowActionEnum action,
                                          AtomicLong counter,
                                          Event parentEvent)
Parameters:
resourceManager -
vmd -
splits -
result -
action -
counter -
parentEvent -


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