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

issue #28 Rename to extensions #4063

Merged
merged 5 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
import java.util.Objects;

/**
* PluginRequest to intialize plugin
* InitializeExtensionsRequest to initialize extension
*
* @opensearch.internal
*/
public class PluginRequest extends TransportRequest {
public class InitializeExtensionsRequest extends TransportRequest {
private final DiscoveryNode sourceNode;
/*
* TODO change DiscoveryNode to Extension information
*/
private final List<DiscoveryExtension> extensions;

public PluginRequest(DiscoveryNode sourceNode, List<DiscoveryExtension> extensions) {
public InitializeExtensionsRequest(DiscoveryNode sourceNode, List<DiscoveryExtension> extensions) {
this.sourceNode = sourceNode;
this.extensions = extensions;
}

public PluginRequest(StreamInput in) throws IOException {
public InitializeExtensionsRequest(StreamInput in) throws IOException {
super(in);
sourceNode = new DiscoveryNode(in);
extensions = in.readList(DiscoveryExtension::new);
Expand All @@ -58,14 +58,14 @@ public DiscoveryNode getSourceNode() {

@Override
public String toString() {
return "PluginRequest{" + "sourceNode=" + sourceNode + ", extensions=" + extensions + '}';
return "InitializeExtensionsRequest{" + "sourceNode=" + sourceNode + ", extensions=" + extensions + '}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PluginRequest that = (PluginRequest) o;
InitializeExtensionsRequest that = (InitializeExtensionsRequest) o;
return Objects.equals(sourceNode, that.sourceNode) && Objects.equals(extensions, that.extensions);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@
import java.util.Objects;

/**
* PluginResponse to intialize plugin
* InitializeExtensionsResponse to initialize extension
*
* @opensearch.internal
*/
public class PluginResponse extends TransportResponse {
public class InitializeExtensionsResponse extends TransportResponse {
private String name;

public PluginResponse(String name) {
public InitializeExtensionsResponse(String name) {
this.name = name;
}

public PluginResponse(StreamInput in) throws IOException {
public InitializeExtensionsResponse(StreamInput in) throws IOException {
name = in.readString();
}

Expand All @@ -70,14 +70,14 @@ public String getName() {

@Override
public String toString() {
return "PluginResponse{" + "name" + name + "}";
return "InitializeExtensionsResponse{" + "name" + name + "}";
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PluginResponse that = (PluginResponse) o;
InitializeExtensionsResponse that = (InitializeExtensionsResponse) o;
return Objects.equals(name, that.name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.discovery.PluginRequest;
import org.opensearch.discovery.PluginResponse;
import org.opensearch.discovery.InitializeExtensionsRequest;
import org.opensearch.discovery.InitializeExtensionsResponse;
import org.opensearch.extensions.ExtensionsSettings.Extension;
import org.opensearch.index.IndexModule;
import org.opensearch.index.IndexService;
Expand Down Expand Up @@ -229,15 +229,16 @@ public void extensionsInitialize() {

private void extensionInitialize(DiscoveryNode extensionNode) {
final CountDownLatch inProgressLatch = new CountDownLatch(1);
final TransportResponseHandler<PluginResponse> pluginResponseHandler = new TransportResponseHandler<PluginResponse>() {
final TransportResponseHandler<InitializeExtensionsResponse> extensionResponseHandler = new TransportResponseHandler<
InitializeExtensionsResponse>() {

@Override
public PluginResponse read(StreamInput in) throws IOException {
return new PluginResponse(in);
public InitializeExtensionsResponse read(StreamInput in) throws IOException {
return new InitializeExtensionsResponse(in);
}

@Override
public void handleResponse(PluginResponse response) {
public void handleResponse(InitializeExtensionsResponse response) {
for (DiscoveryExtension extension : extensionsList) {
if (extension.getName().equals(response.getName())) {
extensionsInitializedList.add(extension);
Expand All @@ -249,7 +250,7 @@ public void handleResponse(PluginResponse response) {

@Override
public void handleException(TransportException exp) {
logger.debug(new ParameterizedMessage("Plugin request failed"), exp);
logger.debug(new ParameterizedMessage("Extension request failed"), exp);
inProgressLatch.countDown();
}

Expand All @@ -264,8 +265,8 @@ public String executor() {
transportService.sendRequest(
extensionNode,
REQUEST_EXTENSION_ACTION_NAME,
new PluginRequest(transportService.getLocalNode(), new ArrayList<DiscoveryExtension>(extensionsList)),
pluginResponseHandler
new InitializeExtensionsRequest(transportService.getLocalNode(), new ArrayList<DiscoveryExtension>(extensionsList)),
extensionResponseHandler
);
inProgressLatch.await(100, TimeUnit.SECONDS);
} catch (Exception e) {
Expand Down