com.ldodds.slug.framework
Class Controller
java.lang.Object
com.ldodds.slug.framework.Controller
- All Implemented Interfaces:
- java.lang.Runnable
- Direct Known Subclasses:
- FilteringController
- public class Controller
- extends java.lang.Object
- implements java.lang.Runnable
A Controller is responsible for handing out a list of
work items to a number of Worker
objects which it
created using a designated WorkerFactory
. Tracking
progress against the task list is delegated to a Monitor
The Controller is a generic class which can be used for performing
any co-ordinating a number of different types of task: it's not
specific to web crawling so a Controller instance could be used
in other scenarios.
The Controller exposes a very basic management interface in the
form of its start
, stop
, addWorkers
and
reduceWorkers
methods. These could be used to build a
graphical utility for managing a running Controller instance.
- Author:
- ldodds
Field Summary |
protected java.util.logging.Logger |
_logger
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_logger
protected java.util.logging.Logger _logger
Controller
public Controller(java.util.List workItems,
WorkerFactory factory,
int numberOfWorkers,
Monitor monitor)
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
stop
public void stop()
addWorkers
public void addWorkers(int increment)
reduceWorkers
public void reduceWorkers(int decrement)
popWorkItem
public Task popWorkItem(Worker worker)
completedTask
public void completedTask(Worker worker,
Task task)
addWorkItem
public void addWorkItem(Task workItem)
getStarted
public java.util.Date getStarted()