Interface NetService


public interface NetService

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
  • Method Details

    • getTransportType

      NetService.TransportType getTransportType()

      Returns the transport type.

      Returns:
      a trasport type
    • createClient

      Bootstrap createClient(SocketAddress socketAddress)

      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

      Bootstrap createClient(SocketAddress socketAddress, NetClientConfiguration clientConfiguration)

      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 to
      clientConfiguration - the client configuration
      Returns:
      a client bootstrap
    • createClient

      Bootstrap createClient(SocketAddress socketAddress, int nThreads) throws IllegalArgumentException

      Creates a client bootstrap that will connect to the specified address with amount of threads.

      Parameters:
      socketAddress - the socket address to connect to
      nThreads - 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 to
      clientConfiguration - the client configuration
      nThreads - 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

      ServerBootstrap createServer(SocketAddress socketAddress)

      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 to
      serverConfiguration - 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 to
      nThreads - 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 to
      serverConfiguration - the server configuration
      nThreads - 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