Skip to content

Commit a218801

Browse files
authored
Fix up comment in PersistentTasksNodeService (#113526) (#113531)
The formatting of this comment was destroyed by spotless. This commit fixes this.
1 parent 2955518 commit a218801

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

server/src/main/java/org/elasticsearch/persistent/PersistentTasksNodeService.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,35 @@ public void clusterChanged(ClusterChangedEvent event) {
7575
PersistentTasksCustomMetadata tasks = event.state().getMetadata().custom(PersistentTasksCustomMetadata.TYPE);
7676
PersistentTasksCustomMetadata previousTasks = event.previousState().getMetadata().custom(PersistentTasksCustomMetadata.TYPE);
7777

78-
// Cluster State Local State Local Action
79-
// STARTED NULL Create as STARTED, Start
80-
// STARTED STARTED Noop - running
81-
// STARTED COMPLETED Noop - waiting for notification ack
82-
// STARTED LOCAL_ABORTED Noop - waiting for notification ack
83-
84-
// NULL NULL Noop - nothing to do
85-
// NULL STARTED Remove locally, Mark as PENDING_CANCEL, Cancel
86-
// NULL COMPLETED Remove locally
87-
// NULL LOCAL_ABORTED Remove locally
88-
89-
// Master states:
90-
// NULL - doesn't exist in the cluster state
91-
// STARTED - exist in the cluster state
92-
93-
// Local state:
94-
// NULL - we don't have task registered locally in runningTasks
95-
// STARTED - registered in TaskManager, requires master notification when finishes
96-
// PENDING_CANCEL - registered in TaskManager, doesn't require master notification when finishes
97-
// COMPLETED - not registered in TaskManager, notified, waiting for master to remove it from CS so we can remove locally
98-
// LOCAL_ABORTED - not registered in TaskManager, notified, waiting for master to adjust it in CS so we can remove locally
99-
100-
// When task finishes if it is marked as STARTED or PENDING_CANCEL it is marked as COMPLETED and unregistered,
101-
// If the task was STARTED, the master notification is also triggered (this is handled by unregisterTask() method, which is
102-
// triggered by PersistentTaskListener
78+
/*
79+
* Master states:
80+
* NULL - doesn't exist in the cluster state
81+
* STARTED - exist in the cluster state
82+
*
83+
* Local states (see org.elasticsearch.persistent.AllocatedPersistentTask.State)
84+
* NULL - we don't have task registered locally in runningTasks
85+
* STARTED - registered in TaskManager, requires master notification when finishes
86+
* PENDING_CANCEL - registered in TaskManager, doesn't require master notification when finishes
87+
* COMPLETED - not registered in TaskManager, notified, waiting for master to remove it from CS so we can remove locally
88+
* LOCAL_ABORTED - not registered in TaskManager, notified, waiting for master to adjust it in CS so we can remove locally
89+
*
90+
* Master state | Local state | Local action
91+
* ---------------+----------------+-----------------------------------------------
92+
* STARTED | NULL | Create as STARTED, Start
93+
* STARTED | STARTED | Noop - running
94+
* STARTED | PENDING_CANCEL | Impossible
95+
* STARTED | COMPLETED | Noop - waiting for notification ack
96+
* STARTED | LOCAL_ABORTED | Noop - waiting for notification ack
97+
* NULL | NULL | Noop - nothing to do
98+
* NULL | STARTED | Remove locally, Mark as PENDING_CANCEL, Cancel
99+
* NULL | PENDING_CANCEL | Noop - will remove locally when complete
100+
* NULL | COMPLETED | Remove locally
101+
* NULL | LOCAL_ABORTED | Remove locally
102+
*
103+
* When task finishes if it is marked as STARTED or PENDING_CANCEL it is marked as COMPLETED and unregistered,
104+
* If the task was STARTED, the master notification is also triggered (this is handled by unregisterTask() method, which is
105+
* triggered by PersistentTaskListener
106+
*/
103107

104108
if (Objects.equals(tasks, previousTasks) == false || event.nodesChanged()) {
105109
// We have some changes let's check if they are related to our node

0 commit comments

Comments
 (0)