Class Router4Impl<C extends io.netty.channel.Channel>
- java.lang.Object
-
- com.linkedin.alpini.router.impl.netty4.Router4Impl<C>
-
- All Implemented Interfaces:
ResourceRegistry.Sync,Shutdownable,ShutdownableResource,Router
public class Router4Impl<C extends io.netty.channel.Channel> extends java.lang.Object implements Router, ResourceRegistry.Sync
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.linkedin.alpini.router.impl.Router
Router.Builder, Router.PipelineFactory<CHANNEL_HANDLER>
-
-
Constructor Summary
Constructors Constructor Description Router4Impl(java.lang.String name, java.lang.Class<? extends io.netty.channel.socket.ServerSocketChannel> channelClass, io.netty.channel.EventLoopGroup bossPool, io.netty.channel.EventLoopGroup workerPool, io.netty.util.concurrent.EventExecutor workerExecutor, ConnectionLimitHandler connectionLimit, ActiveStreamsCountHandler activeStreamsCountHandler, Http2SettingsFrameLogger http2SettingsFrameLogger, RouterTimeoutProcessor timeoutProcessor, io.netty.util.Timer nettyTimer, java.util.Map<java.lang.String,java.lang.Object> serverSocketOptions, ScatterGatherHelper<H,P,K,R,BasicFullHttpRequest,io.netty.handler.codec.http.FullHttpResponse,io.netty.handler.codec.http.HttpResponseStatus> scatterGatherHelper)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected io.netty.bootstrap.ServerBootstrapbootstrap()protected <H,P extends ResourcePath<K>,K,R>
Router4PipelineFactory<C>constructRouterPipelineFactory(ScatterGatherRequestHandler4<H,P,K,R> scatterGatherRequestHandler)intgetActiveStreams()ActiveStreamsCountHandlergetActiveStreamsCountHandler()intgetConnectedCount()ConnectionLimitHandlergetConnectionLimit()Http2SettingsFrameLoggergetHttp2SettingsFrameLogger()AsyncFuture<java.net.SocketAddress>getLocalAddress()io.netty.util.TimergetNettyTimer()java.util.function.Supplier<Router4PipelineFactory<C>>getPipelineSupplier()longgetRstErrorCount()booleanisBusyAutoReadDisable()static booleanisBusyAutoReadDisable(Router router)booleanisShutdown()Returns true if this resource has been shut down.booleanisTerminated()Returns true if the resource has completed shutting down.NettynettyVersion()AsyncFuture<java.lang.Void>setAcceptConnection(boolean enabled)voidsetBusyAutoReadDisable(boolean busyAutoReadDisable)static voidsetBusyAutoReadDisable(Router router, boolean busyAutoReadDisable)voidsetPipelineSupplier(java.util.function.Supplier<Router4PipelineFactory<C>> pipelineSupplier)voidshutdown()Starts the shutdown process.AsyncFuture<java.net.SocketAddress>start(java.net.SocketAddress address)voidwaitForShutdown()Waits for shutdown to completevoidwaitForShutdown(long timeoutInMs)Waits for shutdown to complete with a timeout
-
-
-
Constructor Detail
-
Router4Impl
public Router4Impl(java.lang.String name, java.lang.Class<? extends io.netty.channel.socket.ServerSocketChannel> channelClass, io.netty.channel.EventLoopGroup bossPool, io.netty.channel.EventLoopGroup workerPool, io.netty.util.concurrent.EventExecutor workerExecutor, ConnectionLimitHandler connectionLimit, ActiveStreamsCountHandler activeStreamsCountHandler, Http2SettingsFrameLogger http2SettingsFrameLogger, RouterTimeoutProcessor timeoutProcessor, io.netty.util.Timer nettyTimer, java.util.Map<java.lang.String,java.lang.Object> serverSocketOptions, @Nonnull ScatterGatherHelper<H,P,K,R,BasicFullHttpRequest,io.netty.handler.codec.http.FullHttpResponse,io.netty.handler.codec.http.HttpResponseStatus> scatterGatherHelper)
-
-
Method Detail
-
getPipelineSupplier
public java.util.function.Supplier<Router4PipelineFactory<C>> getPipelineSupplier()
-
setPipelineSupplier
public void setPipelineSupplier(@Nonnull java.util.function.Supplier<Router4PipelineFactory<C>> pipelineSupplier)
-
constructRouterPipelineFactory
protected <H,P extends ResourcePath<K>,K,R> Router4PipelineFactory<C> constructRouterPipelineFactory(@Nonnull ScatterGatherRequestHandler4<H,P,K,R> scatterGatherRequestHandler)
-
nettyVersion
public Netty nettyVersion()
- Specified by:
nettyVersionin interfaceRouter
-
bootstrap
protected io.netty.bootstrap.ServerBootstrap bootstrap()
-
start
public AsyncFuture<java.net.SocketAddress> start(java.net.SocketAddress address)
-
getLocalAddress
public AsyncFuture<java.net.SocketAddress> getLocalAddress()
- Specified by:
getLocalAddressin interfaceRouter
-
setAcceptConnection
public AsyncFuture<java.lang.Void> setAcceptConnection(boolean enabled)
- Specified by:
setAcceptConnectionin interfaceRouter
-
getConnectedCount
public int getConnectedCount()
- Specified by:
getConnectedCountin interfaceRouter
-
getActiveStreams
public int getActiveStreams()
- Specified by:
getActiveStreamsin interfaceRouter
-
getRstErrorCount
public long getRstErrorCount()
- Specified by:
getRstErrorCountin interfaceRouter
-
isBusyAutoReadDisable
public boolean isBusyAutoReadDisable()
-
setBusyAutoReadDisable
public void setBusyAutoReadDisable(boolean busyAutoReadDisable)
-
setBusyAutoReadDisable
public static void setBusyAutoReadDisable(Router router, boolean busyAutoReadDisable)
-
isBusyAutoReadDisable
public static boolean isBusyAutoReadDisable(Router router)
-
isShutdown
public boolean isShutdown()
Returns true if this resource has been shut down.- Specified by:
isShutdownin interfaceShutdownableResource- Returns:
- true if this resource has been shut down
-
isTerminated
public boolean isTerminated()
Returns true if the resource has completed shutting down. Note that isTerminated is never true unless shutdown was called first.- Specified by:
isTerminatedin interfaceShutdownableResource- Returns:
- true if the resource has completed shutting down.
-
shutdown
public void shutdown()
Starts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown- Specified by:
shutdownin interfaceShutdownable
-
waitForShutdown
public void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateExceptionWaits for shutdown to complete- Specified by:
waitForShutdownin interfaceShutdownable- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to be started
-
waitForShutdown
public void waitForShutdown(long timeoutInMs) throws java.lang.InterruptedException, java.lang.IllegalStateException, java.util.concurrent.TimeoutExceptionWaits for shutdown to complete with a timeout- Specified by:
waitForShutdownin interfaceShutdownable- Parameters:
timeoutInMs- number of milliseconds to wait before throwing TimeoutException- Throws:
java.lang.InterruptedException- when the wait is interruptedjava.lang.IllegalStateException- when the method is invoked when the shutdown has yet to be startedjava.util.concurrent.TimeoutException- when the operation times out
-
getNettyTimer
public io.netty.util.Timer getNettyTimer()
-
getConnectionLimit
public ConnectionLimitHandler getConnectionLimit()
-
getActiveStreamsCountHandler
public ActiveStreamsCountHandler getActiveStreamsCountHandler()
-
getHttp2SettingsFrameLogger
public Http2SettingsFrameLogger getHttp2SettingsFrameLogger()
-
-