Package com.sshtools.synergy.nio
Class SshEngineContext
java.lang.Object
com.sshtools.synergy.nio.SshEngineContext
Each instance of a
SshEngine has a single configuration context.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEventListener(EventListener listener) addListeningInterface(String addressToBind, int portToBind, ProtocolContextFactory<?> contextFactory, boolean reuseAddress) Add an interface and port to the listening socket list and provide the protocol context.addListeningInterface(InetAddress addressToBind, int portToBind, ProtocolContextFactory<?> contextFactory, boolean reuseAddress) Add an interface and port to the listening socket list and provide the protocol context.<K> KgetAttribute(String name, K defaultValue) com.sshtools.common.util.ByteBufferPoolReturns a direct buffer pool.Get the instance of the SSHD for this context.intGet the time in seconds for each idle period service run.intTo determine whether any channels are idle a service run is performed to evaluate the state of each channel.intGet the listening socket list.intGet the maximum number of channels that can be serviced by a single selector thread.intGet the maximum number of connections allowed at any one time.intGet the number of permanent accept threads.intGet the number of permanent connect threads.intGet the number of permanent transfer threads.Get the product name used to prefix thread namesGet the SelectorProvider used to create Selector instances.Get the text used when disconnecting when the maximum connection threshold has been reached.booleanDetermine whether the daemon is using direct byte buffers.static voidremoveEventListener(EventListener listener) voidremoveListeningInterface(String anInterface) Deprecated.voidremoveListeningInterface(String addressBound, int portBound) Remove a listening interface from the daemon at runtime.voidremoveListeningInterface(InetAddress addressBound, int portBound) Remove a listening interface from the daemon at runtime.voidsetAttribute(String name, Object value) voidsetBufferPoolArraySize(int bufferPoolArraySize) Set the size of the byte buffers in the pool.voidsetIdleServiceRunPeriod(int idleServicePeriod) voidsetInactiveServiceRunsPerIdleEvent(int inactivePeriodsPerIdleEvent) To determine whether any channels are idle a service run is performed to evaluate the state of each channel.voidsetIpv6WorkaroundBindAddress(String ipv6WorkaroundBindAddress) voidsetIpv6WorkaroundPort(int ipv6WorkaroundPort) voidsetMaximumChannelsPerThread(int maximumChannelsPerThread) Set the maximum number of channels that can be serviced by a single selector thread.voidsetMaximumConnections(int maximumConnections) Set the maximum number of connections allowed at any one time.voidsetPermanentAcceptThreads(int permanentAcceptThreads) Set the number of permanent accept threads.voidsetPermanentConnectThreads(int permanentConnectThreads) Set the number of permanent connect threads.voidsetPermanentTransferThreads(int permanentTransferThreads) Set the number of permanent transfer threads.voidsetProduct(String product) Set the product namevoidsetSelectorProvider(SelectorProvider selectorProvider) Set the SelectorProvider used by the Selector threads.voidsetTooManyConnectionsText(String tooManyConnectionsText) Set the text used when disconnecting when the maximum connection threshold has been reached.voidsetUsingDirectBuffers(boolean useDirectByteBuffers) Configure the byte buffer pool to use direct byte buffers.
-
Method Details
-
setProduct
Set the product name- Parameters:
String- product
-
getProduct
Get the product name used to prefix thread names -
setMaximumConnections
public void setMaximumConnections(int maximumConnections) Set the maximum number of connections allowed at any one time.- Parameters:
maximumConnections- int
-
getMaximumConnections
public int getMaximumConnections()Get the maximum number of connections allowed at any one time.- Returns:
- int
-
getTooManyConnectionsText
Get the text used when disconnecting when the maximum connection threshold has been reached.- Returns:
-
setTooManyConnectionsText
Set the text used when disconnecting when the maximum connection threshold has been reached.- Parameters:
tooManyConnectionsText-
-
getBufferPool
public com.sshtools.common.util.ByteBufferPool getBufferPool()Returns a direct buffer pool.- Returns:
- ByteBufferPool
-
setSelectorProvider
Set the SelectorProvider used by the Selector threads.- Parameters:
selectorProvider- SelectorProvider
-
getSelectorProvider
Get the SelectorProvider used to create Selector instances.- Returns:
- SelectorProvider
-
getEngine
Get the instance of the SSHD for this context.- Returns:
-
isUsingDirectBuffers
public boolean isUsingDirectBuffers()Determine whether the daemon is using direct byte buffers.- Returns:
- boolean
-
setUsingDirectBuffers
public void setUsingDirectBuffers(boolean useDirectByteBuffers) Configure the byte buffer pool to use direct byte buffers.- Parameters:
useDirectByteBuffers- boolean
-
setBufferPoolArraySize
public void setBufferPoolArraySize(int bufferPoolArraySize) Set the size of the byte buffers in the pool. The minimum size is 35000 bytes- Parameters:
bufferPoolArraySize- int
-
addListeningInterface
public ListeningInterface addListeningInterface(String addressToBind, int portToBind, ProtocolContextFactory<?> contextFactory, boolean reuseAddress) throws IOException Add an interface and port to the listening socket list and provide the protocol context. handler for subsequent connections.- Parameters:
addressToBind- StringportToBind- intprotocolContext-- Throws:
IOExceptionIOException
-
addListeningInterface
public ListeningInterface addListeningInterface(InetAddress addressToBind, int portToBind, ProtocolContextFactory<?> contextFactory, boolean reuseAddress) throws IOException Add an interface and port to the listening socket list and provide the protocol context.- Parameters:
addressToBind-portToBind-context-- Throws:
IOException
-
removeListeningInterface
Remove a listening interface from the daemon at runtime.- Parameters:
addressBound-portBound-
-
removeListeningInterface
public void removeListeningInterface(String addressBound, int portBound) throws UnknownHostException Remove a listening interface from the daemon at runtime.- Parameters:
addressBound-portBound-- Throws:
UnknownHostException
-
removeListeningInterface
Deprecated.useremoveListeningInterface(java.lang.String,int)instead.Remove an interface and port from the listening socket list.- Parameters:
String- anInterface- Throws:
IOException
-
getListeningInterfaces
Get the listening socket list.- Returns:
- InetSocketAddress[]
-
getPermanentAcceptThreads
public int getPermanentAcceptThreads()Get the number of permanent accept threads.- Returns:
- int
-
setPermanentAcceptThreads
public void setPermanentAcceptThreads(int permanentAcceptThreads) Set the number of permanent accept threads.An accept thread services the asynchronous server socket by processing requests for connections. Once a connection has been accepted it is then registered with a transfer thread where all IO is handled.
The server maintains this number of permanent threads but will also dynamically create additional threads if the permanent threads are overloaded.
- Parameters:
permanentAcceptThreads-
-
getPermanentConnectThreads
public int getPermanentConnectThreads()Get the number of permanent connect threads.- Returns:
-
setPermanentConnectThreads
public void setPermanentConnectThreads(int permanentConnectThreads) Set the number of permanent connect threads. When existing SSH connections make outgoing socket connections through port forwarding; the asynchronous connection process is handled by these threads. Once the connection has been established the socket is then registered with a transfer thread where all IO is performed.- Parameters:
permanentConnectThreads-
-
getPermanentTransferThreads
public int getPermanentTransferThreads()Get the number of permanent transfer threads.- Returns:
-
setPermanentTransferThreads
public void setPermanentTransferThreads(int permanentTransferThreads) Set the number of permanent transfer threads. Once a socket has either been accepted or connected, the socket is registered with a transfer thread. This thread asynchronously performs all the IO for the socket. If all the permanent threads become fully loaded then additional threads will be created to handle additional connections and shutdown once they have no sockets to service.- Parameters:
permanentAcceptThreads-
-
getMaximumChannelsPerThread
public int getMaximumChannelsPerThread()Get the maximum number of channels that can be serviced by a single selector thread.- Returns:
-
setMaximumChannelsPerThread
public void setMaximumChannelsPerThread(int maximumChannelsPerThread) Set the maximum number of channels that can be serviced by a single selector thread. Setting this value to 1 effectivley gives you a thread-per-connection model.- Parameters:
maximumChannelsPerThread-
-
getIdleServiceRunPeriod
public int getIdleServiceRunPeriod()Get the time in seconds for each idle period service run. For example if this setting is 10 (default) then every 10 seconds an idle service run will be performed. This will process all the current channels on a thread and evaluate whether an idle event should be fired on the channel.- Returns:
- int
-
setIdleServiceRunPeriod
public void setIdleServiceRunPeriod(int idleServicePeriod) - Parameters:
idleServicePeriod- int
-
getInactiveServiceRunsPerIdleEvent
public int getInactiveServiceRunsPerIdleEvent()To determine whether any channels are idle a service run is performed to evaluate the state of each channel. Each time a channel is found to be inactive we flag it. This setting defines how many times it should be flagged consequentivly before an idle event is fired.- Returns:
- int
-
setInactiveServiceRunsPerIdleEvent
public void setInactiveServiceRunsPerIdleEvent(int inactivePeriodsPerIdleEvent) To determine whether any channels are idle a service run is performed to evaluate the state of each channel. Each time a channel is found to be inactive we flag it. This setting defines how many times it should be flagged consequentivly before an idle event is fired.- Parameters:
inactivePeriodsPerIdleEvent- int
-
addEventListener
-
removeEventListener
-
getIpv6WorkaroundPort
public int getIpv6WorkaroundPort() -
setIpv6WorkaroundPort
public void setIpv6WorkaroundPort(int ipv6WorkaroundPort) -
getIpv6WorkaroundBindAddress
-
setIpv6WorkaroundBindAddress
-
setAttribute
-
getAttribute
-
removeListeningInterface(java.lang.String,int)instead.