Package jadex.commons

Class ConstantPoolStrategy

  • All Implemented Interfaces:
    IPoolStrategy

    public class ConstantPoolStrategy
    extends java.lang.Object
    implements IPoolStrategy
    Simple strategy with a constant number of workers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int capacity
      The number of free workers.
      protected int workercnt
      The number of workers in the pool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCapacity()
      Get the number of free workers.
      int getWorkerCount()
      Get the worker cnt.
      long getWorkerTimeout()
      Get the component timeout.
      boolean taskAdded()
      Called when a new task was added to the pool.
      boolean taskFinished()
      Called when a task is finished.
      void taskServed​(long waitdur)
      Called when a new task was served from the pool.
      void workersAdded​(int cnt)
      Called when a new worker was added proactively to the pool.
      boolean workerTimeoutOccurred()
      Notify the strategy that a timeout for a component has occurred, i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • workercnt

        protected int workercnt
        The number of workers in the pool.
      • capacity

        protected int capacity
        The number of free workers.
    • Constructor Detail

      • ConstantPoolStrategy

        public ConstantPoolStrategy()
        Create a new ConstantPoolStrategy.
      • ConstantPoolStrategy

        public ConstantPoolStrategy​(int workercnt)
        Create a new ConstantPoolStrategy.
    • Method Detail

      • taskAdded

        public boolean taskAdded()
        Called when a new task was added to the pool.
        Specified by:
        taskAdded in interface IPoolStrategy
        Returns:
        True, if a new worker should be added to the pool.
      • workersAdded

        public void workersAdded​(int cnt)
        Called when a new worker was added proactively to the pool.
        Specified by:
        workersAdded in interface IPoolStrategy
        Parameters:
        cnt - The number of new workers.
      • taskServed

        public void taskServed​(long waitdur)
        Called when a new task was served from the pool.
        Specified by:
        taskServed in interface IPoolStrategy
        Parameters:
        waitdur - The waiting time of the task.
      • taskFinished

        public boolean taskFinished()
        Called when a task is finished.
        Specified by:
        taskFinished in interface IPoolStrategy
        Returns:
        True, if executing worker should be removed from the pool.
      • getWorkerTimeout

        public long getWorkerTimeout()
        Get the component timeout.
        Specified by:
        getWorkerTimeout in interface IPoolStrategy
        Returns:
        The timeout for the component to wait for new workers in the pool.
      • workerTimeoutOccurred

        public boolean workerTimeoutOccurred()
        Notify the strategy that a timeout for a component has occurred, i.e. it was not needed for serving some worker.
        Specified by:
        workerTimeoutOccurred in interface IPoolStrategy
        Returns:
        True, if the component be excluded from the pool.
      • getCapacity

        public int getCapacity()
        Get the number of free workers.
        Specified by:
        getCapacity in interface IPoolStrategy