Skip to content

Commit

Permalink
Javadocs for Netty4GrpcServerTransport.
Browse files Browse the repository at this point in the history
Signed-off-by: Finn Carroll <[email protected]>
  • Loading branch information
finnegancarroll committed Dec 18, 2024
1 parent 979f98e commit 8c83da1
Showing 1 changed file with 45 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,72 @@
import static org.opensearch.common.util.concurrent.OpenSearchExecutors.daemonThreadFactory;
import static org.opensearch.transport.TcpTransport.resolveTransportPublishPort;

/**
* Netty4 gRPC server implemented as a LifecycleComponent.
* Services injected through BindableService list.
*/
public class Netty4GrpcServerTransport extends NetworkPlugin.AuxTransport {
private static final Logger logger = LogManager.getLogger(Netty4GrpcServerTransport.class);

/**
* Type key for configuring settings of this auxiliary transport.
*/
public static final String GRPC_TRANSPORT_SETTING_KEY = "experimental-transport-grpc";

/**
* Port range on which to bind.
* Note this setting is configured through AffixSetting AUX_TRANSPORT_PORTS where the aux transport type matches the GRPC_TRANSPORT_SETTING_KEY.
*/
public static final Setting<PortsRange> SETTING_GRPC_PORTS = AUX_TRANSPORT_PORTS.getConcreteSettingForNamespace(
GRPC_TRANSPORT_SETTING_KEY
);

public static final Setting<Integer> SETTING_GRPC_WORKER_COUNT = new Setting<>(
"grpc.netty.worker_count",
(s) -> Integer.toString(OpenSearchExecutors.allocatedProcessors(s)),
(s) -> Setting.parseInt(s, 1, "grpc.netty.worker_count"),
Setting.Property.NodeScope
);

/**
* Port published to peers for this server.
*/
public static final Setting<Integer> SETTING_GRPC_PUBLISH_PORT = intSetting("grpc.publish_port", -1, -1, Setting.Property.NodeScope);

/**
* Host list to bind and publish.
* For distinct bind/publish hosts configure SETTING_GRPC_BIND_HOST + SETTING_GRPC_PUBLISH_HOST separately.
*/
public static final Setting<List<String>> SETTING_GRPC_HOST = listSetting(
"grpc.host",
emptyList(),
Function.identity(),
Setting.Property.NodeScope
);

public static final Setting<List<String>> SETTING_GRPC_PUBLISH_HOST = listSetting(
"grpc.publish_host",
/**
* Host list to bind
*/
public static final Setting<List<String>> SETTING_GRPC_BIND_HOST = listSetting(
"grpc.bind_host",
SETTING_GRPC_HOST,
Function.identity(),
Setting.Property.NodeScope
);

public static final Setting<List<String>> SETTING_GRPC_BIND_HOST = listSetting(
"grpc.bind_host",
/**
* Host list published to peers
*/
public static final Setting<List<String>> SETTING_GRPC_PUBLISH_HOST = listSetting(
"grpc.publish_host",
SETTING_GRPC_HOST,
Function.identity(),
Setting.Property.NodeScope
);

/**
* Configure size of thread pool backing this transport server
*/
public static final Setting<Integer> SETTING_GRPC_WORKER_COUNT = new Setting<>(
"grpc.netty.worker_count",
(s) -> Integer.toString(OpenSearchExecutors.allocatedProcessors(s)),
(s) -> Setting.parseInt(s, 1, "grpc.netty.worker_count"),
Setting.Property.NodeScope
);

private final Settings settings;
private final NetworkService networkService;
private final List<BindableService> services;
Expand All @@ -98,6 +127,11 @@ public class Netty4GrpcServerTransport extends NetworkPlugin.AuxTransport {
private volatile BoundTransportAddress boundAddress;
private volatile EventLoopGroup eventLoopGroup;

/**
* @param settings to fetch configured settings
* @param services gRPC compatible services to be registered with the server
* @param networkService to bind/publish address
*/
public Netty4GrpcServerTransport(Settings settings, List<BindableService> services, NetworkService networkService) {
this.settings = Objects.requireNonNull(settings);
this.services = Objects.requireNonNull(services);
Expand Down

0 comments on commit 8c83da1

Please sign in to comment.