Package jadex.micro.examples.mandelbrot
Class ServicePoolManager
- java.lang.Object
- 
- jadex.micro.examples.mandelbrot.ServicePoolManager
 
- 
 public class ServicePoolManager extends java.lang.ObjectGeneric class that allows dispatching tasks to a dynamic pool of services.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classServicePoolManager.AllocationDataHandler for a single task allocation.
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.MapbusyThe collection of busy services (id->service).protected IInternalAccesscomponentThe component, which manages the pool.protected booleancreatingFlag to indicate an ongoing creation.protected java.util.MapfreeThe collection of free services (id->service).protected IServicePoolHandlerhandlerThe handler for service creation, selection and invocation.protected intmaxThe maximum number of services (-1 for unlimited).protected java.lang.StringnameThe services name.protected booleansearchingFlag to indicate an ongoing search.protected java.util.MaptasksThe open tasks with their corresponding allocation data.protected ITimertimerThe search timeout timer.
 - 
Constructor SummaryConstructors Constructor Description ServicePoolManager(IInternalAccess component, java.lang.String name, IServicePoolHandler handler, int max)Create a new service pool manager.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddService(IService service)Add a service to the pool and start working on tasks.protected voidcreateServices()Create services until there are no more todo items.IIntermediateFutureperformTasks(java.util.Set tasks, boolean retry, java.lang.Object user)Perform the given tasks using available or newly created services.protected booleanretryTask(java.lang.Object task, ServicePoolManager.AllocationData ad)(Re-)start working on a task.protected voidsearchServices()Search for services or create new services as needed.voidsetMax(int max)Set the maximum number of services.
 
- 
- 
- 
Field Detail- 
componentprotected IInternalAccess component The component, which manages the pool.
 - 
nameprotected java.lang.String name The services name.
 - 
handlerprotected IServicePoolHandler handler The handler for service creation, selection and invocation.
 - 
maxprotected int max The maximum number of services (-1 for unlimited).
 - 
freeprotected java.util.Map free The collection of free services (id->service).
 - 
busyprotected java.util.Map busy The collection of busy services (id->service).
 - 
tasksprotected java.util.Map tasks The open tasks with their corresponding allocation data.
 - 
searchingprotected boolean searching Flag to indicate an ongoing search.
 - 
creatingprotected boolean creating Flag to indicate an ongoing creation.
 - 
timerprotected ITimer timer The search timeout timer.
 
- 
 - 
Constructor Detail- 
ServicePoolManagerpublic ServicePoolManager(IInternalAccess component, java.lang.String name, IServicePoolHandler handler, int max) Create a new service pool manager.- Parameters:
- name- The services name.
- handler- The code for service invocation.
 
 
- 
 - 
Method Detail- 
performTaskspublic IIntermediateFuture performTasks(java.util.Set tasks, boolean retry, java.lang.Object user) Perform the given tasks using available or newly created services.- Parameters:
- tasks- The set of tasks to be performed.
- retry- True, when failed tasks should be retried.
- user- User data that is provided for service selection, creation, invocation (if any).
- Returns:
- A future with intermediate and final results.
 
 - 
setMaxpublic void setMax(int max) Set the maximum number of services. Only affects the creation of new services.
 - 
retryTaskprotected boolean retryTask(java.lang.Object task, ServicePoolManager.AllocationData ad)(Re-)start working on a task.- Parameters:
- task- The task.
- ad- The allocation data.
- Returns:
- True, when the task was assigned to an available service.
 
 - 
searchServicesprotected void searchServices() Search for services or create new services as needed.
 - 
addServiceprotected void addService(IService service) Add a service to the pool and start working on tasks.- Parameters:
- service- The service to add.
 
 - 
createServicesprotected void createServices() Create services until there are no more todo items.- Parameters:
- todo- The collection of remaining tasks.
 
 
- 
 
-