Skip to content

Commit

Permalink
[Feature/extensions] Read from extensions.yml (#3381)
Browse files Browse the repository at this point in the history
* Fixed git errors

Signed-off-by: Ryan Bogan <rbogan@amazon.com>

* Added ExtensionsSettings file and corresponding method in ExtensionsOrchestrator to read from extensions.yml

Signed-off-by: Ryan Bogan <rbogan@amazon.com>

* Removed unnecessary files

Signed-off-by: Ryan Bogan <rbogan@amazon.com>

* Fixed lint errors

Signed-off-by: Ryan Bogan <rbogan@amazon.com>

* Added more asserts to tests and removed unnecessary dependencies

Signed-off-by: Ryan Bogan <rbogan@amazon.com>

* Fixed gradle check errors

Signed-off-by: Ryan Bogan <rbogan@amazon.com>

* Removed unused import

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
  • Loading branch information
ryanbogan authored May 18, 2022
1 parent 84a61bc commit 3b58b05
Show file tree
Hide file tree
Showing 36 changed files with 212 additions and 153 deletions.
2 changes: 0 additions & 2 deletions modules/ingest-geoip/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ opensearchplugin {
dependencies {
api('com.maxmind.geoip2:geoip2:3.0.1')
// geoip2 dependencies:
api("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
api("com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}")
api('com.maxmind.db:maxmind-db:2.0.0')

testImplementation 'org.elasticsearch:geolite2-databases:20191119'
Expand Down

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions modules/ingest-geoip/licenses/jackson-databind-LICENSE

This file was deleted.

20 changes: 0 additions & 20 deletions modules/ingest-geoip/licenses/jackson-databind-NOTICE

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/discovery-ec2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ dependencies {
api "commons-logging:commons-logging:${versions.commonslogging}"
api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
api "commons-codec:commons-codec:${versions.commonscodec}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
}

restResources {
Expand Down
8 changes: 0 additions & 8 deletions plugins/discovery-ec2/licenses/jackson-LICENSE

This file was deleted.

20 changes: 0 additions & 20 deletions plugins/discovery-ec2/licenses/jackson-NOTICE

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions plugins/repository-azure/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ dependencies {
api 'io.projectreactor.netty:reactor-netty-core:1.0.16'
api 'io.projectreactor.netty:reactor-netty-http:1.0.18'
api "org.slf4j:slf4j-api:${versions.slf4j}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${versions.jackson}"
api "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${versions.jackson}"
api "com.fasterxml.jackson.module:jackson-module-jaxb-annotations:${versions.jackson}"
Expand Down
8 changes: 0 additions & 8 deletions plugins/repository-azure/licenses/jackson-LICENSE

This file was deleted.

20 changes: 0 additions & 20 deletions plugins/repository-azure/licenses/jackson-NOTICE

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion plugins/repository-hdfs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ dependencies {
api 'org.apache.htrace:htrace-core4:4.2.0-incubating'
api "org.apache.logging.log4j:log4j-core:${versions.log4j}"
api 'org.apache.avro:avro:1.10.2'
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api 'com.google.code.gson:gson:2.9.0'
runtimeOnly 'com.google.guava:guava:31.1-jre'
api 'com.google.protobuf:protobuf-java:3.20.1'
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/repository-s3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ dependencies {
api "commons-logging:commons-logging:${versions.commonslogging}"
api "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
api "commons-codec:commons-codec:${versions.commonscodec}"
api "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
api "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
api "joda-time:joda-time:${versions.joda}"

Expand Down
8 changes: 0 additions & 8 deletions plugins/repository-s3/licenses/jackson-LICENSE

This file was deleted.

20 changes: 0 additions & 20 deletions plugins/repository-s3/licenses/jackson-NOTICE

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 3 additions & 22 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ dependencies {
// jna
api "net.java.dev.jna:jna:${versions.jna}"

api "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
api "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"

testImplementation(project(":test:framework")) {
// tests use the locally compiled version of server
exclude group: 'org.opensearch', module: 'server'
Expand Down Expand Up @@ -223,31 +226,12 @@ tasks.named("processResources").configure {

tasks.named("thirdPartyAudit").configure {
ignoreMissingClasses(
// from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml)
'com.fasterxml.jackson.databind.ObjectMapper',

// from log4j
'com.conversantmedia.util.concurrent.SpinPolicy',
'com.fasterxml.jackson.annotation.JsonInclude$Include',
'com.fasterxml.jackson.databind.DeserializationContext',
'com.fasterxml.jackson.databind.DeserializationFeature',
'com.fasterxml.jackson.databind.JsonMappingException',
'com.fasterxml.jackson.databind.JsonNode',
'com.fasterxml.jackson.databind.Module$SetupContext',
'com.fasterxml.jackson.databind.ObjectReader',
'com.fasterxml.jackson.databind.ObjectWriter',
'com.fasterxml.jackson.databind.SerializerProvider',
'com.fasterxml.jackson.databind.deser.std.StdDeserializer',
'com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer',
'com.fasterxml.jackson.databind.module.SimpleModule',
'com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter',
'com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider',
'com.fasterxml.jackson.databind.ser.std.StdScalarSerializer',
'com.fasterxml.jackson.databind.ser.std.StdSerializer',
'com.fasterxml.jackson.dataformat.xml.JacksonXmlModule',
'com.fasterxml.jackson.dataformat.xml.XmlMapper',
'com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter',
'com.fasterxml.jackson.databind.node.ObjectNode',
'org.fusesource.jansi.Ansi',
'org.fusesource.jansi.AnsiRenderer$Code',
'com.lmax.disruptor.EventFactory',
Expand Down Expand Up @@ -307,9 +291,6 @@ tasks.named("thirdPartyAudit").configure {
'org.noggit.JSONParser',

// from lucene-spatial
'com.fasterxml.jackson.databind.JsonSerializer',
'com.fasterxml.jackson.databind.JsonDeserializer',
'com.fasterxml.jackson.databind.node.ArrayNode',
'com.google.common.geometry.S2Cell',
'com.google.common.geometry.S2CellId',
'com.google.common.geometry.S2Projections',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

package org.opensearch.extensions;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
Expand Down Expand Up @@ -36,6 +39,7 @@
import org.opensearch.transport.TransportService;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Path;
Expand Down Expand Up @@ -98,6 +102,32 @@ private void extensionsDiscovery() throws IOException {
for (final Path plugin : PluginsService.findPluginDirs(extensionsPath)) {
try {
PluginInfo pluginInfo = PluginInfo.readFromProperties(plugin);

// TODO: Add unit tests for commented section below

/**
try {
List<Extension> extensions = readFromExtensionsYml(extensionsPath.toString()).getExtensions();
for(Extension extension : extensions) {
extensionsSet.add(
new DiscoveryExtension(
extension.getName(),
"id",
extension.getEphemeralId(),
extension.getHostName(),
extension.getHostAddress(),
new TransportAddress(TransportAddress.META_ADDRESS, Integer.parseInt(extension.getPort())),
null,
Version.fromString(extension.getVersion()),
pluginInfo
)
);
}
} catch (Exception e) {
//ignore
}
*/

/*
* TODO: Read from extensions.yml
* https://github.com/opensearch-project/OpenSearch/issues/3084
Expand Down Expand Up @@ -262,4 +292,12 @@ public String executor() {
logger.error(e.toString());
}
}

public static ExtensionsSettings readFromExtensionsYml(String filePath) throws Exception {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
InputStream input = ExtensionsOrchestrator.class.getResourceAsStream(filePath);
ExtensionsSettings extensionSettings = objectMapper.readValue(input, ExtensionsSettings.class);
return extensionSettings;
}

}
Loading

0 comments on commit 3b58b05

Please sign in to comment.