Class AutoTcpTransportServer
- java.lang.Object
-
- org.apache.activemq.util.ServiceSupport
-
- org.apache.activemq.transport.TransportServerSupport
-
- org.apache.activemq.transport.TransportServerThreadSupport
-
- org.apache.activemq.transport.tcp.TcpTransportServer
-
- org.apache.activemq.transport.auto.AutoTcpTransportServer
-
- All Implemented Interfaces:
Runnable
,Service
,TransportServer
,ServiceListener
- Direct Known Subclasses:
AutoNIOSSLTransportServer
,AutoSslTransportServer
public class AutoTcpTransportServer extends TcpTransportServer
A TCP based implementation ofTransportServer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AutoTcpTransportServer.ProtocolInfo
-
Nested classes/interfaces inherited from class org.apache.activemq.transport.tcp.TcpTransportServer
TcpTransportServer.TransportInfo
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>
autoTransportOptions
protected BrokerService
brokerService
protected Set<String>
enabledProtocols
protected int
maxConnectionThreadPoolSize
protected ThreadPoolExecutor
newConnectionExecutor
protected ThreadPoolExecutor
protocolDetectionExecutor
protected int
protocolDetectionTimeOut
protected Map<String,ProtocolVerifier>
protocolVerifiers
protected Map<String,Map<String,Object>>
wireFormatOptions
-
Fields inherited from class org.apache.activemq.transport.tcp.TcpTransportServer
allowLinkStealing, backlog, connectionTimeout, currentTransportCount, dynamicManagement, jmxPort, logWriterName, maximumConnections, maxInactivityDuration, maxInactivityDurationInitalDelay, minmumWireFormatVersion, selector, serverSocket, serverSocketFactory, socketBufferSize, socketHandlerThread, socketQueue, soTimeout, startLogging, trace, transportFactory, useQueueForAccept, verifyHostName, wireFormatFactory
-
Fields inherited from class org.apache.activemq.transport.TransportServerSupport
transportOptions
-
-
Constructor Summary
Constructors Constructor Description AutoTcpTransportServer(TcpTransportFactory transportFactory, URI location, ServerSocketFactory serverSocketFactory, BrokerService brokerService, Set<String> enabledProtocols)
-
Method Summary
-
Methods inherited from class org.apache.activemq.transport.tcp.TcpTransportServer
bind, createTransport, doHandleSocket, doStart, getBacklog, getConnectionTimeout, getCurrentTransportCount, getJmxPort, getLogWriterName, getMaximumConnections, getMaxInactivityDuration, getMaxInactivityDurationInitalDelay, getMinmumWireFormatVersion, getSocketAddress, getSocketBufferSize, getSoTimeout, getWireFormatFactory, isAllowLinkStealing, isDynamicManagement, isSslServer, isStartLogging, isTrace, isUseQueueForAccept, resolveHostName, run, setAllowLinkStealing, setBacklog, setBrokerInfo, setConnectionTimeout, setDynamicManagement, setJmxPort, setLogWriterName, setMaximumConnections, setMaxInactivityDuration, setMaxInactivityDurationInitalDelay, setMinmumWireFormatVersion, setSocketBufferSize, setSoTimeout, setStartLogging, setTrace, setUseQueueForAccept, started, stopped, toString
-
Methods inherited from class org.apache.activemq.transport.TransportServerThreadSupport
getStackSize, isDaemon, isJoinOnStop, setDaemon, setJoinOnStop, setStackSize
-
Methods inherited from class org.apache.activemq.transport.TransportServerSupport
getAcceptListener, getBindLocation, getConnectURI, onAcceptError, setAcceptListener, setBindLocation, setConnectURI, setTransportOption
-
Methods inherited from class org.apache.activemq.util.ServiceSupport
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
-
-
-
-
Field Detail
-
protocolVerifiers
protected final Map<String,ProtocolVerifier> protocolVerifiers
-
brokerService
protected BrokerService brokerService
-
newConnectionExecutor
protected final ThreadPoolExecutor newConnectionExecutor
-
protocolDetectionExecutor
protected final ThreadPoolExecutor protocolDetectionExecutor
-
maxConnectionThreadPoolSize
protected int maxConnectionThreadPoolSize
-
protocolDetectionTimeOut
protected int protocolDetectionTimeOut
-
-
Constructor Detail
-
AutoTcpTransportServer
public AutoTcpTransportServer(TcpTransportFactory transportFactory, URI location, ServerSocketFactory serverSocketFactory, BrokerService brokerService, Set<String> enabledProtocols) throws IOException, URISyntaxException
- Parameters:
transportFactory
-location
-serverSocketFactory
-- Throws:
IOException
URISyntaxException
-
-
Method Detail
-
findWireFormatFactory
public WireFormatFactory findWireFormatFactory(String scheme, Map<String,Map<String,Object>> options) throws IOException
- Throws:
IOException
-
findTransportFactory
public TransportFactory findTransportFactory(String scheme, Map<String,?> options) throws IOException
- Throws:
IOException
-
getMaxConnectionThreadPoolSize
public int getMaxConnectionThreadPoolSize()
-
setMaxConnectionThreadPoolSize
public void setMaxConnectionThreadPoolSize(int maxConnectionThreadPoolSize)
Set the number of threads to be used for processing connections. Defaults to Integer.MAX_SIZE. Set this value to be lower to reduce the number of simultaneous connection attempts. If not set then the maximum number of threads will generally be controlled by the transport maxConnections setting:TcpTransportServer.setMaximumConnections(int)
.Note that this setter controls two thread pools because connection attempts require 1 thread to start processing the connection and another thread to read from the socket and to detect the protocol. Two threads are needed because some transports block on socket read so the first thread needs to be able to abort the second thread on timeout. Therefore this setting will set each thread pool to the size passed in essentially giving 2 times as many potential threads as the value set.
Both thread pools will close idle threads after a period of time essentially allowing the thread pools to grow and shrink dynamically based on load.
- Parameters:
maxConnectionThreadPoolSize
-
-
setProtocolDetectionTimeOut
public void setProtocolDetectionTimeOut(int protocolDetectionTimeOut)
-
setWireFormatFactory
public void setWireFormatFactory(WireFormatFactory factory)
- Overrides:
setWireFormatFactory
in classTcpTransportServer
- Parameters:
factory
- The wireFormatFactory to set.
-
initProtocolVerifiers
protected void initProtocolVerifiers()
-
initOpenWireProtocolVerifier
protected void initOpenWireProtocolVerifier()
-
isAllProtocols
protected boolean isAllProtocols()
-
handleSocket
protected void handleSocket(Socket socket)
- Overrides:
handleSocket
in classTcpTransportServer
-
configureTransport
protected TcpTransportServer.TransportInfo configureTransport(TcpTransportServer server, Socket socket) throws Exception
- Overrides:
configureTransport
in classTcpTransportServer
- Throws:
Exception
-
waitForProtocolDetectionFinish
protected void waitForProtocolDetectionFinish(Future<?> future, AtomicInteger readBytes) throws Exception
- Throws:
Exception
-
createTransport
protected TcpTransport createTransport(Socket socket, WireFormat format, TcpTransportFactory detectedTransportFactory, TcpTransport.InitBuffer initBuffer) throws IOException
- Parameters:
socket
-format
-detectedTransportFactory
-- Returns:
- Throws:
IOException
-
setWireFormatOptions
public void setWireFormatOptions(Map<String,Map<String,Object>> wireFormatOptions)
-
setAutoTransportOptions
public void setAutoTransportOptions(Map<String,Object> autoTransportOptions)
-
doStop
protected void doStop(ServiceStopper stopper) throws Exception
- Overrides:
doStop
in classTcpTransportServer
- Throws:
Exception
-
detectProtocol
protected AutoTcpTransportServer.ProtocolInfo detectProtocol(byte[] buffer) throws IOException
- Throws:
IOException
-
-