Class PreboundSocketFactoryManager

java.lang.Object
org.apache.kafka.common.test.PreboundSocketFactoryManager
All Implemented Interfaces:
AutoCloseable

public class PreboundSocketFactoryManager extends Object implements AutoCloseable
  • Constructor Details

    • PreboundSocketFactoryManager

      public PreboundSocketFactoryManager()
  • Method Details

    • getSocketForListenerAndMarkAsUsed

      public ServerSocketChannel getSocketForListenerAndMarkAsUsed(int nodeId, String listener)
      Get a socket from this manager, mark it as used, and return it.
      Parameters:
      nodeId - The ID of the node.
      listener - The listener for the socket.
      Returns:
      null if the socket was not found; the socket, otherwise.
    • getOrCreateSocketFactory

      public org.apache.kafka.server.ServerSocketFactory getOrCreateSocketFactory(int nodeId)
      Get or create a socket factory object associated with a given node ID.
      Parameters:
      nodeId - The ID of the node.
      Returns:
      The socket factory.
    • getOrCreatePortForListener

      public int getOrCreatePortForListener(int nodeId, String listener) throws IOException
      Get a specific port number. The port will be created if it does not already exist.
      Parameters:
      nodeId - The ID of the node.
      listener - The listener for the socket.
      Returns:
      The port number.
      Throws:
      IOException
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception