Skip to content

Commit

Permalink
Added TransportActions support and removed LocalNodeResponse for exte…
Browse files Browse the repository at this point in the history
…nsions (#5615)

* Added getSettings() support, ActionListener onFailure(), and initial createComponents support for extensions

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

* Update CHANGELOG

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

* Rework EnvironmentSettings API

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

* Addressed PR Comments

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

* Removed ExtensionActionListener and changed exception types

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

* Added TransportActions support and removed LocalNodeResponse for extensions

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

* Update CHANGELOG

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

* Update failure handling in UpdateSettingsResponseHandler

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

* Added REST updates

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

* Fix merge conflict

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

Signed-off-by: Ryan Bogan <rbogan@amazon.com>
  • Loading branch information
ryanbogan committed Dec 23, 2022
1 parent 4fe8097 commit 35605c6
Show file tree
Hide file tree
Showing 37 changed files with 2,297 additions and 377 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add feature flag for extensions ([#5211](https://github.com/opensearch-project/OpenSearch/pull/5211))
- Added jackson dependency to server ([#5366] (https://github.com/opensearch-project/OpenSearch/pull/5366))
- Adding support to register settings dynamically ([#5495](https://github.com/opensearch-project/OpenSearch/pull/5495))
- Added experimental support for extensions ([#5347](https://github.com/opensearch-project/OpenSearch/pull/5347)), ([#5518](https://github.com/opensearch-project/OpenSearch/pull/5518), ([#5597](https://github.com/opensearch-project/OpenSearch/pull/5597)))
- Added experimental support for extensions ([#5347](https://github.com/opensearch-project/OpenSearch/pull/5347)), ([#5518](https://github.com/opensearch-project/OpenSearch/pull/5518), ([#5597](https://github.com/opensearch-project/OpenSearch/pull/5597)), ([#5615](https://github.com/opensearch-project/OpenSearch/pull/5615)))
- Add CI bundle pattern to distribution download ([#5348](https://github.com/opensearch-project/OpenSearch/pull/5348))
- Add support for ppc64le architecture ([#5459](https://github.com/opensearch-project/OpenSearch/pull/5459))

Expand Down
7 changes: 7 additions & 0 deletions server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@
import org.opensearch.common.inject.TypeLiteral;
import org.opensearch.common.inject.multibindings.MapBinder;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.extensions.action.ExtensionProxyAction;
import org.opensearch.extensions.action.ExtensionTransportAction;
import org.opensearch.common.settings.IndexScopedSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.settings.SettingsFilter;
Expand Down Expand Up @@ -703,6 +705,11 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
// Remote Store
actions.register(RestoreRemoteStoreAction.INSTANCE, TransportRestoreRemoteStoreAction.class);

if (FeatureFlags.isEnabled(FeatureFlags.EXTENSIONS)) {
// ExtensionProxyAction
actions.register(ExtensionProxyAction.INSTANCE, ExtensionTransportAction.class);
}

// Decommission actions
actions.register(DecommissionAction.INSTANCE, TransportDecommissionAction.class);
actions.register(GetDecommissionStateAction.INSTANCE, TransportGetDecommissionStateAction.class);
Expand Down
60 changes: 0 additions & 60 deletions server/src/main/java/org/opensearch/cluster/LocalNodeResponse.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import org.opensearch.plugins.PluginInfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
Expand All @@ -30,6 +33,7 @@
public class DiscoveryExtensionNode extends DiscoveryNode implements Writeable, ToXContentFragment {

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

public DiscoveryExtensionNode(
String name,
Expand All @@ -40,16 +44,22 @@ public DiscoveryExtensionNode(
TransportAddress address,
Map<String, String> attributes,
Version version,
PluginInfo pluginInfo
PluginInfo pluginInfo,
List<ExtensionDependency> dependencies
) {
super(name, id, ephemeralId, hostName, hostAddress, address, attributes, DiscoveryNodeRole.BUILT_IN_ROLES, version);
this.pluginInfo = pluginInfo;
this.dependencies = dependencies;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
pluginInfo.writeTo(out);
out.writeVInt(dependencies.size());
for (ExtensionDependency dependency : dependencies) {
dependency.writeTo(out);
}
}

/**
Expand All @@ -61,6 +71,15 @@ public void writeTo(StreamOutput out) throws IOException {
public DiscoveryExtensionNode(final StreamInput in) throws IOException {
super(in);
this.pluginInfo = new PluginInfo(in);
int size = in.readVInt();
dependencies = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
dependencies.add(new ExtensionDependency(in));
}
}

public List<ExtensionDependency> getDependencies() {
return dependencies;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.extensions;

import java.io.IOException;
import java.util.Objects;

import org.opensearch.Version;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.io.stream.Writeable;

/**
* This class handles the dependent extensions information
*
* @opensearch.internal
*/
public class ExtensionDependency implements Writeable {
private String uniqueId;
private Version version;

public ExtensionDependency(String uniqueId, Version version) {
this.uniqueId = uniqueId;
this.version = version;
}

/**
* Jackson requires a no-arg constructor.
*
*/
@SuppressWarnings("unused")
private ExtensionDependency() {}

/**
* Reads the extension dependency information
*
* @throws IOException if an I/O exception occurred reading the extension dependency information
*/
public ExtensionDependency(StreamInput in) throws IOException {
uniqueId = in.readString();
version = Version.readVersion(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(uniqueId);
Version.writeVersion(version, out);
}

/**
* The uniqueId of the dependency extension
*
* @return the extension uniqueId
*/
public String getUniqueId() {
return uniqueId;
}

/**
* The minimum version of the dependency extension
*
* @return the extension version
*/
public Version getVersion() {
return version;
}

public String toString() {
return "ExtensionDependency:{uniqueId=" + uniqueId + ", version=" + version + "}";
}

public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
ExtensionDependency that = (ExtensionDependency) obj;
return Objects.equals(uniqueId, that.uniqueId) && Objects.equals(version, that.version);
}

public int hashCode() {
return Objects.hash(uniqueId, version);
}
}
Loading

0 comments on commit 35605c6

Please sign in to comment.