Class SyslogServer<T extends reactor.netty.DisposableChannel>
java.lang.Object
org.openehealth.ipf.commons.audit.server.SyslogServer<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
TlsSyslogServer
,UdpSyslogServer
public abstract class SyslogServer<T extends reactor.netty.DisposableChannel>
extends Object
implements Closeable
Abstract base class for TLS and UDP syslog servers. Received Syslog frames must be
handled by a consumer; the frames are parsed into a Map with keys as specified in
DefaultKeyProvider
. If parsing fails (e.g.
due to incomplete syslog frames, the map is populated with the raw content and the
expection that has been thrown by the parser.
One example for a consumer is SyslogEventCollector
that is practical for tests. With this respect, note that SyslogServer is Closeable
, so it can easily
be started and stopped by using a try-with-resources statement.
- Since:
- 4.0
- Author:
- Christian Ohr
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddress()
void
close()
protected abstract SyslogServer<T>
protected reactor.core.publisher.Mono<Object>
Asynchronously consumes syslog records.Starts the server and returns when started within 10 seconds.void
stop()
Stops the server if it was started before, and returns when stopped within 10 seconds.
-
Field Details
-
channel
-
consumer
-
errorConsumer
-
-
Constructor Details
-
Method Details
-
start
Starts the server and returns when started within 10 seconds. Requests are handled on the receiver thread.- Parameters:
host
- exposed hostport
- port- Returns:
- this instance
-
address
-
doStart
-
stop
public void stop()Stops the server if it was started before, and returns when stopped within 10 seconds. -
handleMap
Asynchronously consumes syslog records. This trick is described at https://levelup.gitconnected.com/reactive-asynchronous-programming-in-java-using-reactor-core-part-2-e9c6caeb8833. It generates a Mono from a potentially blocking call and subscribes using a scheduler.- Parameters:
map
- syslog map- Returns:
- nothing
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-