Skip to content

Commit bf01cda

Browse files
committed
Revert "[ML] Delete forecast API (#31134) (#33218)"
This reverts commit e1b985e.
1 parent e1b985e commit bf01cda

File tree

11 files changed

+2
-656
lines changed

11 files changed

+2
-656
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.elasticsearch.xpack.core.ml.action.DeleteDatafeedAction;
5050
import org.elasticsearch.xpack.core.ml.action.DeleteExpiredDataAction;
5151
import org.elasticsearch.xpack.core.ml.action.DeleteFilterAction;
52-
import org.elasticsearch.xpack.core.ml.action.DeleteForecastAction;
5352
import org.elasticsearch.xpack.core.ml.action.DeleteJobAction;
5453
import org.elasticsearch.xpack.core.ml.action.DeleteModelSnapshotAction;
5554
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
@@ -254,7 +253,6 @@ public List<GenericAction> getClientActions() {
254253
UpdateProcessAction.INSTANCE,
255254
DeleteExpiredDataAction.INSTANCE,
256255
ForecastJobAction.INSTANCE,
257-
DeleteForecastAction.INSTANCE,
258256
GetCalendarsAction.INSTANCE,
259257
PutCalendarAction.INSTANCE,
260258
DeleteCalendarAction.INSTANCE,

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteForecastAction.java

Lines changed: 0 additions & 95 deletions
This file was deleted.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ public final class Messages {
161161
public static final String REST_JOB_NOT_CLOSED_REVERT = "Can only revert to a model snapshot when the job is closed.";
162162
public static final String REST_NO_SUCH_MODEL_SNAPSHOT = "No model snapshot with id [{0}] exists for job [{1}]";
163163
public static final String REST_START_AFTER_END = "Invalid time range: end time ''{0}'' is earlier than start time ''{1}''.";
164-
public static final String REST_NO_SUCH_FORECAST = "No forecast(s) [{0}] exists for job [{1}]";
165-
public static final String REST_CANNOT_DELETE_FORECAST_IN_CURRENT_STATE =
166-
"Forecast(s) [{0}] for job [{1}] needs to be either FAILED or FINISHED to be deleted";
164+
167165
public static final String FIELD_CANNOT_BE_NULL = "Field [{0}] cannot be null";
168166

169167
private Messages() {

x-pack/plugin/ml/qa/ml-with-security/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ integTestRunner {
9191
'ml/validate/Test invalid job config',
9292
'ml/validate/Test job config is invalid because model snapshot id set',
9393
'ml/validate/Test job config that is invalid only because of the job ID',
94-
'ml/validate_detector/Test invalid detector',
95-
'ml/delete_forecast/Test delete on _all forecasts not allow no forecasts',
96-
'ml/delete_forecast/Test delete forecast on missing forecast'
94+
'ml/validate_detector/Test invalid detector'
9795
].join(',')
9896
}
9997

x-pack/plugin/ml/qa/native-multi-node-tests/src/test/java/org/elasticsearch/xpack/ml/integration/ForecastIT.java

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
import org.elasticsearch.ElasticsearchException;
99
import org.elasticsearch.ElasticsearchStatusException;
10-
import org.elasticsearch.action.support.master.AcknowledgedResponse;
11-
import org.elasticsearch.cluster.metadata.MetaData;
1210
import org.elasticsearch.common.unit.TimeValue;
13-
import org.elasticsearch.xpack.core.ml.action.DeleteForecastAction;
1411
import org.elasticsearch.xpack.core.ml.job.config.AnalysisConfig;
1512
import org.elasticsearch.xpack.core.ml.job.config.AnalysisLimits;
1613
import org.elasticsearch.xpack.core.ml.job.config.DataDescription;
@@ -279,104 +276,6 @@ public void testOverflowToDisk() throws Exception {
279276

280277
}
281278

282-
public void testDelete() throws Exception {
283-
Detector.Builder detector = new Detector.Builder("mean", "value");
284-
285-
TimeValue bucketSpan = TimeValue.timeValueHours(1);
286-
AnalysisConfig.Builder analysisConfig = new AnalysisConfig.Builder(Collections.singletonList(detector.build()));
287-
analysisConfig.setBucketSpan(bucketSpan);
288-
DataDescription.Builder dataDescription = new DataDescription.Builder();
289-
dataDescription.setTimeFormat("epoch");
290-
291-
Job.Builder job = new Job.Builder("forecast-it-test-delete");
292-
job.setAnalysisConfig(analysisConfig);
293-
job.setDataDescription(dataDescription);
294-
295-
registerJob(job);
296-
putJob(job);
297-
openJob(job.getId());
298-
299-
long now = Instant.now().getEpochSecond();
300-
long timestamp = now - 50 * bucketSpan.seconds();
301-
List<String> data = new ArrayList<>();
302-
while (timestamp < now) {
303-
data.add(createJsonRecord(createRecord(timestamp, 10.0)));
304-
data.add(createJsonRecord(createRecord(timestamp, 30.0)));
305-
timestamp += bucketSpan.seconds();
306-
}
307-
308-
postData(job.getId(), data.stream().collect(Collectors.joining()));
309-
flushJob(job.getId(), false);
310-
String forecastIdDefaultDurationDefaultExpiry = forecast(job.getId(), null, null);
311-
String forecastIdDuration1HourNoExpiry = forecast(job.getId(), TimeValue.timeValueHours(1), TimeValue.ZERO);
312-
waitForecastToFinish(job.getId(), forecastIdDefaultDurationDefaultExpiry);
313-
waitForecastToFinish(job.getId(), forecastIdDuration1HourNoExpiry);
314-
closeJob(job.getId());
315-
316-
{
317-
ForecastRequestStats forecastStats = getForecastStats(job.getId(), forecastIdDefaultDurationDefaultExpiry);
318-
assertNotNull(forecastStats);
319-
ForecastRequestStats otherStats = getForecastStats(job.getId(), forecastIdDuration1HourNoExpiry);
320-
assertNotNull(otherStats);
321-
}
322-
323-
{
324-
DeleteForecastAction.Request request = new DeleteForecastAction.Request(job.getId(),
325-
forecastIdDefaultDurationDefaultExpiry + "," + forecastIdDuration1HourNoExpiry);
326-
AcknowledgedResponse response = client().execute(DeleteForecastAction.INSTANCE, request).actionGet();
327-
assertTrue(response.isAcknowledged());
328-
}
329-
330-
{
331-
ForecastRequestStats forecastStats = getForecastStats(job.getId(), forecastIdDefaultDurationDefaultExpiry);
332-
assertNull(forecastStats);
333-
ForecastRequestStats otherStats = getForecastStats(job.getId(), forecastIdDuration1HourNoExpiry);
334-
assertNull(otherStats);
335-
}
336-
337-
{
338-
DeleteForecastAction.Request request = new DeleteForecastAction.Request(job.getId(), "forecast-does-not-exist");
339-
ElasticsearchException e = expectThrows(ElasticsearchException.class,
340-
() -> client().execute(DeleteForecastAction.INSTANCE, request).actionGet());
341-
assertThat(e.getMessage(),
342-
equalTo("No forecast(s) [forecast-does-not-exist] exists for job [forecast-it-test-delete]"));
343-
}
344-
345-
{
346-
DeleteForecastAction.Request request = new DeleteForecastAction.Request(job.getId(), MetaData.ALL);
347-
AcknowledgedResponse response = client().execute(DeleteForecastAction.INSTANCE, request).actionGet();
348-
assertTrue(response.isAcknowledged());
349-
}
350-
351-
{
352-
Job.Builder otherJob = new Job.Builder("forecasts-delete-with-all-and-allow-no-forecasts");
353-
otherJob.setAnalysisConfig(analysisConfig);
354-
otherJob.setDataDescription(dataDescription);
355-
356-
registerJob(otherJob);
357-
putJob(otherJob);
358-
DeleteForecastAction.Request request = new DeleteForecastAction.Request(otherJob.getId(), MetaData.ALL);
359-
AcknowledgedResponse response = client().execute(DeleteForecastAction.INSTANCE, request).actionGet();
360-
assertTrue(response.isAcknowledged());
361-
}
362-
363-
{
364-
Job.Builder otherJob = new Job.Builder("forecasts-delete-with-all-and-not-allow-no-forecasts");
365-
otherJob.setAnalysisConfig(analysisConfig);
366-
otherJob.setDataDescription(dataDescription);
367-
368-
registerJob(otherJob);
369-
putJob(otherJob);
370-
371-
DeleteForecastAction.Request request = new DeleteForecastAction.Request(otherJob.getId(), MetaData.ALL);
372-
request.setAllowNoForecasts(false);
373-
ElasticsearchException e = expectThrows(ElasticsearchException.class,
374-
() -> client().execute(DeleteForecastAction.INSTANCE, request).actionGet());
375-
assertThat(e.getMessage(),
376-
equalTo("No forecast(s) [_all] exists for job [forecasts-delete-with-all-and-not-allow-no-forecasts]"));
377-
}
378-
}
379-
380279
private void createDataWithLotsOfClientIps(TimeValue bucketSpan, Job.Builder job) throws IOException {
381280
long now = Instant.now().getEpochSecond();
382281
long timestamp = now - 15 * bucketSpan.seconds();

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import org.elasticsearch.xpack.core.ml.action.DeleteDatafeedAction;
6464
import org.elasticsearch.xpack.core.ml.action.DeleteExpiredDataAction;
6565
import org.elasticsearch.xpack.core.ml.action.DeleteFilterAction;
66-
import org.elasticsearch.xpack.core.ml.action.DeleteForecastAction;
6766
import org.elasticsearch.xpack.core.ml.action.DeleteJobAction;
6867
import org.elasticsearch.xpack.core.ml.action.DeleteModelSnapshotAction;
6968
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction;
@@ -116,7 +115,6 @@
116115
import org.elasticsearch.xpack.ml.action.TransportDeleteDatafeedAction;
117116
import org.elasticsearch.xpack.ml.action.TransportDeleteExpiredDataAction;
118117
import org.elasticsearch.xpack.ml.action.TransportDeleteFilterAction;
119-
import org.elasticsearch.xpack.ml.action.TransportDeleteForecastAction;
120118
import org.elasticsearch.xpack.ml.action.TransportDeleteJobAction;
121119
import org.elasticsearch.xpack.ml.action.TransportDeleteModelSnapshotAction;
122120
import org.elasticsearch.xpack.ml.action.TransportFinalizeJobExecutionAction;
@@ -203,7 +201,6 @@
203201
import org.elasticsearch.xpack.ml.rest.filter.RestPutFilterAction;
204202
import org.elasticsearch.xpack.ml.rest.filter.RestUpdateFilterAction;
205203
import org.elasticsearch.xpack.ml.rest.job.RestCloseJobAction;
206-
import org.elasticsearch.xpack.ml.rest.job.RestDeleteForecastAction;
207204
import org.elasticsearch.xpack.ml.rest.job.RestDeleteJobAction;
208205
import org.elasticsearch.xpack.ml.rest.job.RestFlushJobAction;
209206
import org.elasticsearch.xpack.ml.rest.job.RestForecastJobAction;
@@ -497,7 +494,6 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
497494
new RestDeleteModelSnapshotAction(settings, restController),
498495
new RestDeleteExpiredDataAction(settings, restController),
499496
new RestForecastJobAction(settings, restController),
500-
new RestDeleteForecastAction(settings, restController),
501497
new RestGetCalendarsAction(settings, restController),
502498
new RestPutCalendarAction(settings, restController),
503499
new RestDeleteCalendarAction(settings, restController),
@@ -554,7 +550,6 @@ public List<RestHandler> getRestHandlers(Settings settings, RestController restC
554550
new ActionHandler<>(UpdateProcessAction.INSTANCE, TransportUpdateProcessAction.class),
555551
new ActionHandler<>(DeleteExpiredDataAction.INSTANCE, TransportDeleteExpiredDataAction.class),
556552
new ActionHandler<>(ForecastJobAction.INSTANCE, TransportForecastJobAction.class),
557-
new ActionHandler<>(DeleteForecastAction.INSTANCE, TransportDeleteForecastAction.class),
558553
new ActionHandler<>(GetCalendarsAction.INSTANCE, TransportGetCalendarsAction.class),
559554
new ActionHandler<>(PutCalendarAction.INSTANCE, TransportPutCalendarAction.class),
560555
new ActionHandler<>(DeleteCalendarAction.INSTANCE, TransportDeleteCalendarAction.class),

0 commit comments

Comments
 (0)