Skip to content

Commit

Permalink
Rename to Extensions (#72)
Browse files Browse the repository at this point in the history
* issue #28

Signed-off-by: mloufra <[email protected]>

* issue #28

Signed-off-by: mloufra <[email protected]>

* Rename to javadoc, log message and method to extensions

Signed-off-by: mloufra <[email protected]>

* Rename the remaining to extensions

Signed-off-by: mloufra <[email protected]>

* fix bug on ExtensionsRunner.java

Signed-off-by: mloufra <[email protected]>

Signed-off-by: mloufra <[email protected]>
  • Loading branch information
mloufra authored Aug 11, 2022
1 parent 767c807 commit fd0f070
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
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

0 comments on commit fd0f070

Please sign in to comment.