C# Class Summer.Batch.Infrastructure.Repeat.Support.RepeatTemplate

Simple implementation and base class for batch templates implementing RepeatOperations. Provides a framework including interceptors and policies. Subclasses just need to provide a method that gets the next result and one that waits for all the results to be returned from concurrent processes or threads. N.B. the template accumulates thrown exceptions during the iteration, and they are all processed together when the main loop ends (i.e. finished processing the items). Clients that do not want to stop execution when an exception is thrown can use a specific ICompletionPolicy that does not finish when exceptions are received. This is not the default behaviour. Clients that want to take some business action when an exception is thrown by the IRepeatCallback can consider using a custom IRepeatListener instead of trying to customise the ICompletionPolicy. This is generally a friendlier interface to implement, and the IRepeatListener#After(RepeatContext, RepeatStatus) method is passed in the result of the callback, which would be an instance of Exception if the business processing had thrown an exception. If the exception is not to be propagated to the caller, then a non-default ICompletionPolicy needs to be provided as well, but that could be off the shelf, with the business action implemented only in the interceptor.
Inheritance: IRepeatOperations
Afficher le fichier Open project: SummerBatch/SummerBatch

Protected Properties

Свойство Type Description
Logger NLog.Logger

Méthodes publiques

Méthode Description
Iterate ( RepeatCallback callback ) : RepeatStatus

Execute the batch callback until the completion policy decides that we are finished. Wait for the whole batch to finish before returning even if the task executor is asynchronous.

RegisterListener ( IRepeatListener listener ) : void

Registers given listener.

SetListeners ( IRepeatListener listeners ) : void

Registers array of listeners.

Méthodes protégées

Méthode Description
CanContinue ( RepeatStatus value ) : bool

Check return value from batch operation.

CreateInternalState ( IRepeatContext context ) : IRepeatInternalState

Create an internal state object that is used to store data needed internally in the scope of an iteration. Used by subclasses to manage the queueing and retrieval of asynchronous results. The default just provides an accumulation of exceptions instances for processing at the end of the batch.

ExecuteAfterInterceptors ( IRepeatContext context, RepeatStatus value ) : void

Convenience method to execute after interceptors on a callback result.

GetNextResult ( IRepeatContext context, RepeatCallback callback, IRepeatInternalState state ) : RepeatStatus

Get the next completed result, possibly executing several callbacks until one finally finishes. Normally a subclass would have to override both this method and CreateInternalState because the implementation of this method would rely on the details of the internal state.

IsComplete ( IRepeatContext context ) : bool

Delegates to the Completion policy.

IsComplete ( IRepeatContext context, RepeatStatus result ) : bool

Delegates to the Completion policy.

Start ( ) : IRepeatContext

Delegates the start to the Completion policy.

Update ( IRepeatContext context ) : void

Delegates to the completion policy.

WaitForResults ( IRepeatInternalState state ) : bool

If necessary, wait for results to come back from remote or concurrent processes. By default does nothing and returns true.

Private Methods

Méthode Description
DoHandle ( System exception, IRepeatContext context, ICollection deferred ) : void

Handling exceptions.

ExecuteInternal ( RepeatCallback callback ) : RepeatStatus

HandleFinally ( ICollection deferred, IRepeatListener listeners, IRepeatContext context ) : void

Handling the finally from ExecuteInternal.

IsMarkedComplete ( IRepeatContext context ) : bool

Check that given context is marked as completed.

Rethrow ( System exception ) : void

rethrow the exception wrapped into a RepeatException.

UnwrapIfRethrown ( System exception ) : System.Exception

Unwrap the exception id it has been wrapped into a RepeatException.

Method Details

CanContinue() protected méthode

Check return value from batch operation.
protected CanContinue ( RepeatStatus value ) : bool
value RepeatStatus
Résultat bool

CreateInternalState() protected méthode

Create an internal state object that is used to store data needed internally in the scope of an iteration. Used by subclasses to manage the queueing and retrieval of asynchronous results. The default just provides an accumulation of exceptions instances for processing at the end of the batch.
protected CreateInternalState ( IRepeatContext context ) : IRepeatInternalState
context IRepeatContext
Résultat IRepeatInternalState

ExecuteAfterInterceptors() protected méthode

Convenience method to execute after interceptors on a callback result.
protected ExecuteAfterInterceptors ( IRepeatContext context, RepeatStatus value ) : void
context IRepeatContext
value RepeatStatus
Résultat void

GetNextResult() protected méthode

Get the next completed result, possibly executing several callbacks until one finally finishes. Normally a subclass would have to override both this method and CreateInternalState because the implementation of this method would rely on the details of the internal state.
 
protected GetNextResult ( IRepeatContext context, RepeatCallback callback, IRepeatInternalState state ) : RepeatStatus
context IRepeatContext
callback RepeatCallback
state IRepeatInternalState
Résultat RepeatStatus

IsComplete() protected méthode

Delegates to the Completion policy.
protected IsComplete ( IRepeatContext context ) : bool
context IRepeatContext
Résultat bool

IsComplete() protected méthode

Delegates to the Completion policy.
protected IsComplete ( IRepeatContext context, RepeatStatus result ) : bool
context IRepeatContext
result RepeatStatus
Résultat bool

Iterate() public méthode

Execute the batch callback until the completion policy decides that we are finished. Wait for the whole batch to finish before returning even if the task executor is asynchronous.
public Iterate ( RepeatCallback callback ) : RepeatStatus
callback RepeatCallback
Résultat RepeatStatus

RegisterListener() public méthode

Registers given listener.
public RegisterListener ( IRepeatListener listener ) : void
listener IRepeatListener
Résultat void

SetListeners() public méthode

Registers array of listeners.
public SetListeners ( IRepeatListener listeners ) : void
listeners IRepeatListener
Résultat void

Start() protected méthode

Delegates the start to the Completion policy.
protected Start ( ) : IRepeatContext
Résultat IRepeatContext

Update() protected méthode

Delegates to the completion policy.
protected Update ( IRepeatContext context ) : void
context IRepeatContext
Résultat void

WaitForResults() protected méthode

If necessary, wait for results to come back from remote or concurrent processes. By default does nothing and returns true.
protected WaitForResults ( IRepeatInternalState state ) : bool
state IRepeatInternalState
Résultat bool

Property Details

Logger protected_oe static_oe property

Logger
protected static Logger,NLog Logger
Résultat NLog.Logger