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

Rename to Extensions #72

Merged
merged 5 commits into from
Aug 11, 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
28 changes: 14 additions & 14 deletions src/main/java/org/opensearch/sdk/ExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.opensearch.common.network.NetworkService;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.PageCacheRecycler;
import org.opensearch.discovery.PluginRequest;
import org.opensearch.discovery.PluginResponse;
import org.opensearch.discovery.InitializeExtensionsRequest;
import org.opensearch.discovery.InitializeExtensionsResponse;
import org.opensearch.extensions.ExtensionRequest;
import org.opensearch.extensions.ExtensionsOrchestrator;
import org.opensearch.extensions.ExtensionBooleanResponse;
Expand Down Expand Up @@ -99,17 +99,17 @@ public DiscoveryNode getOpensearchNode() {
}

/**
* Handles a plugin request from OpenSearch. This is the first request for the transport communication and will initialize the extension and will be a part of OpenSearch bootstrap.
* Handles a extension request from OpenSearch. This is the first request for the transport communication and will initialize the extension and will be a part of OpenSearch bootstrap.
*
* @param pluginRequest The request to handle.
* @param extensionInitRequest The request to handle.
* @return A response to OpenSearch validating that this is an extension.
*/
PluginResponse handlePluginsRequest(PluginRequest pluginRequest) {
logger.info("Registering Plugin Request received from OpenSearch");
PluginResponse pluginResponse = new PluginResponse(extensionSettings.getExtensionName());
opensearchNode = pluginRequest.getSourceNode();
InitializeExtensionsResponse handleExtensionInitRequest(InitializeExtensionsRequest extensionInitRequest) {
logger.info("Registering Extension Request received from OpenSearch");
InitializeExtensionsResponse initializeExtensionsResponse = new InitializeExtensionsResponse(extensionSettings.getExtensionName());
opensearchNode = extensionInitRequest.getSourceNode();
setOpensearchNode(opensearchNode);
return pluginResponse;
return initializeExtensionsResponse;
}

/**
Expand All @@ -131,7 +131,7 @@ TransportResponse handleOpenSearchRequest(OpenSearchRequest request) throws Exce
}

/**
* Handles a request for extension point indices from OpenSearch. The {@link #handlePluginsRequest(PluginRequest)} method must have been called first to initialize the extension.
* Handles a request for extension point indices from OpenSearch. The {@link #handleExtensionInitRequest(InitializeExtensionsRequest)} method must have been called first to initialize the extension.
*
* @param indicesModuleRequest The request to handle.
* @param transportService The transport service communicating with OpenSearch.
Expand All @@ -141,14 +141,14 @@ IndicesModuleResponse handleIndicesModuleRequest(IndicesModuleRequest indicesMod
logger.info("Registering Indices Module Request received from OpenSearch");
IndicesModuleResponse indicesModuleResponse = new IndicesModuleResponse(true, true, true);

// handlePluginsRequest will set the opensearchNode while bootstraping of OpenSearch
// handleExtensionInitRequest will set the opensearchNode while bootstraping of OpenSearch
DiscoveryNode opensearchNode = getOpensearchNode();
transportService.connectToNode(opensearchNode);
return indicesModuleResponse;
}

/**
* Handles a request for extension name from OpenSearch. The {@link #handlePluginsRequest(PluginRequest)} method must have been called first to initialize the extension.
* Handles a request for extension name from OpenSearch. The {@link #handleExtensionInitRequest(InitializeExtensionsRequest)} method must have been called first to initialize the extension.
*
* @param indicesModuleRequest The request to handle.
* @return A response acknowledging the request.
Expand Down Expand Up @@ -247,8 +247,8 @@ public void startTransportService(TransportService transportService) {
ThreadPool.Names.GENERIC,
false,
false,
PluginRequest::new,
(request, channel, task) -> channel.sendResponse(handlePluginsRequest(request))
InitializeExtensionsRequest::new,
(request, channel, task) -> channel.sendResponse(handleExtensionInitRequest(request))
);

transportService.registerRequestHandler(
Expand Down
12 changes: 6 additions & 6 deletions src/test/java/org/opensearch/sdk/TestExtensionsRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.opensearch.common.io.stream.NamedWriteableRegistryResponse;
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.OpenSearchRequest;
import org.opensearch.extensions.ExtensionsOrchestrator.OpenSearchRequestType;
import org.opensearch.sdk.handlers.ClusterSettingsResponseHandler;
Expand Down Expand Up @@ -98,19 +98,19 @@ public void testRegisterRequestHandler() {
}

@Test
public void testHandlePluginsRequest() throws UnknownHostException {
public void testHandleExtensionInitRequest() throws UnknownHostException {
DiscoveryNode sourceNode = new DiscoveryNode(
"test_node",
new TransportAddress(InetAddress.getByName("localhost"), 9876),
emptyMap(),
emptySet(),
Version.CURRENT
);
PluginRequest pluginRequest = new PluginRequest(sourceNode, null);
PluginResponse response = extensionsRunner.handlePluginsRequest(pluginRequest);
InitializeExtensionsRequest extensionInitRequest = new InitializeExtensionsRequest(sourceNode, null);
InitializeExtensionsResponse response = extensionsRunner.handleExtensionInitRequest(extensionInitRequest);
assertEquals(response.getName(), "extension");

// Test if the source node is set after handlePluginRequest() is called during OpenSearch bootstrap
// Test if the source node is set after handleExtensionInitRequest()) is called during OpenSearch bootstrap
assertEquals(extensionsRunner.getOpensearchNode(), sourceNode);
}

Expand Down