diff --git a/CHANGELOG.md b/CHANGELOG.md index 65de8dfb5b464..2b41db0feeaea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -227,6 +227,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Modified EnvironmentSettingsRequest to pass entire Settings object ([#4731](https://github.com/opensearch-project/OpenSearch/pull/4731)) - Added contentParser method to ExtensionRestRequest ([#4760](https://github.com/opensearch-project/OpenSearch/pull/4760)) - Enforce type safety for RegisterTransportActionsRequest([#4796](https://github.com/opensearch-project/OpenSearch/pull/4796)) + - Modified local node request to return Discovery Node ([#4862](https://github.com/opensearch-project/OpenSearch/pull/4862)) - Enforce type safety for NamedWriteableRegistryParseRequest ([#4923](https://github.com/opensearch-project/OpenSearch/pull/4923)) ## [2.x] diff --git a/server/src/main/java/org/opensearch/cluster/LocalNodeResponse.java b/server/src/main/java/org/opensearch/cluster/LocalNodeResponse.java deleted file mode 100644 index ef1ef4a49ad62..0000000000000 --- a/server/src/main/java/org/opensearch/cluster/LocalNodeResponse.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.cluster; - -import org.opensearch.cluster.node.DiscoveryNode; -import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.io.stream.StreamInput; -import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.transport.TransportResponse; - -import java.io.IOException; -import java.util.Objects; - -/** - * LocalNode Response for Extensibility - * - * @opensearch.internal - */ -public class LocalNodeResponse extends TransportResponse { - private final DiscoveryNode localNode; - - public LocalNodeResponse(ClusterService clusterService) { - this.localNode = clusterService.localNode(); - } - - public LocalNodeResponse(StreamInput in) throws IOException { - super(in); - this.localNode = new DiscoveryNode(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - this.localNode.writeTo(out); - } - - @Override - public String toString() { - return "LocalNodeResponse{" + "localNode=" + localNode + '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - LocalNodeResponse that = (LocalNodeResponse) o; - return Objects.equals(localNode, that.localNode); - } - - @Override - public int hashCode() { - return Objects.hash(localNode); - } - -} diff --git a/server/src/main/java/org/opensearch/extensions/ExtensionsOrchestrator.java b/server/src/main/java/org/opensearch/extensions/ExtensionsOrchestrator.java index ac129780792a9..838c5924d213c 100644 --- a/server/src/main/java/org/opensearch/extensions/ExtensionsOrchestrator.java +++ b/server/src/main/java/org/opensearch/extensions/ExtensionsOrchestrator.java @@ -29,7 +29,6 @@ import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.ClusterSettingsResponse; -import org.opensearch.cluster.LocalNodeResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.io.FileSystemUtils; @@ -77,7 +76,6 @@ public class ExtensionsOrchestrator implements ReportingService channel.sendResponse(handleExtensionRequest(request))) ); - transportService.registerRequestHandler( - REQUEST_EXTENSION_LOCAL_NODE, - ThreadPool.Names.GENERIC, - false, - false, - ExtensionRequest::new, - ((request, channel, task) -> channel.sendResponse(handleExtensionRequest(request))) - ); transportService.registerRequestHandler( REQUEST_EXTENSION_CLUSTER_SETTINGS, ThreadPool.Names.GENERIC, @@ -430,8 +419,6 @@ TransportResponse handleExtensionRequest(ExtensionRequest extensionRequest) thro switch (extensionRequest.getRequestType()) { case REQUEST_EXTENSION_CLUSTER_STATE: return new ClusterStateResponse(clusterService.getClusterName(), clusterService.state(), false); - case REQUEST_EXTENSION_LOCAL_NODE: - return new LocalNodeResponse(clusterService); case REQUEST_EXTENSION_CLUSTER_SETTINGS: return new ClusterSettingsResponse(clusterService); case REQUEST_EXTENSION_ENVIRONMENT_SETTINGS: diff --git a/server/src/test/java/org/opensearch/extensions/ExtensionsOrchestratorTests.java b/server/src/test/java/org/opensearch/extensions/ExtensionsOrchestratorTests.java index 7cc02a7f6b5ce..6b2335a2333f3 100644 --- a/server/src/test/java/org/opensearch/extensions/ExtensionsOrchestratorTests.java +++ b/server/src/test/java/org/opensearch/extensions/ExtensionsOrchestratorTests.java @@ -46,7 +46,6 @@ import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.ClusterSettingsResponse; -import org.opensearch.cluster.LocalNodeResponse; import org.opensearch.env.EnvironmentSettingsResponse; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; @@ -455,9 +454,6 @@ public void testHandleExtensionRequest() throws Exception { ); assertEquals(ClusterSettingsResponse.class, extensionsOrchestrator.handleExtensionRequest(clusterSettingRequest).getClass()); - ExtensionRequest localNodeRequest = new ExtensionRequest(ExtensionsOrchestrator.RequestType.REQUEST_EXTENSION_LOCAL_NODE); - assertEquals(LocalNodeResponse.class, extensionsOrchestrator.handleExtensionRequest(localNodeRequest).getClass()); - ExtensionRequest environmentSettingsRequest = new ExtensionRequest( ExtensionsOrchestrator.RequestType.REQUEST_EXTENSION_ENVIRONMENT_SETTINGS ); @@ -672,7 +668,7 @@ public void testRegisterHandler() throws Exception { settings, client ); - verify(mockTransportService, times(10)).registerRequestHandler(anyString(), anyString(), anyBoolean(), anyBoolean(), any(), any()); + verify(mockTransportService, times(9)).registerRequestHandler(anyString(), anyString(), anyBoolean(), anyBoolean(), any(), any()); } private static class Example implements NamedWriteable {