Package com.yahoo.jrt

Class Transport


  • public class Transport
    extends java.lang.Object
    The Transport class is the core needed to make your Supervisor tick. It implements the reactor pattern to perform multiplexed network IO, handles scheduled tasks and keeps track of some additional helper threads. A single Transport object can back multiple Supervisor objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      Transport()  
      Transport​(java.lang.String name)  
      Transport​(java.lang.String name, int numThreads)  
      Transport​(java.lang.String name, int numThreads, boolean tcpNoDelay)  
      Transport​(java.lang.String name, CryptoEngine cryptoEngine, int numThreads)  
      Transport​(java.lang.String name, FatalErrorHandler fatalHandler, CryptoEngine cryptoEngine, int numThreads, boolean tcpNoDelay)
      Create a new Transport object with the given fatal error handler and CryptoEngine.
    • Constructor Detail

      • Transport

        public Transport​(java.lang.String name,
                         FatalErrorHandler fatalHandler,
                         CryptoEngine cryptoEngine,
                         int numThreads,
                         boolean tcpNoDelay)
        Create a new Transport object with the given fatal error handler and CryptoEngine. If a fatal error occurs when no fatal error handler is registered, the default action is to log the error and exit with exit code 1.
        Parameters:
        name - used for identifying threads
        fatalHandler - fatal error handler
        cryptoEngine - crypto engine to use
        numThreads - number of TransportThreads.
      • Transport

        public Transport​(java.lang.String name,
                         CryptoEngine cryptoEngine,
                         int numThreads)
      • Transport

        public Transport​(java.lang.String name,
                         int numThreads)
      • Transport

        public Transport​(java.lang.String name,
                         int numThreads,
                         boolean tcpNoDelay)
      • Transport

        public Transport​(java.lang.String name)
      • Transport

        public Transport()
    • Method Detail

      • selectThread

        public TransportThread selectThread()
        Select a random transport thread
        Returns:
        a random transport thread
      • sync

        public Transport sync()
        Synchronize with all transport threads. This method will block until all commands issued before this method was invoked has completed. If a transport thread has been shut down (or is in the progress of being shut down) this method will instead wait for the transport thread to complete, since no more commands will be performed, and waiting would be forever. Invoking this method from a transport thread is not a good idea.
        Returns:
        this object, to enable chaining
      • shutdown

        public Transport shutdown()
        Initiate controlled shutdown of all transport threads.
        Returns:
        this object, to enable chaining with join
      • join

        public void join()
        Wait for all transport threads to finish.