Skip to content

Commit b24cf20

Browse files
masseykepull[bot]
authored andcommitted
Moving the data stream reindex task to x-pack (#117927)
1 parent 097e62d commit b24cf20

15 files changed

+173
-147
lines changed

modules/data-streams/src/main/java/org/elasticsearch/datastreams/DataStreamsPlugin.java

+1-64
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,19 @@
1919
import org.elasticsearch.action.datastreams.MigrateToDataStreamAction;
2020
import org.elasticsearch.action.datastreams.ModifyDataStreamsAction;
2121
import org.elasticsearch.action.datastreams.PromoteDataStreamAction;
22-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction;
2322
import org.elasticsearch.action.datastreams.lifecycle.ExplainDataStreamLifecycleAction;
2423
import org.elasticsearch.action.datastreams.lifecycle.GetDataStreamLifecycleAction;
2524
import org.elasticsearch.action.datastreams.lifecycle.PutDataStreamLifecycleAction;
26-
import org.elasticsearch.client.internal.Client;
2725
import org.elasticsearch.client.internal.OriginSettingClient;
2826
import org.elasticsearch.cluster.metadata.DataStream;
2927
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
3028
import org.elasticsearch.cluster.node.DiscoveryNodes;
31-
import org.elasticsearch.cluster.service.ClusterService;
3229
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
3330
import org.elasticsearch.common.settings.ClusterSettings;
3431
import org.elasticsearch.common.settings.IndexScopedSettings;
3532
import org.elasticsearch.common.settings.Setting;
3633
import org.elasticsearch.common.settings.Settings;
3734
import org.elasticsearch.common.settings.SettingsFilter;
38-
import org.elasticsearch.common.settings.SettingsModule;
3935
import org.elasticsearch.core.IOUtils;
4036
import org.elasticsearch.core.TimeValue;
4137
import org.elasticsearch.datastreams.action.CreateDataStreamTransportAction;
@@ -44,7 +40,6 @@
4440
import org.elasticsearch.datastreams.action.MigrateToDataStreamTransportAction;
4541
import org.elasticsearch.datastreams.action.ModifyDataStreamsTransportAction;
4642
import org.elasticsearch.datastreams.action.PromoteDataStreamTransportAction;
47-
import org.elasticsearch.datastreams.action.ReindexDataStreamTransportAction;
4843
import org.elasticsearch.datastreams.action.TransportGetDataStreamsAction;
4944
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleErrorStore;
5045
import org.elasticsearch.datastreams.lifecycle.DataStreamLifecycleService;
@@ -78,27 +73,14 @@
7873
import org.elasticsearch.datastreams.rest.RestMigrateToDataStreamAction;
7974
import org.elasticsearch.datastreams.rest.RestModifyDataStreamsAction;
8075
import org.elasticsearch.datastreams.rest.RestPromoteDataStreamAction;
81-
import org.elasticsearch.datastreams.task.ReindexDataStreamPersistentTaskExecutor;
82-
import org.elasticsearch.datastreams.task.ReindexDataStreamPersistentTaskState;
83-
import org.elasticsearch.datastreams.task.ReindexDataStreamStatus;
84-
import org.elasticsearch.datastreams.task.ReindexDataStreamTask;
85-
import org.elasticsearch.datastreams.task.ReindexDataStreamTaskParams;
8676
import org.elasticsearch.features.NodeFeature;
8777
import org.elasticsearch.health.HealthIndicatorService;
8878
import org.elasticsearch.index.IndexSettingProvider;
89-
import org.elasticsearch.persistent.PersistentTaskParams;
90-
import org.elasticsearch.persistent.PersistentTaskState;
91-
import org.elasticsearch.persistent.PersistentTasksExecutor;
9279
import org.elasticsearch.plugins.ActionPlugin;
9380
import org.elasticsearch.plugins.HealthPlugin;
94-
import org.elasticsearch.plugins.PersistentTaskPlugin;
9581
import org.elasticsearch.plugins.Plugin;
9682
import org.elasticsearch.rest.RestController;
9783
import org.elasticsearch.rest.RestHandler;
98-
import org.elasticsearch.tasks.Task;
99-
import org.elasticsearch.threadpool.ThreadPool;
100-
import org.elasticsearch.xcontent.NamedXContentRegistry;
101-
import org.elasticsearch.xcontent.ParseField;
10284

10385
import java.io.IOException;
10486
import java.time.Clock;
@@ -111,7 +93,7 @@
11193

11294
import static org.elasticsearch.cluster.metadata.DataStreamLifecycle.DATA_STREAM_LIFECYCLE_ORIGIN;
11395

114-
public class DataStreamsPlugin extends Plugin implements ActionPlugin, HealthPlugin, PersistentTaskPlugin {
96+
public class DataStreamsPlugin extends Plugin implements ActionPlugin, HealthPlugin {
11597

11698
public static final Setting<TimeValue> TIME_SERIES_POLL_INTERVAL = Setting.timeSetting(
11799
"time_series.poll_interval",
@@ -262,7 +244,6 @@ public Collection<?> createComponents(PluginServices services) {
262244
actions.add(new ActionHandler<>(PutDataStreamOptionsAction.INSTANCE, TransportPutDataStreamOptionsAction.class));
263245
actions.add(new ActionHandler<>(DeleteDataStreamOptionsAction.INSTANCE, TransportDeleteDataStreamOptionsAction.class));
264246
}
265-
actions.add(new ActionHandler<>(ReindexDataStreamAction.INSTANCE, ReindexDataStreamTransportAction.class));
266247
return actions;
267248
}
268249

@@ -321,48 +302,4 @@ public void close() throws IOException {
321302
public Collection<HealthIndicatorService> getHealthIndicatorServices() {
322303
return List.of(dataStreamLifecycleHealthIndicatorService.get());
323304
}
324-
325-
@Override
326-
public List<NamedXContentRegistry.Entry> getNamedXContent() {
327-
return List.of(
328-
new NamedXContentRegistry.Entry(
329-
PersistentTaskState.class,
330-
new ParseField(ReindexDataStreamPersistentTaskState.NAME),
331-
ReindexDataStreamPersistentTaskState::fromXContent
332-
),
333-
new NamedXContentRegistry.Entry(
334-
PersistentTaskParams.class,
335-
new ParseField(ReindexDataStreamTaskParams.NAME),
336-
ReindexDataStreamTaskParams::fromXContent
337-
)
338-
);
339-
}
340-
341-
@Override
342-
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
343-
return List.of(
344-
new NamedWriteableRegistry.Entry(
345-
PersistentTaskState.class,
346-
ReindexDataStreamPersistentTaskState.NAME,
347-
ReindexDataStreamPersistentTaskState::new
348-
),
349-
new NamedWriteableRegistry.Entry(
350-
PersistentTaskParams.class,
351-
ReindexDataStreamTaskParams.NAME,
352-
ReindexDataStreamTaskParams::new
353-
),
354-
new NamedWriteableRegistry.Entry(Task.Status.class, ReindexDataStreamStatus.NAME, ReindexDataStreamStatus::new)
355-
);
356-
}
357-
358-
@Override
359-
public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(
360-
ClusterService clusterService,
361-
ThreadPool threadPool,
362-
Client client,
363-
SettingsModule settingsModule,
364-
IndexNameExpressionResolver expressionResolver
365-
) {
366-
return List.of(new ReindexDataStreamPersistentTaskExecutor(client, clusterService, ReindexDataStreamTask.TASK_NAME, threadPool));
367-
}
368305
}

x-pack/plugin/migrate/build.gradle

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apply plugin: 'elasticsearch.internal-es-plugin'
2+
apply plugin: 'elasticsearch.internal-cluster-test'
3+
4+
esplugin {
5+
name 'x-pack-migrate'
6+
description 'Elasticsearch Expanded Pack Plugin - Index and Data Stream Migration'
7+
classname 'org.elasticsearch.xpack.migrate.MigratePlugin'
8+
extendedPlugins = ['x-pack-core']
9+
hasNativeController false
10+
requiresKeystore true
11+
}
12+
base {
13+
archivesName = 'x-pack-migrate'
14+
}
15+
16+
dependencies {
17+
compileOnly project(path: xpackModule('core'))
18+
testImplementation(testArtifact(project(xpackModule('core'))))
19+
testImplementation project(xpackModule('ccr'))
20+
testImplementation project(':modules:data-streams')
21+
testImplementation project(path: ':modules:reindex')
22+
}
23+
24+
addQaCheckDependencies(project)
+9-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the "Elastic License
4-
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5-
* Public License v 1"; you may not use this file except in compliance with, at
6-
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7-
* License v3.0 only", or the "Server Side Public License, v 1".
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
86
*/
97

10-
package org.elasticsearch.datastreams.action;
8+
package org.elasticsearch.xpack.migrate.action;
119

1210
import org.elasticsearch.ResourceNotFoundException;
1311
import org.elasticsearch.action.ActionListener;
@@ -17,21 +15,21 @@
1715
import org.elasticsearch.action.admin.indices.rollover.RolloverRequestBuilder;
1816
import org.elasticsearch.action.admin.indices.template.put.TransportPutComposableIndexTemplateAction;
1917
import org.elasticsearch.action.datastreams.CreateDataStreamAction;
20-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction;
21-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction.ReindexDataStreamRequest;
22-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction.ReindexDataStreamResponse;
2318
import org.elasticsearch.action.index.IndexRequest;
2419
import org.elasticsearch.action.support.master.AcknowledgedResponse;
2520
import org.elasticsearch.cluster.metadata.ComposableIndexTemplate;
2621
import org.elasticsearch.cluster.metadata.Template;
2722
import org.elasticsearch.datastreams.DataStreamsPlugin;
28-
import org.elasticsearch.datastreams.task.ReindexDataStreamTask;
2923
import org.elasticsearch.plugins.Plugin;
3024
import org.elasticsearch.tasks.CancellableTask;
3125
import org.elasticsearch.tasks.TaskManager;
3226
import org.elasticsearch.test.ESIntegTestCase;
3327
import org.elasticsearch.transport.TransportService;
3428
import org.elasticsearch.xcontent.XContentType;
29+
import org.elasticsearch.xpack.migrate.MigratePlugin;
30+
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamRequest;
31+
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamResponse;
32+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTask;
3533

3634
import java.util.Collection;
3735
import java.util.List;
@@ -48,7 +46,7 @@ public class ReindexDataStreamTransportActionIT extends ESIntegTestCase {
4846

4947
@Override
5048
protected Collection<Class<? extends Plugin>> nodePlugins() {
51-
return List.of(DataStreamsPlugin.class);
49+
return List.of(DataStreamsPlugin.class, MigratePlugin.class);
5250
}
5351

5452
public void testNonExistentDataStream() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.migrate;
9+
10+
import org.elasticsearch.action.ActionRequest;
11+
import org.elasticsearch.action.ActionResponse;
12+
import org.elasticsearch.client.internal.Client;
13+
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
14+
import org.elasticsearch.cluster.service.ClusterService;
15+
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
16+
import org.elasticsearch.common.settings.SettingsModule;
17+
import org.elasticsearch.persistent.PersistentTaskParams;
18+
import org.elasticsearch.persistent.PersistentTaskState;
19+
import org.elasticsearch.persistent.PersistentTasksExecutor;
20+
import org.elasticsearch.plugins.ActionPlugin;
21+
import org.elasticsearch.plugins.PersistentTaskPlugin;
22+
import org.elasticsearch.plugins.Plugin;
23+
import org.elasticsearch.tasks.Task;
24+
import org.elasticsearch.threadpool.ThreadPool;
25+
import org.elasticsearch.xcontent.NamedXContentRegistry;
26+
import org.elasticsearch.xcontent.ParseField;
27+
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction;
28+
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamTransportAction;
29+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamPersistentTaskExecutor;
30+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamPersistentTaskState;
31+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamStatus;
32+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTask;
33+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTaskParams;
34+
35+
import java.util.ArrayList;
36+
import java.util.List;
37+
38+
public class MigratePlugin extends Plugin implements ActionPlugin, PersistentTaskPlugin {
39+
40+
@Override
41+
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
42+
List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> actions = new ArrayList<>();
43+
actions.add(new ActionHandler<>(ReindexDataStreamAction.INSTANCE, ReindexDataStreamTransportAction.class));
44+
return actions;
45+
}
46+
47+
@Override
48+
public List<NamedXContentRegistry.Entry> getNamedXContent() {
49+
return List.of(
50+
new NamedXContentRegistry.Entry(
51+
PersistentTaskState.class,
52+
new ParseField(ReindexDataStreamPersistentTaskState.NAME),
53+
ReindexDataStreamPersistentTaskState::fromXContent
54+
),
55+
new NamedXContentRegistry.Entry(
56+
PersistentTaskParams.class,
57+
new ParseField(ReindexDataStreamTaskParams.NAME),
58+
ReindexDataStreamTaskParams::fromXContent
59+
)
60+
);
61+
}
62+
63+
@Override
64+
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
65+
return List.of(
66+
new NamedWriteableRegistry.Entry(
67+
PersistentTaskState.class,
68+
ReindexDataStreamPersistentTaskState.NAME,
69+
ReindexDataStreamPersistentTaskState::new
70+
),
71+
new NamedWriteableRegistry.Entry(
72+
PersistentTaskParams.class,
73+
ReindexDataStreamTaskParams.NAME,
74+
ReindexDataStreamTaskParams::new
75+
),
76+
new NamedWriteableRegistry.Entry(Task.Status.class, ReindexDataStreamStatus.NAME, ReindexDataStreamStatus::new)
77+
);
78+
}
79+
80+
@Override
81+
public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor(
82+
ClusterService clusterService,
83+
ThreadPool threadPool,
84+
Client client,
85+
SettingsModule settingsModule,
86+
IndexNameExpressionResolver expressionResolver
87+
) {
88+
return List.of(new ReindexDataStreamPersistentTaskExecutor(client, clusterService, ReindexDataStreamTask.TASK_NAME, threadPool));
89+
}
90+
}

server/src/main/java/org/elasticsearch/action/datastreams/ReindexDataStreamAction.java x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/ReindexDataStreamAction.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the "Elastic License
4-
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5-
* Public License v 1"; you may not use this file except in compliance with, at
6-
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7-
* License v3.0 only", or the "Server Side Public License, v 1".
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
86
*/
97

10-
package org.elasticsearch.action.datastreams;
8+
package org.elasticsearch.xpack.migrate.action;
119

1210
import org.elasticsearch.action.ActionRequest;
1311
import org.elasticsearch.action.ActionRequestValidationException;

modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/ReindexDataStreamTransportAction.java x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/action/ReindexDataStreamTransportAction.java

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the "Elastic License
4-
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5-
* Public License v 1"; you may not use this file except in compliance with, at
6-
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7-
* License v3.0 only", or the "Server Side Public License, v 1".
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
86
*/
97

10-
package org.elasticsearch.datastreams.action;
8+
package org.elasticsearch.xpack.migrate.action;
119

1210
import org.elasticsearch.ResourceAlreadyExistsException;
1311
import org.elasticsearch.ResourceNotFoundException;
1412
import org.elasticsearch.action.ActionListener;
15-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction;
16-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction.ReindexDataStreamRequest;
17-
import org.elasticsearch.action.datastreams.ReindexDataStreamAction.ReindexDataStreamResponse;
1813
import org.elasticsearch.action.support.ActionFilters;
1914
import org.elasticsearch.action.support.HandledTransportAction;
2015
import org.elasticsearch.cluster.metadata.DataStream;
2116
import org.elasticsearch.cluster.metadata.Metadata;
2217
import org.elasticsearch.cluster.service.ClusterService;
23-
import org.elasticsearch.datastreams.task.ReindexDataStreamTask;
24-
import org.elasticsearch.datastreams.task.ReindexDataStreamTaskParams;
2518
import org.elasticsearch.injection.guice.Inject;
2619
import org.elasticsearch.persistent.PersistentTasksService;
2720
import org.elasticsearch.tasks.Task;
2821
import org.elasticsearch.threadpool.ThreadPool;
2922
import org.elasticsearch.transport.TransportService;
23+
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamRequest;
24+
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamResponse;
25+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTask;
26+
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTaskParams;
3027

3128
/*
3229
* This transport action creates a new persistent task for reindexing the source data stream given in the request. On successful creation

modules/data-streams/src/main/java/org/elasticsearch/datastreams/task/ReindexDataStreamPersistentTaskExecutor.java x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskExecutor.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the "Elastic License
4-
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5-
* Public License v 1"; you may not use this file except in compliance with, at
6-
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7-
* License v3.0 only", or the "Server Side Public License, v 1".
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
86
*/
97

10-
package org.elasticsearch.datastreams.task;
8+
package org.elasticsearch.xpack.migrate.task;
119

1210
import org.elasticsearch.ElasticsearchException;
1311
import org.elasticsearch.action.ActionListener;

modules/data-streams/src/main/java/org/elasticsearch/datastreams/task/ReindexDataStreamPersistentTaskState.java x-pack/plugin/migrate/src/main/java/org/elasticsearch/xpack/migrate/task/ReindexDataStreamPersistentTaskState.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/*
22
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3-
* or more contributor license agreements. Licensed under the "Elastic License
4-
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5-
* Public License v 1"; you may not use this file except in compliance with, at
6-
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7-
* License v3.0 only", or the "Server Side Public License, v 1".
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
86
*/
97

10-
package org.elasticsearch.datastreams.task;
8+
package org.elasticsearch.xpack.migrate.task;
119

1210
import org.elasticsearch.common.io.stream.StreamInput;
1311
import org.elasticsearch.common.io.stream.StreamOutput;

0 commit comments

Comments
 (0)