Class RpcSocketPool


  • public class RpcSocketPool
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  RpcSocketPool.ShutdownHandler
      Shutdown handler for cleaning up before a socket is closed
    • Constructor Summary

      Constructors 
      Constructor Description
      RpcSocketPool​(int poolSize, java.lang.String host, int port, java.util.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
      RpcSocketPool​(int poolSize, java.lang.String host, int port, java.util.Properties socketProperties, RpcSocketPool.ShutdownHandler shutdownHandler, boolean secure)
      Create a new socket pool indicating whether it is secure (SSL) or not.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.Socket acquire()
      Acquire a socket to the configured server address
      void disconnect()
      Disconnect all sockets from the specified host and port
      void release​(java.net.Socket socket, RpcSocketPool.ShutdownHandler shutdownHandler)
      Release a socket back to the pool as no longer using
      void timeout​(int idleDuration)
      Timeout any sockets idle for greater than or equal to the milliseconds value specified
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RpcSocketPool

        public RpcSocketPool​(int poolSize,
                             java.lang.String host,
                             int port,
                             java.util.Properties socketProperties,
                             RpcSocketPool.ShutdownHandler shutdownHandler,
                             boolean secure)
        Create a new socket pool indicating whether it is secure (SSL) or not.
        Parameters:
        poolSize - poolSize
        host - host
        port - port
        socketProperties - socketProperties
        shutdownHandler - shutdownHandler
        secure - secure
      • RpcSocketPool

        public RpcSocketPool​(int poolSize,
                             java.lang.String host,
                             int port,
                             java.util.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 - poolSize
        host - host
        port - port
        socketProperties - socketProperties
        shutdownHandler - shutdownHandler
    • Method Detail

      • acquire

        public java.net.Socket acquire()
                                throws java.io.IOException
        Acquire a socket to the configured server address
        Returns:
        - socket
        Throws:
        java.io.IOException - on error
      • release

        public void release​(java.net.Socket socket,
                            RpcSocketPool.ShutdownHandler shutdownHandler)
                     throws java.io.IOException
        Release a socket back to the pool as no longer using
        Parameters:
        socket - socket
        shutdownHandler - shutdownHandler
        Throws:
        java.io.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