Class 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 Detail

      • LOAD_FACTOR

        public static int LOAD_FACTOR
      • 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
      • worksBySerial

        protected java.util.HashMap<java.lang.Long,​Result<TO>> worksBySerial
      • pool

        protected java.util.concurrent.ExecutorService pool
      • completion

        protected java.util.concurrent.CompletionService<Result<TO>> completion
    • Constructor Detail

      • Master

        public Master​(ConcurrentProperties props,
                      int numWorkers)
        Constructor
        Parameters:
        numWorkers - : How may workers will be used
        listener - : Listener
    • Method Detail

      • hasNext

        public abstract boolean hasNext()
        Specified by:
        hasNext in interface java.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:
        iterator in interface java.lang.Iterable<TI>
      • next

        public abstract TI next()
        Get next item
        Specified by:
        next in interface java.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:
        remove in interface java.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 -