-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enterprise GeoIp Task experiment #110207
Draft
masseyke
wants to merge
14
commits into
elastic:main
Choose a base branch
from
masseyke:enterprise-geoip-task-experiment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Enterprise GeoIp Task experiment #110207
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d2d1880
Enterprise GeoIp Task experiment
masseyke 1e6c13f
deleted junk, spotlessapply, added transport version
masseyke f677f0f
LicensedEnterpriseGeoIpDownloaderTaskExecutor does not need to be a P…
masseyke daf7107
renamed LicensedEnterpriseGeoIpDownloaderTaskExecutor to LicensedEnte…
masseyke de507a7
Simplify slightly, treeshaking
joegallo d28cfcd
TODOs as review
joegallo 2138d6e
WIP switching to a LicenseStateListener
joegallo 1b69eab
Add a module for the enterprise downloader
joegallo 355fb4b
Reorder slightly to decrease overall diff
joegallo 6d15790
Whitespace
joegallo 98273cf
More treeshaking
joegallo bae9e09
Add a todo and the state to the logs
joegallo 50ce1eb
Merge branch 'main' into enterprise-geoip-task-experiment
joegallo 3c2fe4b
A slightly simpler approach
joegallo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
43 changes: 43 additions & 0 deletions
43
...p/src/main/java/org/elasticsearch/ingest/geoip/EnterpriseGeoIpDownloaderTaskExecutor.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,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.ingest.geoip; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.elasticsearch.client.internal.Client; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.persistent.AllocatedPersistentTask; | ||
import org.elasticsearch.persistent.PersistentTaskParams; | ||
import org.elasticsearch.persistent.PersistentTaskState; | ||
import org.elasticsearch.persistent.PersistentTasksExecutor; | ||
import org.elasticsearch.persistent.PersistentTasksService; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
|
||
import static org.elasticsearch.ingest.geoip.enterprise.EnterpriseGeoIpTaskParams.ENTERPRISE_GEOIP_DOWNLOADER; | ||
|
||
public class EnterpriseGeoIpDownloaderTaskExecutor extends PersistentTasksExecutor<PersistentTaskParams> { | ||
private static final Logger logger = LogManager.getLogger(GeoIpDownloader.class); | ||
|
||
private final PersistentTasksService persistentTasksService; | ||
|
||
protected EnterpriseGeoIpDownloaderTaskExecutor( | ||
Client client, | ||
HttpClient httpClient, | ||
ClusterService clusterService, | ||
ThreadPool threadPool | ||
) { | ||
super(ENTERPRISE_GEOIP_DOWNLOADER, threadPool.generic()); | ||
persistentTasksService = new PersistentTasksService(clusterService, threadPool, client); | ||
} | ||
|
||
@Override | ||
protected void nodeOperation(AllocatedPersistentTask task, PersistentTaskParams params, PersistentTaskState state) { | ||
logger.info("Running enterprise downloader"); | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
...ip/src/main/java/org/elasticsearch/ingest/geoip/enterprise/EnterpriseGeoIpTaskParams.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,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.ingest.geoip.enterprise; | ||
|
||
import org.elasticsearch.TransportVersion; | ||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.persistent.PersistentTaskParams; | ||
import org.elasticsearch.xcontent.ObjectParser; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
import org.elasticsearch.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.ingest.geoip.GeoIpDownloader.GEOIP_DOWNLOADER; | ||
|
||
public class EnterpriseGeoIpTaskParams implements PersistentTaskParams { | ||
|
||
public static final String ENTERPRISE_GEOIP_DOWNLOADER = "enterprise-" + GEOIP_DOWNLOADER; | ||
|
||
public static final ObjectParser<EnterpriseGeoIpTaskParams, Void> PARSER = new ObjectParser<>( | ||
ENTERPRISE_GEOIP_DOWNLOADER, | ||
true, | ||
EnterpriseGeoIpTaskParams::new | ||
); | ||
|
||
public EnterpriseGeoIpTaskParams() {} | ||
|
||
public EnterpriseGeoIpTaskParams(StreamInput in) {} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public String getWriteableName() { | ||
return ENTERPRISE_GEOIP_DOWNLOADER; | ||
} | ||
|
||
@Override | ||
public TransportVersion getMinimalSupportedVersion() { | ||
return TransportVersions.ENTERPRISE_GEOIP_DOWNLOADER; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) {} | ||
|
||
public static EnterpriseGeoIpTaskParams fromXContent(XContentParser parser) { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return obj instanceof EnterpriseGeoIpTaskParams; | ||
} | ||
} |
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
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,20 @@ | ||
apply plugin: 'elasticsearch.internal-es-plugin' | ||
apply plugin: 'elasticsearch.internal-yaml-rest-test' | ||
apply plugin: 'elasticsearch.internal-cluster-test' | ||
esplugin { | ||
name 'x-pack-geoip-enterprise-downloader' | ||
description 'Elasticsearch Expanded Pack Plugin - Geoip Enterprise Downloader' | ||
classname 'org.elasticsearch.xpack.geoip.EnterpriseDownloaderPlugin' | ||
extendedPlugins = ['x-pack-core'] | ||
} | ||
base { | ||
archivesName = 'x-pack-geoip-enterprise-downloader' | ||
} | ||
|
||
dependencies { | ||
compileOnly project(path: xpackModule('core')) | ||
implementation project(':modules:ingest-geoip') | ||
testImplementation(testArtifact(project(xpackModule('core')))) | ||
} | ||
|
||
addQaCheckDependencies(project) |
60 changes: 60 additions & 0 deletions
60
...se-downloader/src/main/java/org/elasticsearch/xpack/geoip/EnterpriseDownloaderPlugin.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,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.geoip; | ||
|
||
import org.elasticsearch.client.internal.Client; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.settings.SettingsModule; | ||
import org.elasticsearch.license.XPackLicenseState; | ||
import org.elasticsearch.persistent.PersistentTasksExecutor; | ||
import org.elasticsearch.plugins.IngestPlugin; | ||
import org.elasticsearch.plugins.PersistentTaskPlugin; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.xpack.core.XPackPlugin; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class EnterpriseDownloaderPlugin extends Plugin implements IngestPlugin, PersistentTaskPlugin { | ||
|
||
private final Settings settings; | ||
private EnterpriseGeoIpDownloaderLicenseListener enterpriseGeoIpDownloaderTaskExecutor; | ||
|
||
public EnterpriseDownloaderPlugin(final Settings settings) { | ||
this.settings = settings; | ||
} | ||
|
||
protected XPackLicenseState getLicenseState() { | ||
return XPackPlugin.getSharedLicenseState(); | ||
} | ||
|
||
@Override | ||
public Collection<?> createComponents(PluginServices services) { | ||
enterpriseGeoIpDownloaderTaskExecutor = new EnterpriseGeoIpDownloaderLicenseListener( | ||
services.client(), | ||
services.clusterService(), | ||
services.threadPool(), | ||
getLicenseState() | ||
); | ||
enterpriseGeoIpDownloaderTaskExecutor.init(); | ||
return List.of(enterpriseGeoIpDownloaderTaskExecutor); | ||
} | ||
|
||
@Override | ||
public List<PersistentTasksExecutor<?>> getPersistentTasksExecutor( | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
Client client, | ||
SettingsModule settingsModule, | ||
IndexNameExpressionResolver expressionResolver | ||
) { | ||
return List.of(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some
to [...]
that could go here that would work?