public class AbstractServer<I,O,B extends io.netty.bootstrap.AbstractBootstrap<B,C>,C extends io.netty.channel.Channel,S extends AbstractServer> extends java.lang.Object implements MetricEventsPublisher<ServerMetricsEvent<?>>
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractServer.ServerState |
Modifier and Type | Field and Description |
---|---|
protected B |
bootstrap |
protected UnpooledConnectionFactory<I,O> |
connectionFactory |
protected ErrorHandler |
errorHandler |
protected MetricEventsSubject<ServerMetricsEvent<?>> |
eventsSubject |
protected int |
port |
protected java.util.concurrent.atomic.AtomicReference<AbstractServer.ServerState> |
serverStateRef |
Constructor and Description |
---|
AbstractServer(B bootstrap,
int port) |
Modifier and Type | Method and Description |
---|---|
MetricEventsSubject<ServerMetricsEvent<?>> |
getEventsSubject() |
int |
getServerPort() |
protected io.netty.channel.ChannelInitializer<io.netty.channel.Channel> |
newChannelInitializer(PipelineConfigurator<I,O> pipelineConfigurator,
ConnectionHandler<I,O> connectionHandler,
io.netty.util.concurrent.EventExecutorGroup connHandlingExecutor) |
protected S |
returnServer() |
void |
shutdown() |
S |
start() |
void |
startAndWait() |
rx.Subscription |
subscribe(MetricEventsListener<? extends ServerMetricsEvent<?>> listener) |
void |
waitTillShutdown() |
void |
waitTillShutdown(long duration,
java.util.concurrent.TimeUnit timeUnit) |
S |
withErrorHandler(ErrorHandler errorHandler)
A catch all error handler which gets invoked if any error happens during connection handling by the configured
ConnectionHandler . |
protected final UnpooledConnectionFactory<I,O> connectionFactory
protected final int port
protected final java.util.concurrent.atomic.AtomicReference<AbstractServer.ServerState> serverStateRef
protected final MetricEventsSubject<ServerMetricsEvent<?>> eventsSubject
protected ErrorHandler errorHandler
public AbstractServer(B bootstrap, int port)
public void startAndWait()
public S start()
public S withErrorHandler(ErrorHandler errorHandler)
ConnectionHandler
.errorHandler
- Error handler to invoke when ConnectionHandler
threw an error.public void shutdown() throws java.lang.InterruptedException
java.lang.InterruptedException
public void waitTillShutdown() throws java.lang.InterruptedException
java.lang.InterruptedException
public void waitTillShutdown(long duration, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
java.lang.InterruptedException
public int getServerPort()
public MetricEventsSubject<ServerMetricsEvent<?>> getEventsSubject()
public rx.Subscription subscribe(MetricEventsListener<? extends ServerMetricsEvent<?>> listener)
subscribe
in interface MetricEventsPublisher<ServerMetricsEvent<?>>
protected S returnServer()
protected io.netty.channel.ChannelInitializer<io.netty.channel.Channel> newChannelInitializer(PipelineConfigurator<I,O> pipelineConfigurator, ConnectionHandler<I,O> connectionHandler, io.netty.util.concurrent.EventExecutorGroup connHandlingExecutor)