| | |
| | | } |
| | | |
| | | /** |
| | | * Registers a task. The Control Panel creates a task everytime an operation |
| | | * Registers a task. The Control Panel creates a task every time an operation |
| | | * is made and they are stored here. |
| | | * @param task the task to be registered. |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Unregisters a task. |
| | | * @param task the task to be unregistered. |
| | | */ |
| | | public void unregisterTask(Task task) |
| | | { |
| | | tasks.remove(task); |
| | | } |
| | | |
| | | /** |
| | | * Tells whether an index must be reindexed or not. |
| | | * @param index the index. |
| | | * @return <CODE>true</CODE> if the index must be reindexed and |
| | |
| | | { |
| | | while (!stopPooling) |
| | | { |
| | | cleanupTasks(); |
| | | regenerateDescriptor(); |
| | | Thread.sleep(poolingPeriod); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Cleans the tasks that are over. |
| | | */ |
| | | private void cleanupTasks() |
| | | { |
| | | Set<Task> toClean = new HashSet<Task>(); |
| | | for (Task task : tasks) |
| | | { |
| | | if (task.getState() == Task.State.FINISHED_SUCCESSFULLY || |
| | | task.getState() == Task.State.FINISHED_WITH_ERROR) |
| | | { |
| | | toClean.add(task); |
| | | } |
| | | } |
| | | for (Task task : toClean) |
| | | { |
| | | unregisterTask(task); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns whether the provided task is running on the provided server or not. |
| | | * The code takes into account that the server object might not be fully |
| | | * initialized (but at least it contains the host name and the instance |