|
19 | 19 |
|
20 | 20 | package org.elasticsearch.client;
|
21 | 21 |
|
22 |
| -import org.apache.http.util.EntityUtils; |
23 | 22 | import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
|
24 | 23 | import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
|
25 | 24 | import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
26 | 25 | import org.elasticsearch.client.indexlifecycle.AllocateAction;
|
27 | 26 | import org.elasticsearch.client.indexlifecycle.DeleteAction;
|
28 | 27 | import org.elasticsearch.client.indexlifecycle.ForceMergeAction;
|
29 | 28 | import org.elasticsearch.client.indexlifecycle.LifecycleAction;
|
| 29 | +import org.elasticsearch.client.indexlifecycle.LifecycleManagementStatusRequest; |
| 30 | +import org.elasticsearch.client.indexlifecycle.LifecycleManagementStatusResponse; |
30 | 31 | import org.elasticsearch.client.indexlifecycle.LifecyclePolicy;
|
| 32 | +import org.elasticsearch.client.indexlifecycle.OperationMode; |
31 | 33 | import org.elasticsearch.client.indexlifecycle.Phase;
|
32 | 34 | import org.elasticsearch.client.indexlifecycle.PutLifecyclePolicyRequest;
|
33 | 35 | import org.elasticsearch.client.indexlifecycle.RolloverAction;
|
@@ -88,35 +90,33 @@ public void testStartStopILM() throws Exception {
|
88 | 90 | createIndex("baz", Settings.builder().put("index.lifecycle.name", "eggplant").build());
|
89 | 91 | createIndex("squash", Settings.EMPTY);
|
90 | 92 |
|
91 |
| - // TODO: NORELEASE convert this to using the high level client once |
92 |
| - // there are APIs for it |
93 |
| - Request statusReq = new Request("GET", "/_ilm/status"); |
94 |
| - Response statusResponse = client().performRequest(statusReq); |
95 |
| - String statusResponseString = EntityUtils.toString(statusResponse.getEntity()); |
96 |
| - assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString); |
| 93 | + LifecycleManagementStatusRequest statusRequest = new LifecycleManagementStatusRequest(); |
| 94 | + LifecycleManagementStatusResponse statusResponse = execute( |
| 95 | + statusRequest, |
| 96 | + highLevelClient().indexLifecycle()::lifecycleManagementStatus, |
| 97 | + highLevelClient().indexLifecycle()::lifecycleManagementStatusAsync); |
| 98 | + assertEquals(statusResponse.getOperationMode(), OperationMode.RUNNING); |
97 | 99 |
|
98 | 100 | StopILMRequest stopReq = new StopILMRequest();
|
99 | 101 | AcknowledgedResponse stopResponse = execute(stopReq, highLevelClient().indexLifecycle()::stopILM,
|
100 | 102 | highLevelClient().indexLifecycle()::stopILMAsync);
|
101 | 103 | assertTrue(stopResponse.isAcknowledged());
|
102 | 104 |
|
103 |
| - // TODO: NORELEASE convert this to using the high level client once there are APIs for it |
104 |
| - statusReq = new Request("GET", "/_ilm/status"); |
105 |
| - statusResponse = client().performRequest(statusReq); |
106 |
| - statusResponseString = EntityUtils.toString(statusResponse.getEntity()); |
107 |
| - assertThat(statusResponseString, |
108 |
| - Matchers.anyOf(equalTo("{\"operation_mode\":\"STOPPING\"}"), equalTo("{\"operation_mode\":\"STOPPED\"}"))); |
| 105 | + |
| 106 | + statusResponse = execute(statusRequest, highLevelClient().indexLifecycle()::lifecycleManagementStatus, |
| 107 | + highLevelClient().indexLifecycle()::lifecycleManagementStatusAsync); |
| 108 | + assertThat(statusResponse.getOperationMode(), |
| 109 | + Matchers.anyOf(equalTo(OperationMode.STOPPING), |
| 110 | + equalTo(OperationMode.STOPPED))); |
109 | 111 |
|
110 | 112 | StartILMRequest startReq = new StartILMRequest();
|
111 | 113 | AcknowledgedResponse startResponse = execute(startReq, highLevelClient().indexLifecycle()::startILM,
|
112 | 114 | highLevelClient().indexLifecycle()::startILMAsync);
|
113 | 115 | assertTrue(startResponse.isAcknowledged());
|
114 | 116 |
|
115 |
| - // TODO: NORELEASE convert this to using the high level client once there are APIs for it |
116 |
| - statusReq = new Request("GET", "/_ilm/status"); |
117 |
| - statusResponse = client().performRequest(statusReq); |
118 |
| - statusResponseString = EntityUtils.toString(statusResponse.getEntity()); |
119 |
| - assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString); |
| 117 | + statusResponse = execute(statusRequest, highLevelClient().indexLifecycle()::lifecycleManagementStatus, |
| 118 | + highLevelClient().indexLifecycle()::lifecycleManagementStatusAsync); |
| 119 | + assertEquals(statusResponse.getOperationMode(), OperationMode.RUNNING); |
120 | 120 | }
|
121 | 121 |
|
122 | 122 | public void testExplainLifecycle() throws Exception {
|
|
0 commit comments