com.bigdata.resources
Class MoveTask.AtomicUpdate

java.lang.Object
  extended by com.bigdata.journal.AbstractTask<T>
      extended by com.bigdata.resources.AbstractResourceManagerTask<T>
          extended by com.bigdata.resources.AbstractAtomicUpdateTask<MoveResult>
              extended by com.bigdata.resources.MoveTask.AtomicUpdate
All Implemented Interfaces:
ITask<MoveResult>, Callable<MoveResult>
Enclosing class:
MoveTask

protected static class MoveTask.AtomicUpdate
extends AbstractAtomicUpdateTask<MoveResult>

Moves an index partition from this data service to another data service.

This is an "atomic update" operation. It moves an index segment (supplied by the caller) containing the historical view of the source index partition and generates and moves an index segment containing any buffered writes on the live journal for the source index partition to the target data service. Once the target index partition is registered on the target data service and the IMetadataService has been updated to reflect the move, this task updates the stale locator cache. At that point clients addressing tasks to the source index partition will discover that it has been moved.

Note: If the operation fails, then it has no side-effects but the caller is responsible for deleting the historicalWritesBuildResult iff that is deemed necessary (that is, if it is not in use then either put it to use or delete it -- an attractive alternative is to incorporate it into the source index partition view instead.)

Tasks executing after this one will discover that the source index partition no longer exists as of the timestamp when this task commits. Clients that submit tasks for the source index partition will be notified that it no longer exists. When the client queries the MetadataService it will discover that the key range has been assigned to a new index partition - the one on the target data service.

Note: This task runs as an ITx.UNISOLATED operation since it MUST have an exclusive lock in order to ensure that the buffered writes are transferred to the target index partition without allowing concurrent writes on the source index partition.

Note: I have placed the "receive" of the historical index partition view within the atomic update task deliberately. It should add at most a few seconds to the execution time of that task and makes it easier to write corrective actions for the atomic update since we can offer a guarantees such that the existence of the target index partition on the target data service is sufficient to determine that the entire operation was successful.

Author:
Bryan Thompson
TODO:
optimization to NOT send an empty index segment if there are no buffered writes on the live journal.

Nested Class Summary
 
Nested classes/interfaces inherited from class com.bigdata.journal.AbstractTask
AbstractTask.DelegateTask<T>, AbstractTask.InnerReadWriteTxServiceCallable, AbstractTask.InnerWriteServiceCallable<T>, AbstractTask.ResubmitException
 
Field Summary
 
Fields inherited from class com.bigdata.resources.AbstractResourceManagerTask
DEBUG, INFO, log
 
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 MoveTask.AtomicUpdate(ResourceManager resourceManager, String sourceIndexName, BuildResult historicalWritesBuildResult, UUID targetDataServiceUUID, int targetIndexPartitionId, Event parentEvent)
           
 
Method Summary
 MoveResult doTask()
          Atomic update (move).
 
Methods inherited from class com.bigdata.resources.AbstractAtomicUpdateTask
assertSameIndex
 
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
 

Constructor Detail

MoveTask.AtomicUpdate

protected MoveTask.AtomicUpdate(ResourceManager resourceManager,
                                String sourceIndexName,
                                BuildResult historicalWritesBuildResult,
                                UUID targetDataServiceUUID,
                                int targetIndexPartitionId,
                                Event parentEvent)
Parameters:
resourceManager - The resource manager.
sourceIndexName - The name of the source index partition.
historicalWritesBuildResult - An index segment containing all data for the source view as of the last commit time on the old journal. This index segment should be generated by a compacting merge or by an index partition split with the same semantics so that we will move the minimum amount of data.
targetDataServiceUUID - The UUID of the target data service.
targetIndexPartitionId - The partition identifier assigned to the target index partition.
parentEvent -
Method Detail

doTask

public MoveResult doTask()
                  throws Exception
Atomic update (move).

Specified by:
doTask in class AbstractTask<MoveResult>
Returns:
A MoveResult describing the operation (this is returned mainly for historical reasons).
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.


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