Skip to content

Commit

Permalink
Remove discovery-file plugin (#33257)
Browse files Browse the repository at this point in the history
In #33241 we moved the file-based discovery functionality to core
Elasticsearch, but preserved the `discovery-file` plugin, and support for the
existing location of the `unicast_hosts.txt` file, for BWC reasons. This commit
completes the removal of this plugin.
  • Loading branch information
DaveCTurner authored Sep 18, 2018
1 parent 9543992 commit 421f58e
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 309 deletions.
14 changes: 0 additions & 14 deletions docs/plugins/discovery-file.asciidoc

This file was deleted.

6 changes: 0 additions & 6 deletions docs/plugins/discovery.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ The Azure Classic discovery plugin uses the Azure Classic API for unicast discov

The Google Compute Engine discovery plugin uses the GCE API for unicast discovery.

<<discovery-file,File-based discovery>>::

The File-based discovery plugin allows providing the unicast hosts list through a dynamically updatable file.

[float]
==== Community contributed discovery plugins

Expand All @@ -38,5 +34,3 @@ include::discovery-ec2.asciidoc[]
include::discovery-azure-classic.asciidoc[]

include::discovery-gce.asciidoc[]

include::discovery-file.asciidoc[]
1 change: 0 additions & 1 deletion docs/reference/cat/plugins.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ U7321H6 analysis-stempel {version} The Stempel (Polish) Analysis plugin i
U7321H6 analysis-ukrainian {version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch.
U7321H6 discovery-azure-classic {version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism
U7321H6 discovery-ec2 {version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism.
U7321H6 discovery-file {version} Discovery file plugin enables unicast discovery from hosts stored in a file.
U7321H6 discovery-gce {version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism.
U7321H6 ingest-attachment {version} Ingest processor that uses Apache Tika to extract contents
U7321H6 ingest-geoip {version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database
Expand Down
10 changes: 9 additions & 1 deletion docs/reference/migration/migrate_7_0/plugins.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ See {plugins}/repository-gcs-client.html#repository-gcs-client[Google Cloud Stor
==== Analysis Plugin changes

* The misspelled helper method `requriesAnalysisSettings(AnalyzerProvider<T> provider)` has been
renamed to `requiresAnalysisSettings`
renamed to `requiresAnalysisSettings`

==== File-based discovery plugin

* This plugin has been removed since its functionality is now part of
Elasticsearch and requires no plugin. The location of the hosts file has moved
from `$ES_PATH_CONF/file-discovery/unicast_hosts.txt` to
`$ES_PATH_CONF/unicast_hosts.txt`. See <<file-based-hosts-provider, the
file-based hosts provider documentation>> for further information.
61 changes: 0 additions & 61 deletions plugins/discovery-file/build.gradle

This file was deleted.

20 changes: 0 additions & 20 deletions plugins/discovery-file/config/discovery-file/unicast_hosts.txt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ fi
install_and_check_plugin discovery ec2 aws-java-sdk-core-*.jar
}

@test "[$GROUP] install discovery-file plugin" {
install_and_check_plugin discovery file
}

@test "[$GROUP] install ingest-attachment plugin" {
# we specify the version on the poi-3.17.jar so that the test does
# not spuriously pass if the jar is missing but the other poi jars
Expand Down Expand Up @@ -364,10 +360,6 @@ fi
remove_plugin discovery-ec2
}

@test "[$GROUP] remove discovery-file plugin" {
remove_plugin discovery-file
}

@test "[$GROUP] remove ingest-attachment plugin" {
remove_plugin ingest-attachment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,28 @@ public class FileBasedUnicastHostsProvider extends AbstractComponent implements
public static final String UNICAST_HOSTS_FILE = "unicast_hosts.txt";

private final Path unicastHostsFilePath;
private final Path legacyUnicastHostsFilePath;

public FileBasedUnicastHostsProvider(Settings settings, Path configFile) {
super(settings);
this.unicastHostsFilePath = configFile.resolve(UNICAST_HOSTS_FILE);
this.legacyUnicastHostsFilePath = configFile.resolve("discovery-file").resolve(UNICAST_HOSTS_FILE);
}

private List<String> getHostsList() {
if (Files.exists(unicastHostsFilePath)) {
return readFileContents(unicastHostsFilePath);
}

if (Files.exists(legacyUnicastHostsFilePath)) {
deprecationLogger.deprecated("Found dynamic hosts list at [{}] but this path is deprecated. This list should be at [{}] " +
"instead. Support for the deprecated path will be removed in future.", legacyUnicastHostsFilePath, unicastHostsFilePath);
return readFileContents(legacyUnicastHostsFilePath);
try (Stream<String> lines = Files.lines(unicastHostsFilePath)) {
return lines.filter(line -> line.startsWith("#") == false) // lines starting with `#` are comments
.collect(Collectors.toList());
} catch (IOException e) {
logger.warn(() -> new ParameterizedMessage("failed to read file [{}]", unicastHostsFilePath), e);
return Collections.emptyList();
}
}

logger.warn("expected, but did not find, a dynamic hosts list at [{}]", unicastHostsFilePath);

return Collections.emptyList();
}

private List<String> readFileContents(Path path) {
try (Stream<String> lines = Files.lines(path)) {
return lines.filter(line -> line.startsWith("#") == false) // lines starting with `#` are comments
.collect(Collectors.toList());
} catch (IOException e) {
logger.warn(() -> new ParameterizedMessage("failed to read file [{}]", unicastHostsFilePath), e);
return Collections.emptyList();
}
}

@Override
public List<TransportAddress> buildDynamicHosts(HostsResolver hostsResolver) {
final List<TransportAddress> transportAddresses = hostsResolver.resolveHosts(getHostsList(), 1);
Expand Down
Loading

0 comments on commit 421f58e

Please sign in to comment.