3030import org .elasticsearch .tasks .TaskInfo ;
3131import org .elasticsearch .test .ESIntegTestCase ;
3232import org .elasticsearch .persistent .PersistentTasksCustomMetaData .PersistentTask ;
33- import org .elasticsearch .persistent .PersistentTasksService .WaitForPersistentTaskStatusListener ;
33+ import org .elasticsearch .persistent .PersistentTasksService .WaitForPersistentTaskListener ;
3434import org .elasticsearch .persistent .TestPersistentTasksPlugin .Status ;
3535import org .elasticsearch .persistent .TestPersistentTasksPlugin .TestPersistentTasksExecutor ;
3636import org .elasticsearch .persistent .TestPersistentTasksPlugin .TestParams ;
@@ -69,15 +69,15 @@ public void cleanup() throws Exception {
6969 assertNoRunningTasks ();
7070 }
7171
72- public static class WaitForPersistentTaskStatusFuture <Params extends PersistentTaskParams >
72+ public static class WaitForPersistentTaskFuture <Params extends PersistentTaskParams >
7373 extends PlainActionFuture <PersistentTask <Params >>
74- implements WaitForPersistentTaskStatusListener <Params > {
74+ implements WaitForPersistentTaskListener <Params > {
7575 }
7676
7777 public void testPersistentActionFailure () throws Exception {
7878 PersistentTasksService persistentTasksService = internalCluster ().getInstance (PersistentTasksService .class );
7979 PlainActionFuture <PersistentTask <TestParams >> future = new PlainActionFuture <>();
80- persistentTasksService .startPersistentTask (UUIDs .base64UUID (), TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
80+ persistentTasksService .sendStartRequest (UUIDs .base64UUID (), TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
8181 long allocationId = future .get ().getAllocationId ();
8282 assertBusy (() -> {
8383 // Wait for the task to start
@@ -108,7 +108,7 @@ public void testPersistentActionCompletion() throws Exception {
108108 PersistentTasksService persistentTasksService = internalCluster ().getInstance (PersistentTasksService .class );
109109 PlainActionFuture <PersistentTask <TestParams >> future = new PlainActionFuture <>();
110110 String taskId = UUIDs .base64UUID ();
111- persistentTasksService .startPersistentTask (taskId , TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
111+ persistentTasksService .sendStartRequest (taskId , TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
112112 long allocationId = future .get ().getAllocationId ();
113113 assertBusy (() -> {
114114 // Wait for the task to start
@@ -127,7 +127,7 @@ public void testPersistentActionCompletion() throws Exception {
127127 logger .info ("Simulating errant completion notification" );
128128 //try sending completion request with incorrect allocation id
129129 PlainActionFuture <PersistentTask <?>> failedCompletionNotificationFuture = new PlainActionFuture <>();
130- persistentTasksService .sendCompletionNotification (taskId , Long .MAX_VALUE , null , failedCompletionNotificationFuture );
130+ persistentTasksService .sendCompletionRequest (taskId , Long .MAX_VALUE , null , failedCompletionNotificationFuture );
131131 assertThrows (failedCompletionNotificationFuture , ResourceNotFoundException .class );
132132 // Make sure that the task is still running
133133 assertThat (client ().admin ().cluster ().prepareListTasks ().setActions (TestPersistentTasksExecutor .NAME + "[c]" )
@@ -142,7 +142,7 @@ public void testPersistentActionWithNoAvailableNode() throws Exception {
142142 PlainActionFuture <PersistentTask <TestParams >> future = new PlainActionFuture <>();
143143 TestParams testParams = new TestParams ("Blah" );
144144 testParams .setExecutorNodeAttr ("test" );
145- persistentTasksService .startPersistentTask (UUIDs .base64UUID (), TestPersistentTasksExecutor .NAME , testParams , future );
145+ persistentTasksService .sendStartRequest (UUIDs .base64UUID (), TestPersistentTasksExecutor .NAME , testParams , future );
146146 String taskId = future .get ().getId ();
147147
148148 Settings nodeSettings = Settings .builder ().put (nodeSettings (0 )).put ("node.attr.test_attr" , "test" ).build ();
@@ -169,14 +169,14 @@ public void testPersistentActionWithNoAvailableNode() throws Exception {
169169
170170 // Remove the persistent task
171171 PlainActionFuture <PersistentTask <?>> removeFuture = new PlainActionFuture <>();
172- persistentTasksService .cancelPersistentTask (taskId , removeFuture );
172+ persistentTasksService .sendRemoveRequest (taskId , removeFuture );
173173 assertEquals (removeFuture .get ().getId (), taskId );
174174 }
175175
176176 public void testPersistentActionStatusUpdate () throws Exception {
177177 PersistentTasksService persistentTasksService = internalCluster ().getInstance (PersistentTasksService .class );
178178 PlainActionFuture <PersistentTask <TestParams >> future = new PlainActionFuture <>();
179- persistentTasksService .startPersistentTask (UUIDs .base64UUID (), TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
179+ persistentTasksService .sendStartRequest (UUIDs .base64UUID (), TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
180180 String taskId = future .get ().getId ();
181181
182182 assertBusy (() -> {
@@ -200,28 +200,28 @@ public void testPersistentActionStatusUpdate() throws Exception {
200200 .get ().getTasks ().size (), equalTo (1 ));
201201
202202 int finalI = i ;
203- WaitForPersistentTaskStatusFuture <?> future1 = new WaitForPersistentTaskStatusFuture <>();
204- persistentTasksService .waitForPersistentTaskStatus (taskId ,
203+ WaitForPersistentTaskFuture <?> future1 = new WaitForPersistentTaskFuture <>();
204+ persistentTasksService .waitForPersistentTask (taskId ,
205205 task -> task != null && task .getStatus () != null && task .getStatus ().toString () != null &&
206206 task .getStatus ().toString ().equals ("{\" phase\" :\" phase " + (finalI + 1 ) + "\" }" ),
207207 TimeValue .timeValueSeconds (10 ), future1 );
208208 assertThat (future1 .get ().getId (), equalTo (taskId ));
209209 }
210210
211- WaitForPersistentTaskStatusFuture <?> future1 = new WaitForPersistentTaskStatusFuture <>();
212- persistentTasksService .waitForPersistentTaskStatus (taskId ,
211+ WaitForPersistentTaskFuture <?> future1 = new WaitForPersistentTaskFuture <>();
212+ persistentTasksService .waitForPersistentTask (taskId ,
213213 task -> false , TimeValue .timeValueMillis (10 ), future1 );
214214
215215 assertThrows (future1 , IllegalStateException .class , "timed out after 10ms" );
216216
217217 PlainActionFuture <PersistentTask <?>> failedUpdateFuture = new PlainActionFuture <>();
218- persistentTasksService .updateStatus (taskId , -2 , new Status ("should fail" ), failedUpdateFuture );
218+ persistentTasksService .sendUpdateStateRequest (taskId , -2 , new Status ("should fail" ), failedUpdateFuture );
219219 assertThrows (failedUpdateFuture , ResourceNotFoundException .class , "the task with id " + taskId +
220220 " and allocation id -2 doesn't exist" );
221221
222222 // Wait for the task to disappear
223- WaitForPersistentTaskStatusFuture <?> future2 = new WaitForPersistentTaskStatusFuture <>();
224- persistentTasksService .waitForPersistentTaskStatus (taskId , Objects ::isNull , TimeValue .timeValueSeconds (10 ), future2 );
223+ WaitForPersistentTaskFuture <?> future2 = new WaitForPersistentTaskFuture <>();
224+ persistentTasksService .waitForPersistentTask (taskId , Objects ::isNull , TimeValue .timeValueSeconds (10 ), future2 );
225225
226226 logger .info ("Completing the running task" );
227227 // Complete the running task and make sure it finishes properly
@@ -235,11 +235,11 @@ public void testCreatePersistentTaskWithDuplicateId() throws Exception {
235235 PersistentTasksService persistentTasksService = internalCluster ().getInstance (PersistentTasksService .class );
236236 PlainActionFuture <PersistentTask <TestParams >> future = new PlainActionFuture <>();
237237 String taskId = UUIDs .base64UUID ();
238- persistentTasksService .startPersistentTask (taskId , TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
238+ persistentTasksService .sendStartRequest (taskId , TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future );
239239 future .get ();
240240
241241 PlainActionFuture <PersistentTask <TestParams >> future2 = new PlainActionFuture <>();
242- persistentTasksService .startPersistentTask (taskId , TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future2 );
242+ persistentTasksService .sendStartRequest (taskId , TestPersistentTasksExecutor .NAME , new TestParams ("Blah" ), future2 );
243243 assertThrows (future2 , ResourceAlreadyExistsException .class );
244244
245245 assertBusy (() -> {
0 commit comments