-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move async task maintenance service to core plugin (#57700)
The async task task maintenance service is used by both async search plugin as well as EQL plugin. So it needs to reside in the core. Relates to #49638
- Loading branch information
Showing
10 changed files
with
216 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
...nc-search/src/main/java/org/elasticsearch/xpack/search/AsyncSearchMaintenanceService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
evaluationDependsOn(xpackModule('core')) | ||
|
||
apply plugin: 'elasticsearch.esplugin' | ||
|
||
esplugin { | ||
name 'x-pack-async' | ||
description 'A module which handles common async operations' | ||
classname 'org.elasticsearch.xpack.async.AsyncResultsIndexPlugin' | ||
extendedPlugins = ['x-pack-core'] | ||
} | ||
archivesBaseName = 'x-pack-async' | ||
|
||
dependencies { | ||
compileOnly project(":server") | ||
compileOnly project(path: xpackModule('core'), configuration: 'default') | ||
} | ||
|
||
dependencyLicenses { | ||
ignoreSha 'x-pack-core' | ||
} | ||
|
||
integTest.enabled = false | ||
|
88 changes: 88 additions & 0 deletions
88
x-pack/plugin/async/src/main/java/org/elasticsearch/xpack/async/AsyncResultsIndexPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.async; | ||
|
||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.env.Environment; | ||
import org.elasticsearch.env.NodeEnvironment; | ||
import org.elasticsearch.indices.SystemIndexDescriptor; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.plugins.SystemIndexPlugin; | ||
import org.elasticsearch.repositories.RepositoriesService; | ||
import org.elasticsearch.script.ScriptService; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.watcher.ResourceWatcherService; | ||
import org.elasticsearch.xpack.core.XPackPlugin; | ||
import org.elasticsearch.xpack.core.async.AsyncTaskIndexService; | ||
import org.elasticsearch.xpack.core.async.AsyncTaskMaintenanceService; | ||
import org.elasticsearch.xpack.core.search.action.AsyncSearchResponse; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
import static org.elasticsearch.xpack.core.ClientHelper.ASYNC_SEARCH_ORIGIN; | ||
|
||
public class AsyncResultsIndexPlugin extends Plugin implements SystemIndexPlugin { | ||
|
||
protected final Settings settings; | ||
|
||
public AsyncResultsIndexPlugin(Settings settings) { | ||
this.settings = settings; | ||
} | ||
|
||
@Override | ||
public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) { | ||
return Collections.singletonList(new SystemIndexDescriptor(XPackPlugin.ASYNC_RESULTS_INDEX, this.getClass().getSimpleName())); | ||
} | ||
|
||
@Override | ||
public Collection<Object> createComponents( | ||
Client client, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
ResourceWatcherService resourceWatcherService, | ||
ScriptService scriptService, | ||
NamedXContentRegistry xContentRegistry, | ||
Environment environment, | ||
NodeEnvironment nodeEnvironment, | ||
NamedWriteableRegistry namedWriteableRegistry, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
Supplier<RepositoriesService> repositoriesServiceSupplier | ||
) { | ||
List<Object> components = new ArrayList<>(); | ||
if (DiscoveryNode.isDataNode(environment.settings())) { | ||
// only data nodes should be eligible to run the maintenance service. | ||
AsyncTaskIndexService<AsyncSearchResponse> indexService = new AsyncTaskIndexService<>( | ||
XPackPlugin.ASYNC_RESULTS_INDEX, | ||
clusterService, | ||
threadPool.getThreadContext(), | ||
client, | ||
ASYNC_SEARCH_ORIGIN, | ||
AsyncSearchResponse::new, | ||
namedWriteableRegistry | ||
); | ||
AsyncTaskMaintenanceService maintenanceService = new AsyncTaskMaintenanceService( | ||
clusterService, | ||
nodeEnvironment.nodeId(), | ||
settings, | ||
threadPool, | ||
indexService | ||
); | ||
components.add(maintenanceService); | ||
} | ||
return components; | ||
} | ||
} |
Empty file.
20 changes: 20 additions & 0 deletions
20
...lugin/async/src/test/java/org/elasticsearch/xpack/async/AsyncResultsIndexPluginTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.async; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.hamcrest.Matchers; | ||
|
||
public class AsyncResultsIndexPluginTests extends ESTestCase { | ||
|
||
public void testDummy() { | ||
// This is a dummy test case to satisfy the conventions | ||
AsyncResultsIndexPlugin plugin = new AsyncResultsIndexPlugin(Settings.EMPTY); | ||
assertThat(plugin.getSystemIndexDescriptors(Settings.EMPTY), Matchers.hasSize(1)); | ||
} | ||
} |
Oops, something went wrong.