Class PreboundSocketFactoryManager
java.lang.Object
org.apache.kafka.common.test.PreboundSocketFactoryManager
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intgetOrCreatePortForListener(int nodeId, String listener) Get a specific port number.org.apache.kafka.server.ServerSocketFactorygetOrCreateSocketFactory(int nodeId) Get or create a socket factory object associated with a given node ID.getSocketForListenerAndMarkAsUsed(int nodeId, String listener) Get a socket from this manager, mark it as used, and return it.
-
Constructor Details
-
PreboundSocketFactoryManager
public PreboundSocketFactoryManager()
-
-
Method Details
-
getSocketForListenerAndMarkAsUsed
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
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
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-