Skip to content

Commit

Permalink
Add GrpcInfo to node info api
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Nov 7, 2024
1 parent 3bcd5bb commit b2a1078
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opensearch.core.common.unit.ByteSizeValue;
import org.opensearch.core.service.ReportingService;
import org.opensearch.http.HttpInfo;
import org.opensearch.grpc.GrpcInfo;
import org.opensearch.ingest.IngestInfo;
import org.opensearch.monitor.jvm.JvmInfo;
import org.opensearch.monitor.os.OsInfo;
Expand Down Expand Up @@ -97,6 +98,7 @@ public NodeInfo(StreamInput in) throws IOException {
addInfoIfNonNull(ThreadPoolInfo.class, in.readOptionalWriteable(ThreadPoolInfo::new));
addInfoIfNonNull(TransportInfo.class, in.readOptionalWriteable(TransportInfo::new));
addInfoIfNonNull(HttpInfo.class, in.readOptionalWriteable(HttpInfo::new));
addInfoIfNonNull(GrpcInfo.class, in.readOptionalWriteable(GrpcInfo::new));
addInfoIfNonNull(PluginsAndModules.class, in.readOptionalWriteable(PluginsAndModules::new));
addInfoIfNonNull(IngestInfo.class, in.readOptionalWriteable(IngestInfo::new));
addInfoIfNonNull(AggregationInfo.class, in.readOptionalWriteable(AggregationInfo::new));
Expand All @@ -116,6 +118,7 @@ public NodeInfo(
@Nullable ThreadPoolInfo threadPool,
@Nullable TransportInfo transport,
@Nullable HttpInfo http,
@Nullable GrpcInfo grpc,
@Nullable PluginsAndModules plugins,
@Nullable IngestInfo ingest,
@Nullable AggregationInfo aggsInfo,
Expand All @@ -132,6 +135,7 @@ public NodeInfo(
addInfoIfNonNull(ThreadPoolInfo.class, threadPool);
addInfoIfNonNull(TransportInfo.class, transport);
addInfoIfNonNull(HttpInfo.class, http);
addInfoIfNonNull(GrpcInfo.class, grpc);
addInfoIfNonNull(PluginsAndModules.class, plugins);
addInfoIfNonNull(IngestInfo.class, ingest);
addInfoIfNonNull(AggregationInfo.class, aggsInfo);
Expand Down Expand Up @@ -221,6 +225,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(getInfo(ThreadPoolInfo.class));
out.writeOptionalWriteable(getInfo(TransportInfo.class));
out.writeOptionalWriteable(getInfo(HttpInfo.class));
out.writeOptionalWriteable(getInfo(GrpcInfo.class));
out.writeOptionalWriteable(getInfo(PluginsAndModules.class));
out.writeOptionalWriteable(getInfo(IngestInfo.class));
out.writeOptionalWriteable(getInfo(AggregationInfo.class));
Expand Down Expand Up @@ -254,6 +259,7 @@ private Builder(Version version, Build build, DiscoveryNode node) {
private ThreadPoolInfo threadPool;
private TransportInfo transport;
private HttpInfo http;
private GrpcInfo grpc;
private PluginsAndModules plugins;
private IngestInfo ingest;
private AggregationInfo aggsInfo;
Expand Down Expand Up @@ -295,6 +301,11 @@ public Builder setHttp(HttpInfo http) {
return this;
}

public Builder setGrpc(GrpcInfo grpc) {
this.grpc = grpc;
return this;
}

public Builder setPlugins(PluginsAndModules plugins) {
this.plugins = plugins;
return this;
Expand Down Expand Up @@ -332,6 +343,7 @@ public NodeInfo build() {
threadPool,
transport,
http,
grpc,
plugins,
ingest,
aggsInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public enum Metric {
THREAD_POOL("thread_pool"),
TRANSPORT("transport"),
HTTP("http"),
GRPC("grpc"),
PLUGINS("plugins"),
INGEST("ingest"),
AGGREGATIONS("aggregations"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.core.xcontent.ToXContentFragment;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.grpc.GrpcInfo;
import org.opensearch.http.HttpInfo;
import org.opensearch.ingest.IngestInfo;
import org.opensearch.monitor.jvm.JvmInfo;
Expand Down Expand Up @@ -140,6 +141,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (nodeInfo.getInfo(HttpInfo.class) != null) {
nodeInfo.getInfo(HttpInfo.class).toXContent(builder, params);
}
if (nodeInfo.getInfo(GrpcInfo.class) != null) {
nodeInfo.getInfo(GrpcInfo.class).toXContent(builder, params);
}
if (nodeInfo.getInfo(PluginsAndModules.class) != null) {
nodeInfo.getInfo(PluginsAndModules.class).toXContent(builder, params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ protected NodeInfo nodeOperation(NodeInfoRequest nodeRequest) {
metrics.contains(NodesInfoRequest.Metric.THREAD_POOL.metricName()),
metrics.contains(NodesInfoRequest.Metric.TRANSPORT.metricName()),
metrics.contains(NodesInfoRequest.Metric.HTTP.metricName()),
metrics.contains(NodesInfoRequest.Metric.GRPC.metricName()),
metrics.contains(NodesInfoRequest.Metric.PLUGINS.metricName()),
metrics.contains(NodesInfoRequest.Metric.INGEST.metricName()),
metrics.contains(NodesInfoRequest.Metric.AGGREGATIONS.metricName()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected ClusterStatsNodeResponse newNodeResponse(StreamInput in) throws IOExce

@Override
protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeRequest) {
NodeInfo nodeInfo = nodeService.info(true, true, false, true, false, true, false, true, false, false, false, false);
NodeInfo nodeInfo = nodeService.info(true, true, false, true, false, true, false, false, true, false, false, false, false);
NodeStats nodeStats = nodeService.stats(
CommonStatsFlags.NONE,
isMetricRequired(Metric.OS, nodeRequest.request),
Expand Down
4 changes: 4 additions & 0 deletions server/src/main/java/org/opensearch/node/NodeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public NodeInfo info(
boolean threadPool,
boolean transport,
boolean http,
boolean grpc,
boolean plugin,
boolean ingest,
boolean aggs,
Expand Down Expand Up @@ -201,6 +202,9 @@ public NodeInfo info(
if (http && httpServerTransport != null) {
builder.setHttp(httpServerTransport.info());
}
if (grpc && grpcServerTransport != null) {
builder.setGrpc(grpcServerTransport.info());
}
if (plugin && pluginService != null) {
builder.setPlugins(pluginService.info());
}
Expand Down

0 comments on commit b2a1078

Please sign in to comment.