jklustor-overlap-0.0.2-20140619012940 (ChemAxon)


com.chemaxon.overlap.concurrent
Class ProcessPage<S,T>

Object
  extended by com.chemaxon.overlap.concurrent.ProcessPage<S,T>
Type Parameters:
S - Type of processed sources
T - type of results
All Implemented Interfaces:
Callable<ProcessPage<S,T>>

 class ProcessPage<S,T>
extends Object
implements Callable<ProcessPage<S,T>>

Process a page of inputs.

Synchronization is provided by the ExecutorService which processes this task. Note that call() is not expected to throw any Exception.

Author:
Gabor Imre

Constructor Summary
ProcessPage(int firstSourceIndex, List<S> sources)
          Create a failed page.
ProcessPage(int firstSourceIndex, List<S> sources, Function<S,T> process)
          Construct.
 
Method Summary
 ProcessPage<S,T> call()
           
(package private)  ProcessPage<S,T> createFailedPage()
          Create a page representing the same inputs with all failed state.
(package private)  String[] getSourcesAsStrings()
          Get sources String representation.
(package private)  int getSourcesCount()
          Get number of represented sources.
(package private)  long reportResults(ErrorHandler<S> processError, ResultHandler<S,T> target)
          Flush calculated results to sinks.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessPage

ProcessPage(int firstSourceIndex,
            List<S> sources,
            Function<S,T> process)
Construct.

Parameters:
firstSourceIndex - Index of first source
sources - Sources to process; must contain at least one element
process - Process function
Throws:
IllegalArgumentException - when sources is empty

ProcessPage

ProcessPage(int firstSourceIndex,
            List<S> sources)
Create a failed page.

Parameters:
firstSourceIndex - Index of first source
sources - Sources
Throws:
IllegalArgumentException - when sources is empty
Method Detail

call

public ProcessPage<S,T> call()
                      throws Exception
Specified by:
call in interface Callable<ProcessPage<S,T>>
Throws:
Exception

createFailedPage

ProcessPage<S,T> createFailedPage()
Create a page representing the same inputs with all failed state.

Returns:
A separate copy with all failed state

getSourcesCount

int getSourcesCount()
Get number of represented sources.

Returns:
Number of represented sources

getSourcesAsStrings

String[] getSourcesAsStrings()
Get sources String representation.

Returns:
Array of String representations resulted from invoking Object.toString() on represented sources

reportResults

long reportResults(ErrorHandler<S> processError,
                   ResultHandler<S,T> target)
Flush calculated results to sinks.

Note that runtime exceptions from callback methods will propagate.

Parameters:
processError - Error handler
target - Result handler
Returns:
Work units processed
Throws:
IllegalStateException - when call() was not invoked before

jklustor-overlap-0.0.2-20140619012940 (ChemAxon)