Package com.yahoo.jrt
Class Transport
- java.lang.Object
-
- com.yahoo.jrt.Transport
-
public class Transport extends Object
The Transport class is the core needed to make yourSupervisor
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 multipleSupervisor
objects.
-
-
Constructor Summary
Constructors Constructor Description Transport()
Transport(String name)
Transport(String name, int numThreads)
Transport(String name, int numThreads, boolean tcpNoDelay, int eventsBeforeWakeup)
Transport(String name, int numThreads, int eventsBeforeWakeup)
Transport(String name, CryptoEngine cryptoEngine, int numThreads)
Transport(String name, CryptoEngine cryptoEngine, int numThreads, int eventsBeforeWakeup)
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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
void
join()
Wait for all transport threads to finish.TransportMetrics
metrics()
TransportThread
selectThread()
Select a random transport threadTransport
shutdown()
Initiate controlled shutdown of all transport threads.Transport
sync()
Synchronize with all transport threads.
-
-
-
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 threadsfatalHandler
- fatal error handlercryptoEngine
- crypto engine to usenumThreads
- number ofTransportThread
s.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.
-
metrics
public TransportMetrics metrics()
-
-