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.ServerBootstrap
bootstrap()
protected <H,P extends ResourcePath<K>,K,R>
Router4PipelineFactory<C>constructRouterPipelineFactory(ScatterGatherRequestHandler4<H,P,K,R> scatterGatherRequestHandler)
int
getActiveStreams()
ActiveStreamsCountHandler
getActiveStreamsCountHandler()
int
getConnectedCount()
ConnectionLimitHandler
getConnectionLimit()
Http2SettingsFrameLogger
getHttp2SettingsFrameLogger()
AsyncFuture<java.net.SocketAddress>
getLocalAddress()
io.netty.util.Timer
getNettyTimer()
java.util.function.Supplier<Router4PipelineFactory<C>>
getPipelineSupplier()
long
getRstErrorCount()
boolean
isBusyAutoReadDisable()
static boolean
isBusyAutoReadDisable(Router router)
boolean
isShutdown()
Returns true if this resource has been shut down.boolean
isTerminated()
Returns true if the resource has completed shutting down.Netty
nettyVersion()
AsyncFuture<java.lang.Void>
setAcceptConnection(boolean enabled)
void
setBusyAutoReadDisable(boolean busyAutoReadDisable)
static void
setBusyAutoReadDisable(Router router, boolean busyAutoReadDisable)
void
setPipelineSupplier(java.util.function.Supplier<Router4PipelineFactory<C>> pipelineSupplier)
void
shutdown()
Starts the shutdown process.AsyncFuture<java.net.SocketAddress>
start(java.net.SocketAddress address)
void
waitForShutdown()
Waits for shutdown to completevoid
waitForShutdown(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:
nettyVersion
in 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:
getLocalAddress
in interfaceRouter
-
setAcceptConnection
public AsyncFuture<java.lang.Void> setAcceptConnection(boolean enabled)
- Specified by:
setAcceptConnection
in interfaceRouter
-
getConnectedCount
public int getConnectedCount()
- Specified by:
getConnectedCount
in interfaceRouter
-
getActiveStreams
public int getActiveStreams()
- Specified by:
getActiveStreams
in interfaceRouter
-
getRstErrorCount
public long getRstErrorCount()
- Specified by:
getRstErrorCount
in 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:
isShutdown
in 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:
isTerminated
in 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:
shutdown
in interfaceShutdownable
-
waitForShutdown
public void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateException
Waits for shutdown to complete- Specified by:
waitForShutdown
in 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.TimeoutException
Waits for shutdown to complete with a timeout- Specified by:
waitForShutdown
in 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()
-
-