Skip to content
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

Added TransportActions support and removed LocalNodeResponse for extensions #5615

Merged
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:/opensearch-project/OpenSearch/pull/5211))
- Added jackson dependency to server ([#5366] (https:/opensearch-project/OpenSearch/pull/5366))
- Adding support to register settings dynamically ([#5495](https:/opensearch-project/OpenSearch/pull/5495))
- Added experimental support for extensions ([#5347](https:/opensearch-project/OpenSearch/pull/5347)), ([#5518](https:/opensearch-project/OpenSearch/pull/5518), ([#5597](https:/opensearch-project/OpenSearch/pull/5597)))
- Added experimental support for extensions ([#5347](https:/opensearch-project/OpenSearch/pull/5347)), ([#5518](https:/opensearch-project/OpenSearch/pull/5518), ([#5597](https:/opensearch-project/OpenSearch/pull/5597)), ([#5615](https:/opensearch-project/OpenSearch/pull/5615)))
- Add CI bundle pattern to distribution download ([#5348](https:/opensearch-project/OpenSearch/pull/5348))
- Add support for ppc64le architecture ([#5459](https:/opensearch-project/OpenSearch/pull/5459))

Expand Down
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

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