Class OpennmsGrpcServer
- java.lang.Object
-
- org.opennms.core.ipc.sink.common.AbstractMessageConsumerManager
-
- org.opennms.core.ipc.grpc.server.OpennmsGrpcServer
-
- All Implemented Interfaces:
MessageConsumerManager
,RpcClientFactory
public class OpennmsGrpcServer extends AbstractMessageConsumerManager implements RpcClientFactory
OpenNMS GRPC Server runs as OSGI bundle and it runs both RPC/Sink together. gRPC runs in a typical web server/client mode, so gRPC client runs on each minion and gRPC server runs on OpenNMS. Server initializes and creates two observers (RPC/Sink) that receive messages from the client (Minion).RPC : RPC runs in bi-directional streaming mode. OpenNMS needs a client(minion) handle for sending RPC request so minion always sends it's headers (SystemId/location) when it initializes. This Server maintains a list of client(minion) handles and sends RPC request to each minion in round-robin fashion. When it is directed RPC, server invokes specific minion handle directly. For each RPC request received, server creates a rpcId and maintains the state of this request in the concurrent map. The request is also added to a delay queue which can timeout the request if response is not received within expiration time. RPC responses are received in the observers that are created at start. Each response handling is done in a separate thread which may be used by rpc module to process the response.
Sink: Sink runs in uni-directional streaming mode. OpenNMS receives sink messages from client and they are dispatched in the consumer threads that are initialized at start.
-
-
Field Summary
-
Fields inherited from class org.opennms.core.ipc.sink.common.AbstractMessageConsumerManager
SINK_INITIAL_SLEEP_TIME, startupExecutor, waitForStartup
-
Fields inherited from interface org.opennms.core.ipc.sink.api.MessageConsumerManager
LOG_PREFIX, METRIC_DISPATCH_TIME, METRIC_MESSAGE_SIZE, METRIC_MESSAGES_RECEIVED
-
Fields inherited from interface org.opennms.core.rpc.api.RpcClientFactory
JMX_DOMAIN_RPC, LOG_PREFIX, RPC_DURATION, RPC_FAILED, RPC_REQUEST_SENT, RPC_REQUEST_SIZE, RPC_REQUESTS_RECEIVED, RPC_RESPONSE_SIZE
-
-
Constructor Summary
Constructors Constructor Description OpennmsGrpcServer(GrpcIpcServer grpcIpcServer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <S extends RpcRequest,T extends RpcResponse>
RpcClient<S,T>getClient(RpcModule<S,T> module)
Identity
getIdentity()
java.lang.String
getLocation()
io.grpc.stub.StreamObserver<RpcRequestProto>
getRpcHandler(java.lang.String location, java.lang.String systemId)
com.google.common.collect.Multimap<java.lang.String,io.grpc.stub.StreamObserver<RpcRequestProto>>
getRpcHandlerByLocation()
com.codahale.metrics.MetricRegistry
getSinkMetrics()
io.opentracing.Tracer
getTracer()
TracerRegistry
getTracerRegistry()
void
setIdentity(Identity identity)
void
setLocation(java.lang.String location)
void
setRpcMetrics(com.codahale.metrics.MetricRegistry metricRegistry)
void
setSinkMetrics(com.codahale.metrics.MetricRegistry sinkMetrics)
void
setTracerRegistry(TracerRegistry tracerRegistry)
void
shutdown()
void
start()
protected void
startConsumingForModule(SinkModule<?,Message> module)
protected void
stopConsumingForModule(SinkModule<?,Message> module)
-
Methods inherited from class org.opennms.core.ipc.sink.common.AbstractMessageConsumerManager
dispatch, getNumConsumerThreads, getStartupExecutor, registerConsumer, unregisterAllConsumers, unregisterConsumer
-
-
-
-
Constructor Detail
-
OpennmsGrpcServer
public OpennmsGrpcServer(GrpcIpcServer grpcIpcServer)
-
-
Method Detail
-
start
public void start() throws java.io.IOException
- Throws:
java.io.IOException
-
startConsumingForModule
protected void startConsumingForModule(SinkModule<?,Message> module) throws java.lang.Exception
- Specified by:
startConsumingForModule
in classAbstractMessageConsumerManager
- Throws:
java.lang.Exception
-
stopConsumingForModule
protected void stopConsumingForModule(SinkModule<?,Message> module) throws java.lang.Exception
- Specified by:
stopConsumingForModule
in classAbstractMessageConsumerManager
- Throws:
java.lang.Exception
-
getClient
public <S extends RpcRequest,T extends RpcResponse> RpcClient<S,T> getClient(RpcModule<S,T> module)
- Specified by:
getClient
in interfaceRpcClientFactory
-
getRpcHandler
public io.grpc.stub.StreamObserver<RpcRequestProto> getRpcHandler(java.lang.String location, java.lang.String systemId)
-
getLocation
public java.lang.String getLocation()
-
setLocation
public void setLocation(java.lang.String location)
-
getIdentity
public Identity getIdentity()
-
setIdentity
public void setIdentity(Identity identity)
-
setRpcMetrics
public void setRpcMetrics(com.codahale.metrics.MetricRegistry metricRegistry)
-
getSinkMetrics
public com.codahale.metrics.MetricRegistry getSinkMetrics()
-
setSinkMetrics
public void setSinkMetrics(com.codahale.metrics.MetricRegistry sinkMetrics)
-
getTracerRegistry
public TracerRegistry getTracerRegistry()
-
setTracerRegistry
public void setTracerRegistry(TracerRegistry tracerRegistry)
-
getTracer
public io.opentracing.Tracer getTracer()
-
shutdown
public void shutdown()
-
getRpcHandlerByLocation
public com.google.common.collect.Multimap<java.lang.String,io.grpc.stub.StreamObserver<RpcRequestProto>> getRpcHandlerByLocation()
-
-