A net service provides methods to create resource friendly IO and acceptor event loop groups ad well as clients and servers.
This service should always be used to create event loop groups, clients or servers (that eventually relies on event loop groups) as it allows to centralize their usage so that thread creation and usage can be optimized based on hardware capabilities.
For instance, a typical implementation would create a single event loop group according to CPU capacities and/or configuration and rely on this limited amount of event loops to provides event loop groups accross the application.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Represents the transport type supported at runtime. -
Method Summary
Modifier and TypeMethodDescriptioncreateClient
(SocketAddress socketAddress) Creates a client bootstrap that will connect to the specified address with all available threads.createClient
(SocketAddress socketAddress, int nThreads) Creates a client bootstrap that will connect to the specified address with amount of threads.createClient
(SocketAddress socketAddress, NetClientConfiguration clientConfiguration) Creates a client bootstrap that will connect to the specified address with the specified configuration and all available threads.createClient
(SocketAddress socketAddress, NetClientConfiguration clientConfiguration, int nThreads) Creates a client bootstrap that will connect to the specified address with the specified configuration and amount of threads.createServer
(SocketAddress socketAddress) Creates a server bootstrap that will bind to the specified address with all available threads.createServer
(SocketAddress socketAddress, int nThreads) Creates a server bootstrap that will bind to the specified address with the specified amount of threads.createServer
(SocketAddress socketAddress, NetServerConfiguration serverConfiguration) Creates a server bootstrap that will bind to the specified address with the specified configuration and all available threads.createServer
(SocketAddress socketAddress, NetServerConfiguration serverConfiguration, int nThreads) Creates a server bootstrap that will bind to the specified address with the specified server configuration and amount of threads.Returns a ByteBuf allocator.Returns a direct ByteBuf allocator.Returns the transport type.
-
Method Details
-
getTransportType
NetService.TransportType getTransportType()Returns the transport type.
- Returns:
- a trasport type
-
createClient
Creates a client bootstrap that will connect to the specified address with all available threads.
- Parameters:
socketAddress
- the socket address to connect to- Returns:
- a client bootstrap
-
createClient
Creates a client bootstrap that will connect to the specified address with the specified configuration and all available threads.
- Parameters:
socketAddress
- the socket address to connect toclientConfiguration
- the client configuration- Returns:
- a client bootstrap
-
createClient
Creates a client bootstrap that will connect to the specified address with amount of threads.
- Parameters:
socketAddress
- the socket address to connect tonThreads
- the number of threads to allocate- Returns:
- a client bootstrap
- Throws:
IllegalArgumentException
- if the specified number of thread exceeds the number of threads available
-
createClient
Bootstrap createClient(SocketAddress socketAddress, NetClientConfiguration clientConfiguration, int nThreads) throws IllegalArgumentException Creates a client bootstrap that will connect to the specified address with the specified configuration and amount of threads.
- Parameters:
socketAddress
- the socket address to connect toclientConfiguration
- the client configurationnThreads
- the number of threads to allocate- Returns:
- a client bootstrap
- Throws:
IllegalArgumentException
- if the specified number of thread exceeds the number of threads available
-
createServer
Creates a server bootstrap that will bind to the specified address with all available threads.
- Parameters:
socketAddress
- the socket address to bind to- Returns:
- a server bootstrap
-
createServer
ServerBootstrap createServer(SocketAddress socketAddress, NetServerConfiguration serverConfiguration) Creates a server bootstrap that will bind to the specified address with the specified configuration and all available threads.
- Parameters:
socketAddress
- the socket address to bind toserverConfiguration
- the server configuration- Returns:
- a server bootstrap
-
createServer
ServerBootstrap createServer(SocketAddress socketAddress, int nThreads) throws IllegalArgumentException Creates a server bootstrap that will bind to the specified address with the specified amount of threads.
- Parameters:
socketAddress
- the socket address to bind tonThreads
- the number of threads to allocate- Returns:
- a server bootstrap
- Throws:
IllegalArgumentException
- if the specified number of thread exceeds the number of threads available
-
createServer
ServerBootstrap createServer(SocketAddress socketAddress, NetServerConfiguration serverConfiguration, int nThreads) throws IllegalArgumentException Creates a server bootstrap that will bind to the specified address with the specified server configuration and amount of threads.
- Parameters:
socketAddress
- the socket address to bind toserverConfiguration
- the server configurationnThreads
- the number of threads to allocate- Returns:
- a server bootstrap
- Throws:
IllegalArgumentException
- if the specified number of thread exceeds the number of threads available
-
getByteBufAllocator
ByteBufAllocator getByteBufAllocator()Returns a ByteBuf allocator.
As for event loop groups, this service shall provide optimized ByteBuf allocators.
- Returns:
- a byte buf allocator
-
getDirectByteBufAllocator
ByteBufAllocator getDirectByteBufAllocator()Returns a direct ByteBuf allocator.
As for event loop groups, this service shall provide optimized ByteBuf allocators.
- Returns:
- a byte buf allocator
-