Skip to content

Commit

Permalink
Rename gRPCServiceRegistry to GrpcServiceRegistry
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Ross <[email protected]>
  • Loading branch information
andrross committed Nov 14, 2024
1 parent 00d4eb1 commit 6151622
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.opensearch.core.common.transport.TransportAddress;
import org.opensearch.grpc.AbstractGrpcServerTransport;
import org.opensearch.grpc.GrpcStats;
import org.opensearch.grpc.services.gRPCServiceRegistry;
import org.opensearch.grpc.services.GrpcServiceRegistry;
import org.opensearch.transport.NettyAllocator;
import org.opensearch.transport.SharedGroupFactory;

Expand Down Expand Up @@ -47,14 +47,14 @@ public class Netty4GrpcServerTransport extends AbstractGrpcServerTransport {
public static final Setting<Integer> SETTING_GRPC_WORKER_COUNT = Setting.intSetting("grpc.worker_count", 1, Setting.Property.NodeScope);

private final SharedGroupFactory sharedGroupFactory;
private final gRPCServiceRegistry grpcServiceRegistry;
private final GrpcServiceRegistry grpcServiceRegistry;
private final CopyOnWriteArrayList<Server> servers = new CopyOnWriteArrayList<>();
private volatile SharedGroupFactory.SharedGroup sharedGroup;
private final ServerStatsInterceptor sharedServerStatsInterceptor;
private final AtomicLong currentOpen = new AtomicLong(0);
private final AtomicLong totalOpened = new AtomicLong(0);

public Netty4GrpcServerTransport(Settings settings, NetworkService networkService, SharedGroupFactory sharedGroupFactory, gRPCServiceRegistry grpcServiceRegistry) {
public Netty4GrpcServerTransport(Settings settings, NetworkService networkService, SharedGroupFactory sharedGroupFactory, GrpcServiceRegistry grpcServiceRegistry) {
super(settings, networkService);
this.sharedGroupFactory = sharedGroupFactory;
this.sharedServerStatsInterceptor = new ServerStatsInterceptor(currentOpen, totalOpened);
Expand Down Expand Up @@ -92,7 +92,7 @@ protected TransportAddress bindAddress(InetAddress hostAddress, PortsRange portR
.addService(new HealthStatusManager().getHealthService())
.addService(ProtoReflectionService.newInstance());

for (BindableService bService : grpcServiceRegistry) {
for (BindableService bService : grpcServiceRegistry.getServices()) {
srvBuilder.addService(bService);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.grpc.GrpcServerTransport;
import org.opensearch.grpc.netty4.Netty4GrpcServerTransport;
import org.opensearch.grpc.services.gRPCServiceRegistry;
import org.opensearch.grpc.services.GrpcServiceRegistry;
import org.opensearch.http.HttpServerTransport;
import org.opensearch.http.netty4.Netty4HttpServerTransport;
import org.opensearch.http.netty4.ssl.SecureNetty4HttpServerTransport;
Expand Down Expand Up @@ -155,7 +155,7 @@ public Map<String, Supplier<HttpServerTransport>> getHttpTransports(
}

@Override
public Map<String, Supplier<GrpcServerTransport>> getGrpcTransports(Settings settings, NetworkService networkService, gRPCServiceRegistry grpcServiceRegistry) {
public Map<String, Supplier<GrpcServerTransport>> getGrpcTransports(Settings settings, NetworkService networkService, GrpcServiceRegistry grpcServiceRegistry) {
return Collections.singletonMap(
NETTY_GRPC_TRANSPORT_NAME,
() -> new Netty4GrpcServerTransport(settings, networkService, getSharedGroupFactory(settings), grpcServiceRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.grpc.GrpcServerTransport;
import org.opensearch.grpc.services.gRPCServiceRegistry;
import org.opensearch.grpc.services.GrpcServiceRegistry;
import org.opensearch.http.HttpServerTransport;
import org.opensearch.index.shard.PrimaryReplicaSyncer.ResyncTask;
import org.opensearch.plugins.NetworkPlugin;
Expand Down Expand Up @@ -175,7 +175,7 @@ public NetworkModule(
CircuitBreakerService circuitBreakerService,
NamedWriteableRegistry namedWriteableRegistry,
NamedXContentRegistry xContentRegistry,
gRPCServiceRegistry grpcServiceRegistry,
GrpcServiceRegistry grpcServiceRegistry,
NetworkService networkService,
HttpServerTransport.Dispatcher dispatcher,
ClusterSettings clusterSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@

import io.grpc.BindableService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/*
TODO: Service validation?
TODO: Handle compatibility/errors/dups here before we inject services into gRPC server
*/
public class gRPCServiceRegistry extends ArrayList<BindableService> {
public class GrpcServiceRegistry {

public gRPCServiceRegistry() { }
private final List<BindableService> services;

public gRPCServiceRegistry(ArrayList<BindableService> services) {
this.addAll(services);
public GrpcServiceRegistry(BindableService... services) {
this.services = List.of(services);
}

public List<BindableService> getServices() {
return services;
}
}
10 changes: 4 additions & 6 deletions server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
import org.opensearch.gateway.remote.RemoteClusterStateCleanupManager;
import org.opensearch.gateway.remote.RemoteClusterStateService;
import org.opensearch.grpc.GrpcServerTransport;
import org.opensearch.grpc.services.gRPCServiceRegistry;
import org.opensearch.grpc.services.GrpcServiceRegistry;
import org.opensearch.grpc.services.nodesInfo.NodesInfoServiceImpl;
import org.opensearch.http.HttpServerTransport;
import org.opensearch.identity.IdentityService;
Expand Down Expand Up @@ -1136,11 +1136,9 @@ protected Node(
workloadManagementTransportInterceptor
);

gRPCServiceRegistry grpcReg = new gRPCServiceRegistry(
new ArrayList<>(Arrays.asList(
new NodesInfoServiceImpl()
// TODO: Other service stubs here
))
GrpcServiceRegistry grpcReg = new GrpcServiceRegistry(
new NodesInfoServiceImpl()
// TODO: Other service stubs here
);

final NetworkModule networkModule = new NetworkModule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.opensearch.core.indices.breaker.CircuitBreakerService;
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.grpc.GrpcServerTransport;
import org.opensearch.grpc.services.gRPCServiceRegistry;
import org.opensearch.grpc.services.GrpcServiceRegistry;
import org.opensearch.http.HttpServerTransport;
import org.opensearch.telemetry.tracing.Tracer;
import org.opensearch.threadpool.ThreadPool;
Expand Down Expand Up @@ -116,7 +116,7 @@ default Map<String, Supplier<HttpServerTransport>> getHttpTransports(
default Map<String, Supplier<GrpcServerTransport>> getGrpcTransports(
Settings settings,
NetworkService networkService,
gRPCServiceRegistry grpcServiceRegistry
GrpcServiceRegistry grpcServiceRegistry
) {
return Collections.emptyMap();
}
Expand Down

0 comments on commit 6151622

Please sign in to comment.