Package com.yahoo.jrt

Class Transport


  • public class Transport
    extends 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 Detail

      • Transport

        public Transport​(String name,
                         FatalErrorHandler fatalHandler,
                         CryptoEngine cryptoEngine,
                         int numThreads,
                         boolean tcpNoDelay,
                         int eventsBeforeWakeup)
        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.
        eventsBeforeWakeup - number write events in Q before waking thread up
      • Transport

        public Transport​(String name,
                         CryptoEngine cryptoEngine,
                         int numThreads,
                         int eventsBeforeWakeup)
      • Transport

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

        public Transport​(String name,
                         int numThreads,
                         int eventsBeforeWakeup)
      • Transport

        public Transport​(String name,
                         int numThreads,
                         boolean tcpNoDelay,
                         int eventsBeforeWakeup)
      • Transport

        public Transport​(String name,
                         int numThreads)
      • Transport

        public Transport​(String name)
      • Transport

        public Transport()
    • Method Detail

      • selectThread

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

        public String getName()
      • 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.