Skip to content

Commit

Permalink
Add nodesInfo service dummy/unimpl response for testing.
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <carrofin@amazon.com>
  • Loading branch information
finnegancarroll committed Nov 14, 2024
1 parent 3b034cb commit 00d4eb1
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.grpc.services.nodesInfo;

import io.grpc.Status;
import io.grpc.stub.StreamObserver;
import org.opensearch.action.admin.cluster.node.info.proto.NodesInfoProtoService;
import org.opensearch.action.admin.cluster.node.info.proto.NodesInfoServiceGrpc;
Expand All @@ -16,11 +17,24 @@ public class NodesInfoServiceImpl extends NodesInfoServiceGrpc.NodesInfoServiceI

@Override
public void getNodesInfo(NodesInfoProtoService.NodesInfoRequest request, StreamObserver<NodesInfoProtoService.NodesInfoResponse> responseObserver) {
System.out.println("getNodesInfo");
try {
System.out.println("getNodesInfo");

NodesInfoProtoService.NodesInfoResponse response = NodesInfoProtoService.NodesInfoResponse.newBuilder()
.setClusterName("test-cluster")
.build();

responseObserver.onNext(response);
responseObserver.onCompleted();
} catch (Exception e) {
responseObserver.onError(e);
}
}

@Override
public void streamNodesInfo(NodesInfoProtoService.NodesInfoRequest request, StreamObserver<NodesInfoProtoService.NodesInfoResponse> responseObserver) {
// Func stub
responseObserver.onError(
Status.UNIMPLEMENTED.withDescription("Method StreamNodesInfo is not implemented").asRuntimeException()
);
}
}

0 comments on commit 00d4eb1

Please sign in to comment.