public class AutoTcpTransportServer extends TcpTransportServer
TransportServer
Modifier and Type | Class and Description |
---|---|
protected class |
AutoTcpTransportServer.ProtocolInfo |
TcpTransportServer.TransportInfo
Modifier and Type | Field and 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 |
allowLinkStealing, backlog, connectionTimeout, currentTransportCount, dynamicManagement, jmxPort, logWriterName, maximumConnections, maxInactivityDuration, maxInactivityDurationInitalDelay, minmumWireFormatVersion, selector, serverSocket, serverSocketFactory, socketBufferSize, socketHandlerThread, socketQueue, soTimeout, startLogging, trace, transportFactory, useQueueForAccept, verifyHostName, wireFormatFactory
transportOptions
Constructor and Description |
---|
AutoTcpTransportServer(TcpTransportFactory transportFactory,
URI location,
ServerSocketFactory serverSocketFactory,
BrokerService brokerService,
Set<String> enabledProtocols) |
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
getStackSize, isDaemon, isJoinOnStop, setDaemon, setJoinOnStop, setStackSize
getAcceptListener, getBindLocation, getConnectURI, onAcceptError, setAcceptListener, setBindLocation, setConnectURI, setTransportOption
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
protected Map<String,Object> autoTransportOptions
protected Set<String> enabledProtocols
protected final Map<String,ProtocolVerifier> protocolVerifiers
protected BrokerService brokerService
protected final ThreadPoolExecutor newConnectionExecutor
protected final ThreadPoolExecutor protocolDetectionExecutor
protected int maxConnectionThreadPoolSize
protected int protocolDetectionTimeOut
public AutoTcpTransportServer(TcpTransportFactory transportFactory, URI location, ServerSocketFactory serverSocketFactory, BrokerService brokerService, Set<String> enabledProtocols) throws IOException, URISyntaxException
transportFactory
- location
- serverSocketFactory
- IOException
URISyntaxException
public WireFormatFactory findWireFormatFactory(String scheme, Map<String,Map<String,Object>> options) throws IOException
IOException
public TransportFactory findTransportFactory(String scheme, Map<String,?> options) throws IOException
IOException
public int getMaxConnectionThreadPoolSize()
public void setMaxConnectionThreadPoolSize(int maxConnectionThreadPoolSize)
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.
maxConnectionThreadPoolSize
- TcpTransportServer#setMaximumConnections(int)}.
public void setProtocolDetectionTimeOut(int protocolDetectionTimeOut)
public void setWireFormatFactory(WireFormatFactory factory)
setWireFormatFactory
in class TcpTransportServer
factory
- The wireFormatFactory to set.protected void initProtocolVerifiers()
protected void initOpenWireProtocolVerifier()
protected boolean isAllProtocols()
protected void handleSocket(Socket socket)
handleSocket
in class TcpTransportServer
protected TcpTransportServer.TransportInfo configureTransport(TcpTransportServer server, Socket socket) throws Exception
configureTransport
in class TcpTransportServer
Exception
protected void waitForProtocolDetectionFinish(Future<?> future, AtomicInteger readBytes) throws Exception
Exception
protected TcpTransport createTransport(Socket socket, WireFormat format, TcpTransportFactory detectedTransportFactory, TcpTransport.InitBuffer initBuffer) throws IOException
socket
- format
- detectedTransportFactory
- IOException
public void setWireFormatOptions(Map<String,Map<String,Object>> wireFormatOptions)
public void setEnabledProtocols(Set<String> enabledProtocols)
public void setAutoTransportOptions(Map<String,Object> autoTransportOptions)
protected void doStop(ServiceStopper stopper) throws Exception
doStop
in class TcpTransportServer
Exception
protected AutoTcpTransportServer.ProtocolInfo detectProtocol(byte[] buffer) throws IOException
IOException
Copyright © 2005–2019 The Apache Software Foundation. All rights reserved.