guarana.toolkit.engine
Class Scheduler

java.lang.Object
  extended by guarana.toolkit.engine.Scheduler
All Implemented Interfaces:
ISource, guarana.util.observer.smart.ISmartObserver

public class Scheduler
extends Object
implements ISource, guarana.util.observer.smart.ISmartObserver

A system agent that can execute tasks that are reported to it. Monitoring log file formats:

Since:
Guaranį SDK 1.0.0
Author:
Rafael Z. Frantz

Constructor Summary
Scheduler(String name)
          Constructs a new scheduler with the given name and number of workers.
 
Method Summary
 Collection<String> getListenedContainers()
          Returns a unmodifiable collection with the names of all listened task containers to this scheduler.
 String getName()
          Returns the name of this source.
 int getNumberOfWorkers()
          Returns the number of current workers defined for this scheduler.
 long getNumberOfWorkUnitsProcessed()
          Returns the number of Work Units processed.
 String getStats()
           
 void registerProcess(Process process)
          Registers a process which will notify this scheduler about tasks ready to be executed.
 void setName(String name)
          Sets the name of this source.
 void start()
          Starts ALL workers (threads) to process work units.
 void stop()
          Stops ALL workers (threads) which are processing work units.
 void update(guarana.util.observer.smart.SmartObservable obj, Object task)
          This method is automatically called by the observable task to notify the task is ready to be executed.
 int workQueueSize()
          Returns the number of elements in the work queue.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scheduler

public Scheduler(String name)
Constructs a new scheduler with the given name and number of workers.

Parameters:
name - The name of this scheduler.
Method Detail

registerProcess

public void registerProcess(Process process)
                     throws InvalidParameterException
Registers a process which will notify this scheduler about tasks ready to be executed.

Parameters:
process - The observable process.
Throws:
InvalidParameterException - if the process is null.

getNumberOfWorkers

public int getNumberOfWorkers()
Returns the number of current workers defined for this scheduler.

Returns:
the number of workers.

workQueueSize

public int workQueueSize()
Returns the number of elements in the work queue.

Returns:
the size of the work queue.

update

public void update(guarana.util.observer.smart.SmartObservable obj,
                   Object task)
This method is automatically called by the observable task to notify the task is ready to be executed. Please, do not call this method by yourself.

Specified by:
update in interface guarana.util.observer.smart.ISmartObserver
Parameters:
obj - THIS PARAMETHER IS NOT USED.
task - The Task which can be executed.

start

public void start()
Starts ALL workers (threads) to process work units. The number of workers is defined in the constructor of this Scheduler.


stop

public void stop()
Stops ALL workers (threads) which are processing work units.


getStats

public String getStats()

setName

public void setName(String name)
Sets the name of this source.

Specified by:
setName in interface ISource
Specified by:
setName in interface guarana.util.observer.smart.ISmartObserver
Parameters:
name - The name of this source.

getName

public String getName()
Returns the name of this source.

Specified by:
getName in interface ISource
Specified by:
getName in interface guarana.util.observer.smart.ISmartObserver
Returns:
the name of this source.

getNumberOfWorkUnitsProcessed

public long getNumberOfWorkUnitsProcessed()
Returns the number of Work Units processed.

Returns:
the number of work units.

getListenedContainers

public Collection<String> getListenedContainers()
Returns a unmodifiable collection with the names of all listened task containers to this scheduler.

Returns:
the names of all listened task containers to this scheduler.


Guaranį DSL Home