Skip to content
Closed
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 @@ -37,6 +37,8 @@
import org.opensearch.transport.TransportResponse;

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

/**
Expand All @@ -46,43 +48,51 @@
*/
public class PluginResponse extends TransportResponse {
private String name;
private List<String> api;

public PluginResponse(String name) {
public PluginResponse(String name, List<String> api) {
this.name = name;
this.api = new ArrayList<>(api);
}

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

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(name);
out.writeStringCollection(api);
}

/**
* @return the node that is currently leading, according to the responding node.
*/

public String getName() {
return this.name;
}

public List<String> getApi() {
return new ArrayList<>(api);
}

@Override
public String toString() {
return "PluginResponse{" + "name" + name + "}";
return "PluginResponse {" + "name=" + name + ", api=" + api + "}";
}

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

@Override
public int hashCode() {
return Objects.hash(name);
return Objects.hash(api, name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,8 @@

package org.opensearch.extensions;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
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;
Expand Down Expand Up @@ -52,8 +43,17 @@
import org.opensearch.transport.TransportResponseHandler;
import org.opensearch.transport.TransportService;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
* The main class for Plugin Extensibility
Expand Down Expand Up @@ -220,6 +220,8 @@ public void handleResponse(PluginResponse response) {
for (DiscoveryExtension extension : extensionsList) {
if (extension.getName().equals(response.getName())) {
extensionsInitializedList.add(extension);
// Temporary for debug
logger.info("Received API from " + response.getName() + ": " + response.getApi());
break;
}
}
Expand Down