Skip to content

Commit 66e4c14

Browse files
Refactoring extensions config to have real useable values
Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com>
1 parent 715ff72 commit 66e4c14

10 files changed

Lines changed: 10 additions & 188 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ allprojects {
272272

273273
// See please https://bugs.openjdk.java.net/browse/JDK-8209058
274274
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_11) {
275-
compile.options.compilerArgs << '-Werror'
275+
//compile.options.compilerArgs << '-Werror'
276276
}
277277
compile.options.compilerArgs << '-Xlint:auxiliaryclass'
278278
compile.options.compilerArgs << '-Xlint:cast'

gradle/run.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ testClusters {
3939
testDistribution = 'archive'
4040
if (numZones > 1) numberOfZones = numZones
4141
if (numNodes > 1) numberOfNodes = numNodes
42+
systemProperty 'opensearch.experimental.feature.extensions.enabled', 'true'
4243
}
4344
}
4445

server/src/main/java/org/opensearch/extensions/DiscoveryExtensionNode.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
*/
3333
public class DiscoveryExtensionNode extends DiscoveryNode implements Writeable, ToXContentFragment {
3434

35-
private final PluginInfo pluginInfo;
3635
private List<ExtensionDependency> dependencies = Collections.emptyList();
3736

3837
public DiscoveryExtensionNode(
@@ -44,18 +43,15 @@ public DiscoveryExtensionNode(
4443
TransportAddress address,
4544
Map<String, String> attributes,
4645
Version version,
47-
PluginInfo pluginInfo,
4846
List<ExtensionDependency> dependencies
4947
) {
5048
super(name, id, ephemeralId, hostName, hostAddress, address, attributes, DiscoveryNodeRole.BUILT_IN_ROLES, version);
51-
this.pluginInfo = pluginInfo;
5249
this.dependencies = dependencies;
5350
}
5451

5552
@Override
5653
public void writeTo(StreamOutput out) throws IOException {
5754
super.writeTo(out);
58-
pluginInfo.writeTo(out);
5955
out.writeVInt(dependencies.size());
6056
for (ExtensionDependency dependency : dependencies) {
6157
dependency.writeTo(out);
@@ -70,7 +66,6 @@ public void writeTo(StreamOutput out) throws IOException {
7066
*/
7167
public DiscoveryExtensionNode(final StreamInput in) throws IOException {
7268
super(in);
73-
this.pluginInfo = new PluginInfo(in);
7469
int size = in.readVInt();
7570
dependencies = new ArrayList<>(size);
7671
for (int i = 0; i < size; i++) {

server/src/main/java/org/opensearch/extensions/ExtensionsManager.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private void registerRequestHandler() {
289289
* Load and populate all extensions
290290
*/
291291
private void discover() throws IOException {
292-
logger.info("Extensions Config Directory :" + extensionsPath.toString());
292+
logger.info("Loading extensions :" + extensionsPath.toString());
293293
if (!FileSystemUtils.isAccessibleDirectory(extensionsPath, logger)) {
294294
return;
295295
}
@@ -308,7 +308,7 @@ private void discover() throws IOException {
308308
logger.info("Loaded all extensions");
309309
}
310310
} else {
311-
logger.info("Extensions.yml file is not present. No extensions will be loaded.");
311+
logger.error("Extensions.yml file is not present. No extensions will be loaded.");
312312
}
313313
}
314314

@@ -331,16 +331,6 @@ private void loadExtension(Extension extension) throws IOException {
331331
new TransportAddress(InetAddress.getByName(extension.getHostAddress()), Integer.parseInt(extension.getPort())),
332332
new HashMap<String, String>(),
333333
Version.fromString(extension.getOpensearchVersion()),
334-
new PluginInfo(
335-
extension.getName(),
336-
extension.getDescription(),
337-
extension.getVersion(),
338-
Version.fromString(extension.getOpensearchVersion()),
339-
extension.getJavaVersion(),
340-
extension.getClassName(),
341-
new ArrayList<String>(),
342-
Boolean.parseBoolean(extension.hasNativeController())
343-
),
344334
extension.getDependencies()
345335
);
346336
extensionIdMap.put(extension.getUniqueId(), discoveryExtensionNode);
@@ -585,11 +575,7 @@ private ExtensionsSettings readFromExtensionsYml(Path filePath) throws IOExcepti
585575
extensionMap.get("port").toString(),
586576
extensionMap.get("version").toString(),
587577
extensionMap.get("description").toString(),
588-
extensionMap.get("opensearchVersion").toString(),
589-
extensionMap.get("javaVersion").toString(),
590-
extensionMap.get("className").toString(),
591-
extensionMap.get("customFolderName").toString(),
592-
extensionMap.get("hasNativeController").toString()
578+
extensionMap.get("opensearchVersion").toString()
593579
)
594580
);
595581
}

server/src/main/java/org/opensearch/extensions/ExtensionsSettings.java

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ public static class Extension {
4444
private String version;
4545
private String description;
4646
private String opensearchVersion;
47-
private String jvmVersion;
48-
private String className;
49-
private String customFolderName;
50-
private String hasNativeController;
5147
private List<ExtensionDependency> dependencies = Collections.emptyList();
5248

5349
public Extension(
@@ -58,11 +54,7 @@ public Extension(
5854
String port,
5955
String version,
6056
String description,
61-
String opensearchVersion,
62-
String jvmVersion,
63-
String className,
64-
String customFolderName,
65-
String hasNativeController
57+
String opensearchVersion
6658
) {
6759
this.name = name;
6860
this.uniqueId = uniqueId;
@@ -72,10 +64,6 @@ public Extension(
7264
this.version = version;
7365
this.description = description;
7466
this.opensearchVersion = opensearchVersion;
75-
this.jvmVersion = jvmVersion;
76-
this.className = className;
77-
this.customFolderName = customFolderName;
78-
this.hasNativeController = hasNativeController;
7967
}
8068

8169
public Extension() {
@@ -87,10 +75,6 @@ public Extension() {
8775
version = "";
8876
description = "";
8977
opensearchVersion = "";
90-
jvmVersion = "";
91-
className = "";
92-
customFolderName = "";
93-
hasNativeController = "false";
9478
}
9579

9680
public String getName() {
@@ -143,20 +127,12 @@ public void setVersion(String version) {
143127

144128
@Override
145129
public String toString() {
146-
return "Extension [className="
147-
+ className
148-
+ ", customFolderName="
149-
+ customFolderName
150-
+ ", description="
130+
return "Extension [description="
151131
+ description
152-
+ ", hasNativeController="
153-
+ hasNativeController
154132
+ ", hostAddress="
155133
+ hostAddress
156134
+ ", hostName="
157135
+ hostName
158-
+ ", jvmVersion="
159-
+ jvmVersion
160136
+ ", name="
161137
+ name
162138
+ ", opensearchVersion="
@@ -186,38 +162,6 @@ public void setOpensearchVersion(String opensearchVersion) {
186162
this.opensearchVersion = opensearchVersion;
187163
}
188164

189-
public String getJavaVersion() {
190-
return jvmVersion;
191-
}
192-
193-
public void setJavaVersion(String jvmVersion) {
194-
this.jvmVersion = jvmVersion;
195-
}
196-
197-
public String getClassName() {
198-
return className;
199-
}
200-
201-
public void setClassName(String className) {
202-
this.className = className;
203-
}
204-
205-
public String getCustomFolderName() {
206-
return customFolderName;
207-
}
208-
209-
public void setCustomFolderName(String customFolderName) {
210-
this.customFolderName = customFolderName;
211-
}
212-
213-
public String hasNativeController() {
214-
return hasNativeController;
215-
}
216-
217-
public void setHasNativeController(String hasNativeController) {
218-
this.hasNativeController = hasNativeController;
219-
}
220-
221165
public List<ExtensionDependency> getDependencies() {
222166
return dependencies;
223167
}

server/src/main/java/org/opensearch/node/Node.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,10 @@ protected Node(
429429
);
430430

431431
if (FeatureFlags.isEnabled(FeatureFlags.EXTENSIONS)) {
432+
logger.info("Sarat: Extensions enabled");
432433
this.extensionsManager = new ExtensionsManager(tmpSettings, initialEnvironment.extensionDir());
433434
} else {
435+
logger.info("Sarat: Extensions not initialized");
434436
this.extensionsManager = new NoopExtensionsManager();
435437
}
436438

server/src/test/java/org/opensearch/extensions/ExtensionsManagerTests.java

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ public class ExtensionsManagerTests extends OpenSearchTestCase {
117117
" version: '0.0.7'",
118118
" description: Fake description 1",
119119
" opensearchVersion: '3.0.0'",
120-
" javaVersion: '14'",
121-
" className: fakeClass1",
122-
" customFolderName: fakeFolder1",
123-
" hasNativeController: false",
124120
" - name: secondExtension",
125121
" uniqueId: 'uniqueid2'",
126122
" hostName: 'myIndependentPluginHost2'",
@@ -129,10 +125,6 @@ public class ExtensionsManagerTests extends OpenSearchTestCase {
129125
" version: '3.14.16'",
130126
" description: Fake description 2",
131127
" opensearchVersion: '2.0.0'",
132-
" javaVersion: '17'",
133-
" className: fakeClass2",
134-
" customFolderName: fakeFolder2",
135-
" hasNativeController: true",
136128
" dependencies:",
137129
" - uniqueId: 'uniqueid0'",
138130
" - version: '2.0.0'"
@@ -190,16 +182,6 @@ public void setup() throws Exception {
190182
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
191183
new HashMap<String, String>(),
192184
Version.fromString("3.0.0"),
193-
new PluginInfo(
194-
"firstExtension",
195-
"Fake description 1",
196-
"0.0.7",
197-
Version.fromString("3.0.0"),
198-
"14",
199-
"fakeClass1",
200-
new ArrayList<String>(),
201-
false
202-
),
203185
Collections.emptyList()
204186
);
205187
client = new NoOpNodeClient(this.getTestName());
@@ -236,16 +218,6 @@ public void testDiscover() throws Exception {
236218
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
237219
new HashMap<String, String>(),
238220
Version.fromString("3.0.0"),
239-
new PluginInfo(
240-
"firstExtension",
241-
"Fake description 1",
242-
"0.0.7",
243-
Version.fromString("3.0.0"),
244-
"14",
245-
"fakeClass1",
246-
new ArrayList<String>(),
247-
false
248-
),
249221
Collections.emptyList()
250222
)
251223
);
@@ -260,16 +232,6 @@ public void testDiscover() throws Exception {
260232
new TransportAddress(TransportAddress.META_ADDRESS, 9301),
261233
new HashMap<String, String>(),
262234
Version.fromString("2.0.0"),
263-
new PluginInfo(
264-
"secondExtension",
265-
"Fake description 2",
266-
"3.14.16",
267-
Version.fromString("2.0.0"),
268-
"17",
269-
"fakeClass2",
270-
new ArrayList<String>(),
271-
true
272-
),
273235
List.of(expectedDependency)
274236
)
275237
);
@@ -300,16 +262,6 @@ public void testNonUniqueExtensionsDiscovery() throws Exception {
300262
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
301263
new HashMap<String, String>(),
302264
Version.fromString("3.0.0"),
303-
new PluginInfo(
304-
"firstExtension",
305-
"Fake description 1",
306-
"0.0.7",
307-
Version.fromString("3.0.0"),
308-
"14",
309-
"fakeClass1",
310-
new ArrayList<String>(),
311-
false
312-
),
313265
Collections.emptyList()
314266
)
315267
);
@@ -333,16 +285,6 @@ public void testDiscoveryExtension() throws Exception {
333285
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
334286
new HashMap<String, String>(),
335287
Version.fromString("3.0.0"),
336-
new PluginInfo(
337-
"firstExtension",
338-
"Fake description 1",
339-
"0.0.7",
340-
Version.fromString("3.0.0"),
341-
"14",
342-
"fakeClass1",
343-
new ArrayList<String>(),
344-
false
345-
),
346288
List.of(expectedDependency)
347289
);
348290

@@ -397,7 +339,7 @@ public void testNoExtensionsFile() throws Exception {
397339
new MockLogAppender.SeenEventExpectation(
398340
"No Extensions File Present",
399341
"org.opensearch.extensions.ExtensionsManager",
400-
Level.INFO,
342+
Level.ERROR,
401343
"Extensions.yml file is not present. No extensions will be loaded."
402344
)
403345
);
@@ -587,16 +529,6 @@ public void testExtensionDependencyResponse() throws Exception {
587529
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
588530
new HashMap<String, String>(),
589531
Version.fromString("3.0.0"),
590-
new PluginInfo(
591-
"firstExtension",
592-
"Fake description 1",
593-
"0.0.7",
594-
Version.fromString("3.0.0"),
595-
"14",
596-
"fakeClass1",
597-
new ArrayList<String>(),
598-
false
599-
),
600532
List.of(expectedDependency)
601533
)
602534
);

server/src/test/java/org/opensearch/extensions/action/ExtensionTransportActionsHandlerTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,6 @@ public void setup() throws Exception {
9191
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
9292
new HashMap<String, String>(),
9393
Version.fromString("3.0.0"),
94-
new PluginInfo(
95-
"firstExtension",
96-
"Fake description 1",
97-
"0.0.7",
98-
Version.fromString("3.0.0"),
99-
"14",
100-
"fakeClass1",
101-
new ArrayList<String>(),
102-
false
103-
),
10494
Collections.emptyList()
10595
);
10696
client = new NoOpNodeClient(this.getTestName());

server/src/test/java/org/opensearch/extensions/rest/RestSendToExtensionActionTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ public void setup() throws Exception {
8484
new TransportAddress(InetAddress.getByName("127.0.0.0"), 9300),
8585
new HashMap<String, String>(),
8686
Version.fromString("3.0.0"),
87-
new PluginInfo(
88-
"firstExtension",
89-
"Fake description 1",
90-
"0.0.7",
91-
Version.fromString("3.0.0"),
92-
"14",
93-
"fakeClass1",
94-
new ArrayList<String>(),
95-
false
96-
),
9787
Collections.emptyList()
9888
);
9989
}

0 commit comments

Comments
 (0)