Class RpcSocketPool
java.lang.Object
com.perforce.p4java.impl.mapbased.rpc.stream.RpcSocketPool
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceShutdown handler for cleaning up before a socket is closed -
Constructor Summary
ConstructorsConstructorDescriptionRpcSocketPool(int poolSize, String host, int port, Properties socketProperties, RpcSocketPool.ShutdownHandler shutdownHandler) Create a new socket pool with a max pool size, host, port, and socket properties, and an optional shutdown handlerRpcSocketPool(int poolSize, String host, int port, Properties socketProperties, RpcSocketPool.ShutdownHandler shutdownHandler, boolean secure) Create a new socket pool indicating whether it is secure (SSL) or not. -
Method Summary
Modifier and TypeMethodDescriptionacquire()Acquire a socket to the configured server addressvoidDisconnect all sockets from the specified host and portvoidrelease(Socket socket, RpcSocketPool.ShutdownHandler shutdownHandler) Release a socket back to the pool as no longer usingvoidtimeout(int idleDuration) Timeout any sockets idle for greater than or equal to the milliseconds value specified
-
Constructor Details
-
RpcSocketPool
public RpcSocketPool(int poolSize, String host, int port, Properties socketProperties, RpcSocketPool.ShutdownHandler shutdownHandler, boolean secure) Create a new socket pool indicating whether it is secure (SSL) or not.- Parameters:
poolSize- poolSizehost- hostport- portsocketProperties- socketPropertiesshutdownHandler- shutdownHandlersecure- secure
-
RpcSocketPool
public RpcSocketPool(int poolSize, String host, int port, Properties socketProperties, RpcSocketPool.ShutdownHandler shutdownHandler) Create a new socket pool with a max pool size, host, port, and socket properties, and an optional shutdown handler- Parameters:
poolSize- poolSizehost- hostport- portsocketProperties- socketPropertiesshutdownHandler- shutdownHandler
-
-
Method Details
-
acquire
Acquire a socket to the configured server address- Returns:
- - socket
- Throws:
IOException- on error
-
release
public void release(Socket socket, RpcSocketPool.ShutdownHandler shutdownHandler) throws IOException Release a socket back to the pool as no longer using- Parameters:
socket- socketshutdownHandler- shutdownHandler- Throws:
IOException- on error
-
disconnect
public void disconnect()Disconnect all sockets from the specified host and port -
timeout
public void timeout(int idleDuration) Timeout any sockets idle for greater than or equal to the milliseconds value specified- Parameters:
idleDuration- idleDuration
-