Package org.snpeff.akka
Class Master<TI,TO>
- java.lang.Object
-
- org.snpeff.akka.ConcurrentActor
-
- org.snpeff.akka.Master<TI,TO>
-
- Type Parameters:
TI-TO-
- All Implemented Interfaces:
java.lang.Iterable<TI>,java.util.Iterator<TI>
- Direct Known Subclasses:
MasterVcf
public abstract class Master<TI,TO> extends ConcurrentActor implements java.lang.Iterable<TI>, java.util.Iterator<TI>
Master: Distributes the jobs to all workers, sends the results to 'listener'- Author:
- pablocingolani
-
-
Field Summary
Fields Modifier and Type Field Description protected intbatchSizeprotected java.util.concurrent.CompletionService<Result<TO>>completionprotected intcountInputObjectsstatic booleandebugstatic intDEFAULT_BATCH_SIZEstatic intDEFAULT_SHOW_EVERYstatic intLOAD_FACTORprotected longnextOutputprotected intnumWorkersprotected java.util.concurrent.ExecutorServicepoolprotected ConcurrentPropertiespropsprotected intsentWorksprotected intshowEveryprotected java.util.HashMap<java.lang.Long,Result<TO>>worksBySerial
-
Constructor Summary
Constructors Constructor Description Master(ConcurrentProperties props, int numWorkers)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidget(java.lang.Object message)Master-receive: Handle-messagesabstract booleanhasNext()java.lang.Iterable<Work<TI>>iterableWork()Return a class that iterates Works (creates works)java.util.Iterator<TI>iterator()abstract TInext()Get next itemprotected voidoutput(Result<TO> result)Output all contents of a resultprotected voidoutput(TO output)Output a result datum You should probably override this methodprotected voidprocessResults(Result<TO> result)Print results in the same order they were sent to the processing queue (i.e.voidremove()protected voidstartMaster(StartMaster startMaster)This is executed when the 'start' message arrives (at the beginning of the processing)
-
-
-
Field Detail
-
LOAD_FACTOR
public static int LOAD_FACTOR
-
DEFAULT_SHOW_EVERY
public static final int DEFAULT_SHOW_EVERY
- See Also:
- Constant Field Values
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE
- See Also:
- Constant Field Values
-
debug
public static boolean debug
-
batchSize
protected int batchSize
-
showEvery
protected int showEvery
-
nextOutput
protected long nextOutput
-
countInputObjects
protected int countInputObjects
-
numWorkers
protected int numWorkers
-
sentWorks
protected int sentWorks
-
pool
protected java.util.concurrent.ExecutorService pool
-
props
protected ConcurrentProperties props
-
-
Constructor Detail
-
Master
public Master(ConcurrentProperties props, int numWorkers)
Constructor- Parameters:
numWorkers- : How may workers will be usedlistener- : Listener
-
-
Method Detail
-
hasNext
public abstract boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<TI>
-
iterableWork
public java.lang.Iterable<Work<TI>> iterableWork()
Return a class that iterates Works (creates works)- Returns:
-
iterator
public java.util.Iterator<TI> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<TI>
-
next
public abstract TI next()
Get next item- Specified by:
nextin interfacejava.util.Iterator<TI>- Returns:
-
get
public void get(java.lang.Object message)
Master-receive: Handle-messages
-
output
protected void output(Result<TO> result)
Output all contents of a result- Parameters:
result-
-
output
protected void output(TO output)
Output a result datum You should probably override this method- Parameters:
result-
-
processResults
protected void processResults(Result<TO> result)
Print results in the same order they were sent to the processing queue (i.e. ordered by Work.serialNumber)- Parameters:
result-
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<TI>
-
startMaster
protected void startMaster(StartMaster startMaster)
This is executed when the 'start' message arrives (at the beginning of the processing)- Parameters:
startMaster-
-
-