Package com.powsybl.afs
Class LocalTaskMonitor
- java.lang.Object
-
- com.powsybl.afs.LocalTaskMonitor
-
- All Implemented Interfaces:
TaskMonitor
,AutoCloseable
public class LocalTaskMonitor extends Object implements TaskMonitor
- Author:
- Geoffroy Jamgotchian
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.powsybl.afs.TaskMonitor
TaskMonitor.NotACancellableTaskMonitor, TaskMonitor.Snapshot, TaskMonitor.Task
-
-
Constructor Summary
Constructors Constructor Description LocalTaskMonitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(TaskListener listener)
Add a listener to task eventsboolean
cancelTaskComputation(UUID id)
Try cancel/stop the computation process monitored by this task.void
close()
void
removeListener(TaskListener listener)
Remove a listener of task eventsTaskMonitor.Task
startTask(ProjectFile projectFile)
Create a task monitoring objectTaskMonitor.Task
startTask(String name, Project project)
Create a task monitoring objectTaskMonitor.Task
startTask(String name, Project project, String nodeId)
void
stopTask(UUID id)
Remove the task monitoring object.TaskMonitor.Snapshot
takeSnapshot(String projectId)
Return the complete state of tasks related to a projectvoid
updateTaskFuture(UUID taskId, Future future)
Update the future of the computation process monitored by this taskvoid
updateTaskMessage(UUID id, String message)
Update the display status of the task
-
-
-
Method Detail
-
startTask
public TaskMonitor.Task startTask(ProjectFile projectFile)
Description copied from interface:TaskMonitor
Create a task monitoring object- Specified by:
startTask
in interfaceTaskMonitor
- Parameters:
projectFile
- related project file- Returns:
- the newly created task
-
startTask
public TaskMonitor.Task startTask(String name, Project project)
Description copied from interface:TaskMonitor
Create a task monitoring object- Specified by:
startTask
in interfaceTaskMonitor
- Parameters:
name
- name of the taskproject
- related project- Returns:
- the newly created task
-
startTask
public TaskMonitor.Task startTask(String name, Project project, String nodeId)
-
stopTask
public void stopTask(UUID id)
Description copied from interface:TaskMonitor
Remove the task monitoring object. To stop the process monitored by this task, useTaskMonitor.cancelTaskComputation(java.util.UUID)
- Specified by:
stopTask
in interfaceTaskMonitor
- Parameters:
id
- id of the task
-
takeSnapshot
public TaskMonitor.Snapshot takeSnapshot(String projectId)
Description copied from interface:TaskMonitor
Return the complete state of tasks related to a project- Specified by:
takeSnapshot
in interfaceTaskMonitor
- Parameters:
projectId
- related project- Returns:
-
cancelTaskComputation
public boolean cancelTaskComputation(UUID id)
Description copied from interface:TaskMonitor
Try cancel/stop the computation process monitored by this task. TheTaskMonitor.stopTask(UUID)
must still be called afterward to clean the task monitor object- Specified by:
cancelTaskComputation
in interfaceTaskMonitor
- Parameters:
id
- the id of the task- Returns:
- a boolean indicating if the cancellation process has succeeded
-
updateTaskMessage
public void updateTaskMessage(UUID id, String message)
Description copied from interface:TaskMonitor
Update the display status of the task- Specified by:
updateTaskMessage
in interfaceTaskMonitor
- Parameters:
id
- id of the taskmessage
- new status message
-
addListener
public void addListener(TaskListener listener)
Description copied from interface:TaskMonitor
Add a listener to task events- Specified by:
addListener
in interfaceTaskMonitor
-
removeListener
public void removeListener(TaskListener listener)
Description copied from interface:TaskMonitor
Remove a listener of task events- Specified by:
removeListener
in interfaceTaskMonitor
-
updateTaskFuture
public void updateTaskFuture(UUID taskId, Future future)
Description copied from interface:TaskMonitor
Update the future of the computation process monitored by this task- Specified by:
updateTaskFuture
in interfaceTaskMonitor
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceTaskMonitor
-
-