com.atlassian.confluence.content.render.xhtml.migration
Class WorkSourceBatchRunner<T>

java.lang.Object
  extended by com.atlassian.confluence.content.render.xhtml.migration.WorkSourceBatchRunner<T>
Type Parameters:
T - the type of item that will be in the batches

public class WorkSourceBatchRunner<T>
extends java.lang.Object

This class is typically the basis for upgrade or migration tasks that need to manipulate a large amount of content. It will use a parameterised number of worker threads to operate on batches of content as specified by a supplied BatchableWorkSource.

Each batch of work will occur within its own transaction.


Constructor Summary
WorkSourceBatchRunner(java.lang.String threadName, int numThreads, org.springframework.transaction.PlatformTransactionManager transactionManager)
           
 
Method Summary
 java.util.List<java.lang.Exception> run(BatchableWorkSource<T> workSource, BatchTask<T> task)
          Begin executing against all the work in the supplied work source.
protected  java.util.List<java.lang.Exception> run(BatchableWorkSource<T> workSource, BatchTask<T> task, java.util.concurrent.ExecutorService executor)
          Exposed (as protected) to allow specification of the executor in unit tests.
 void setProgressWrapper(com.atlassian.core.util.ProgressMeter progress)
           
 void shutdown()
          Deprecated. since 5.2. The executor will be constructed and shutdown during the run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkSourceBatchRunner

public WorkSourceBatchRunner(java.lang.String threadName,
                             int numThreads,
                             org.springframework.transaction.PlatformTransactionManager transactionManager)
Method Detail

run

protected java.util.List<java.lang.Exception> run(BatchableWorkSource<T> workSource,
                                                  BatchTask<T> task,
                                                  java.util.concurrent.ExecutorService executor)
                                           throws java.util.concurrent.ExecutionException,
                                                  java.lang.InterruptedException
Exposed (as protected) to allow specification of the executor in unit tests.

Parameters:
workSource -
task -
executor -
Returns:
Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException

run

public java.util.List<java.lang.Exception> run(BatchableWorkSource<T> workSource,
                                               BatchTask<T> task)
                                        throws java.util.concurrent.ExecutionException,
                                               java.lang.InterruptedException
Begin executing against all the work in the supplied work source. One or more threads will be spawned to perform the work but this method will wait until all threads have finished before it returns.

Parameters:
workSource -
task - the task to be run on each item in the batches from the work source
Returns:
a list of any individual exceptions that occurred as the WorkSourceTask was executing. An empty list will be returned if there are no exceptions.
Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.lang.Exception - if there is any problem out with the actual execution of the the BatchTasks. (Problems within the BatchTask are returned in the List of Exceptions.)

shutdown

@Deprecated
public void shutdown()
Deprecated. since 5.2. The executor will be constructed and shutdown during the run.


setProgressWrapper

public void setProgressWrapper(com.atlassian.core.util.ProgressMeter progress)


Copyright © 2003-2014 Atlassian. All Rights Reserved.