From fd0f0708c14bf39c139b4cdea36b01839786a5ca Mon Sep 17 00:00:00 2001 From: Frank Lou <107960841+mloufra@users.noreply.github.com> Date: Thu, 11 Aug 2022 09:53:07 -0700 Subject: [PATCH] Rename to Extensions (#72) * issue #28 Signed-off-by: mloufra * issue #28 Signed-off-by: mloufra * Rename to javadoc, log message and method to extensions Signed-off-by: mloufra * Rename the remaining to extensions Signed-off-by: mloufra * fix bug on ExtensionsRunner.java Signed-off-by: mloufra Signed-off-by: mloufra --- .../org/opensearch/sdk/ExtensionsRunner.java | 28 +++++++++---------- .../opensearch/sdk/TestExtensionsRunner.java | 12 ++++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/opensearch/sdk/ExtensionsRunner.java b/src/main/java/org/opensearch/sdk/ExtensionsRunner.java index 95395446..29418e73 100644 --- a/src/main/java/org/opensearch/sdk/ExtensionsRunner.java +++ b/src/main/java/org/opensearch/sdk/ExtensionsRunner.java @@ -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; @@ -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; } /** @@ -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. @@ -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. @@ -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( diff --git a/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java b/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java index fb3755e8..38cf8a53 100644 --- a/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java +++ b/src/test/java/org/opensearch/sdk/TestExtensionsRunner.java @@ -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; @@ -98,7 +98,7 @@ 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), @@ -106,11 +106,11 @@ public void testHandlePluginsRequest() throws UnknownHostException { 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); }