public abstract class NIOTransportBuilder<T extends NIOTransportBuilder> extends Object
NIOTransport implementations
as well as providing basic configuration for IOStrategies and
thread pools.NIOTransport,
IOStrategy,
ThreadPoolConfig| Modifier and Type | Field and Description |
|---|---|
protected AttributeBuilder |
attributeBuilder |
protected int |
clientSocketSoTimeout |
protected int |
connectionTimeout |
protected IOStrategy |
ioStrategy |
protected ThreadPoolConfig |
kernelConfig |
protected int |
maxPendingBytesPerConnection |
protected MemoryManager |
memoryManager |
protected String |
name |
protected NIOChannelDistributor |
nioChannelDistributor |
protected boolean |
optimizedForMultiplexing |
protected Processor |
processor |
protected ProcessorSelector |
processorSelector |
protected int |
readBufferSize |
protected boolean |
reuseAddress |
protected SelectionKeyHandler |
selectionKeyHandler |
protected SelectorHandler |
selectorHandler |
protected SelectorProvider |
selectorProvider |
protected int |
selectorRunnerCount |
protected Class<? extends NIOTransport> |
transportClass |
protected ThreadPoolConfig |
workerConfig |
protected int |
writeBufferSize |
| Modifier | Constructor and Description |
|---|---|
protected |
NIOTransportBuilder(Class<? extends NIOTransport> transportClass)
|
protected Class<? extends NIOTransport> transportClass
protected ThreadPoolConfig workerConfig
protected ThreadPoolConfig kernelConfig
protected SelectorProvider selectorProvider
protected SelectorHandler selectorHandler
protected SelectionKeyHandler selectionKeyHandler
protected MemoryManager memoryManager
protected AttributeBuilder attributeBuilder
protected IOStrategy ioStrategy
protected int selectorRunnerCount
protected NIOChannelDistributor nioChannelDistributor
protected String name
protected Processor processor
protected ProcessorSelector processorSelector
protected int readBufferSize
protected int writeBufferSize
protected int clientSocketSoTimeout
protected int connectionTimeout
protected boolean reuseAddress
protected int maxPendingBytesPerConnection
protected boolean optimizedForMultiplexing
protected NIOTransportBuilder(Class<? extends NIOTransport> transportClass)
Constructs a new NIOTransport using the given
transportClass and IOStrategy.
The builder's worker thread pool configuration will be based on the return
value of WorkerThreadPoolConfigProducer.createDefaultWorkerPoolConfig(Transport).
If worker thread configuration is non-null, the initial selector thread pool
configuration will be cloned from it, otherwise a default configuration
will be chosen.
transportClass - the class of the NIOTransport
implementation to be used.public ThreadPoolConfig getWorkerThreadPoolConfig()
ThreadPoolConfig that will be used to construct the
ExecutorService for IOStrategies
that require worker threads. This method will return null
if a ThreadPoolConfig had not been previously set.public T setWorkerThreadPoolConfig(ThreadPoolConfig workerConfig)
ThreadPoolConfig that will be used to construct the
ExecutorService for IOStrategies
that require worker threadspublic ThreadPoolConfig getSelectorThreadPoolConfig()
ThreadPoolConfig that will be used to construct the
ExecutorService which will run the NIOTransport's
SelectorRunners.public T setSelectorThreadPoolConfig(ThreadPoolConfig kernelConfig)
ThreadPoolConfig that will be used to construct the
ExecutorService which will run the NIOTransport's
SelectorRunners.public IOStrategy getIOStrategy()
IOStrategy that will be used by the created NIOTransport.public T setIOStrategy(IOStrategy ioStrategy)
Changes the IOStrategy that will be used. Invoking this method
may change the return value of getWorkerThreadPoolConfig()
ioStrategy - the IOStrategy to use.NIOTransportBuilderpublic MemoryManager getMemoryManager()
MemoryManager that will be used by the created NIOTransport.
If not explicitly set, then MemoryManager.DEFAULT_MEMORY_MANAGER will be used.public T setMemoryManager(MemoryManager memoryManager)
MemoryManager to be used by the created NIOTransport.memoryManager - the MemoryManager.NIOTransportBuilderpublic SelectorHandler getSelectorHandler()
SelectorHandler that will be used by the created NIOTransport.
If not explicitly set, then SelectorHandler.DEFAULT_SELECTOR_HANDLER will be used.public T setSelectorHandler(SelectorHandler selectorHandler)
SelectorHandler to be used by the created NIOTransport.selectorHandler - the SelectorHandler.NIOTransportBuilderpublic SelectionKeyHandler getSelectionKeyHandler()
SelectionKeyHandler that will be used by the created NIOTransport.
If not explicitly set, then SelectionKeyHandler.DEFAULT_SELECTION_KEY_HANDLER will be used.public T setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler)
SelectionKeyHandler to be used by the created NIOTransport.selectionKeyHandler - the SelectionKeyHandler.NIOTransportBuilderpublic AttributeBuilder getAttributeBuilder()
AttributeBuilder that will be used by the created NIOTransport.
If not explicitly set, then AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER will be used.public T setAttributeBuilder(AttributeBuilder attributeBuilder)
AttributeBuilder to be used by the created NIOTransport.attributeBuilder - the AttributeBuilder.NIOTransportBuilderpublic NIOChannelDistributor getNIOChannelDistributor()
NIOChannelDistributor that will be used by the created NIOTransport.
If not explicitly set, then AttributeBuilder.DEFAULT_ATTRIBUTE_BUILDER will be used.public T setNIOChannelDistributor(NIOChannelDistributor nioChannelDistributor)
NIOChannelDistributor to be used by the created NIOTransport.nioChannelDistributor - the NIOChannelDistributor.NIOTransportBuilderpublic SelectorProvider getSelectorProvider()
SelectorProvider that will be used by the created NIOTransport.
If not explicitly set, then SelectorProvider.provider() will be used.public T setSelectorProvider(SelectorProvider selectorProvider)
SelectorProvider to be used by the created NIOTransport.selectorProvider - the SelectorProvider.NIOTransportBuilderpublic String getName()
Transport.getName()public T setName(String name)
NIOTransportBuilderTransport.setName(String)public Processor getProcessor()
Transport.getProcessor()public T setProcessor(Processor processor)
NIOTransportBuilderTransport.setProcessor(Processor)public ProcessorSelector getProcessorSelector()
()public T setProcessorSelector(ProcessorSelector processorSelector)
NIOTransportBuilderTransport.setProcessorSelector(ProcessorSelector)public int getReadBufferSize()
()public T setReadBufferSize(int readBufferSize)
NIOTransportBuilderTransport.setReadBufferSize(int)public int getWriteBufferSize()
Transport.getWriteBufferSize()public T setWriteBufferSize(int writeBufferSize)
NIOTransportBuilderTransport.setWriteBufferSize(int)public int getClientSocketSoTimeout()
public T setClientSocketSoTimeout(int clientSocketSoTimeout)
NIOTransportBuilderNIOTransport.setClientSocketSoTimeout(int)public int getConnectionTimeout()
NIOTransport.getConnectionTimeout()public T setConnectionTimeout(int connectionTimeout)
NIOTransportBuilderNIOTransport.setConnectionTimeout(int)public boolean isReuseAddress()
NIOTransport.isReuseAddress()public T setReuseAddress(boolean reuseAddress)
TCPNIOTransportBuilderNIOTransport.setReuseAddress(boolean)public int getMaxAsyncWriteQueueSizeInBytes()
public T setMaxAsyncWriteQueueSizeInBytes(int maxAsyncWriteQueueSizeInBytes)
TCPNIOTransportBuilder
Note: the value is per connection, not transport total.public boolean isOptimizedForMultiplexing()
public T setOptimizedForMultiplexing(boolean optimizedForMultiplexing)
TCPNIOTransportBuilderNIOTransport.setOptimizedForMultiplexing(boolean)public NIOTransport build()
NIOTransport based on the builder's configuration.protected ThreadPoolConfig configSelectorPool(ThreadPoolConfig config)
Configure the SelectorRunner pool's
default core and max pool size.
config - protected abstract T getThis()
protected abstract NIOTransport create()
Copyright © 2013 Oracle Corporation. All Rights Reserved.