From 62d4522d115e70421859ca22b6ca98b45b5829a5 Mon Sep 17 00:00:00 2001 From: Finn Carroll Date: Mon, 9 Dec 2024 14:10:42 -0800 Subject: [PATCH] Remove main action service. Signed-off-by: Finn Carroll --- .../grpc/actions/MainActionTests.java | 18 ----- .../transport/grpc/GrpcModulePlugin.java | 6 +- .../grpc/actions/MainActionService.java | 67 ------------------- .../main/proto/opensearch/main_action.proto | 30 --------- 4 files changed, 1 insertion(+), 120 deletions(-) delete mode 100644 plugins/transport-grpc/src/internalClusterTest/java/org/opensearch/transport/grpc/actions/MainActionTests.java delete mode 100644 plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/actions/MainActionService.java delete mode 100644 plugins/transport-grpc/src/main/proto/opensearch/main_action.proto diff --git a/plugins/transport-grpc/src/internalClusterTest/java/org/opensearch/transport/grpc/actions/MainActionTests.java b/plugins/transport-grpc/src/internalClusterTest/java/org/opensearch/transport/grpc/actions/MainActionTests.java deleted file mode 100644 index 59a9d0ea32407..0000000000000 --- a/plugins/transport-grpc/src/internalClusterTest/java/org/opensearch/transport/grpc/actions/MainActionTests.java +++ /dev/null @@ -1,18 +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.transport.grpc.actions; - -import org.opensearch.transport.grpc.OpenSearchGrpcIntegTestCase; - -public class MainActionTests extends OpenSearchGrpcIntegTestCase { - - public void test() { - // TODO: implement test - } -} diff --git a/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcModulePlugin.java b/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcModulePlugin.java index 452c07f8e59bb..8b422149281d7 100644 --- a/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcModulePlugin.java +++ b/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/GrpcModulePlugin.java @@ -30,7 +30,6 @@ import org.opensearch.script.ScriptService; import org.opensearch.telemetry.tracing.Tracer; import org.opensearch.threadpool.ThreadPool; -import org.opensearch.transport.grpc.actions.MainActionService; import org.opensearch.watcher.ResourceWatcherService; import java.util.Collection; @@ -40,8 +39,6 @@ import java.util.function.Function; import java.util.function.Supplier; -import io.grpc.BindableService; - import static java.util.Collections.emptyList; import static org.opensearch.common.settings.Setting.intSetting; import static org.opensearch.common.settings.Setting.listSetting; @@ -99,8 +96,7 @@ public Collection createComponents( if (FeatureFlags.isEnabled(FeatureFlags.GRPC_ENABLE_SETTING) == false) { throw new IllegalArgumentException("transport-grpc is experimental and feature flag must be enabled before use"); } - final List services = List.of(new MainActionService(client)); - this.transport = new Netty4GrpcServerTransport(clusterService.getSettings(), services); + this.transport = new Netty4GrpcServerTransport(clusterService.getSettings(), Collections.emptyList()); // The server will manage the lifecycle of any instance of LifecycleComponent that is returned here return List.of(transport); diff --git a/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/actions/MainActionService.java b/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/actions/MainActionService.java deleted file mode 100644 index 38d6370d113a0..0000000000000 --- a/plugins/transport-grpc/src/main/java/org/opensearch/transport/grpc/actions/MainActionService.java +++ /dev/null @@ -1,67 +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.transport.grpc.actions; - -import org.opensearch.action.main.MainRequest; -import org.opensearch.action.main.MainResponse; -import org.opensearch.client.Client; -import org.opensearch.core.action.ActionListener; -import org.opensearch.proto.grpc.MainAction; -import org.opensearch.proto.grpc.MainActionServiceGrpc; - -import io.grpc.stub.StreamObserver; - -/** - * gRPC version of the MainAction, i.e. `GET /` - */ -public final class MainActionService extends MainActionServiceGrpc.MainActionServiceImplBase { - private final Client client; - - public MainActionService(Client client) { - this.client = client; - } - - @Override - public void get(MainAction.MainRequest request, StreamObserver responseObserver) { - client.execute(org.opensearch.action.main.MainAction.INSTANCE, new MainRequest(), new ActionListener<>() { - @Override - public void onResponse(MainResponse mainResponse) { - responseObserver.onNext( - MainAction.MainResponse.newBuilder() - .setName(mainResponse.getNodeName()) - .setClusterName(mainResponse.getClusterName().value()) - .setClusterUuid(mainResponse.getClusterUuid()) - .setVersion( - MainAction.MainResponse.Version.newBuilder() - .setDistribution(mainResponse.getBuild().getDistribution()) - .setNumber(mainResponse.getBuild().getQualifiedVersion()) - .setBuildType(mainResponse.getBuild().type().displayName()) - .setBuildHash(mainResponse.getBuild().hash()) - .setBuildDate(mainResponse.getBuild().date()) - .setBuildSnapshot(Boolean.toString(mainResponse.getBuild().isSnapshot())) - .setLuceneVersion(mainResponse.getVersion().luceneVersion.toString()) - .setMinimumWireCompatibilityVersion(mainResponse.getVersion().minimumCompatibilityVersion().toString()) - .setMinimumIndexCompatibilityVersion( - mainResponse.getVersion().minimumIndexCompatibilityVersion().toString() - ) - .build() - ) - .setTagline("The OpenSearch Project: https://opensearch.org/") - .build() - ); - responseObserver.onCompleted(); - } - - @Override - public void onFailure(Exception e) { - responseObserver.onError(e); - } - }); - } -} diff --git a/plugins/transport-grpc/src/main/proto/opensearch/main_action.proto b/plugins/transport-grpc/src/main/proto/opensearch/main_action.proto deleted file mode 100644 index af521002d8241..0000000000000 --- a/plugins/transport-grpc/src/main/proto/opensearch/main_action.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; -package org.opensearch.proto.grpc; - -message MainRequest { - -} - -message MainResponse { - string name = 1; - string cluster_name = 2; - string cluster_uuid = 3; - Version version = 4; - string tagline = 5; - - message Version { - string distribution = 1; - string number = 2; - string build_type = 3; - string build_hash = 4; - string build_date = 5; - string build_snapshot = 6; - string lucene_version = 7; - string minimum_wire_compatibility_version = 8; - string minimum_index_compatibility_version = 9; - } -} - -service MainActionService { - rpc Get(MainRequest) returns (MainResponse) {} -}