Class TcpProxyService
- java.lang.Object
-
- org.objectweb.joram.mom.proxies.tcp.TcpProxyService
-
- All Implemented Interfaces:
ConnectionManagerMBean,TcpProxyServiceMBean
- Direct Known Subclasses:
SSLTcpProxyService
public class TcpProxyService extends Object implements TcpProxyServiceMBean
Starts a TCP entry point for MOM clients.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanactivatedprivate Stringaddressprivate intbacklogstatic StringBACKLOG_PROPName the property that allow to fix the TCP BACKLOG property for the client's connections.private static booleancnxWithNoAckedQueueprivate TcpConnectionListener[]connectionListenersThe thread listening to incoming TCP connections.private Vector<TcpConnection>connectionsThe list of opened connectionsprivate static booleanDEBUGstatic intDEFAULT_BACKLOGDefault value for the TCP BACKLOG property.static StringDEFAULT_BINDADDRESSDefault IP address for binding the listen socket.static intDEFAULT_POOL_SIZEDefault value for the pool size.static intDEFAULT_PORTDefault value for the TCP port of the listen socket.static intDEFAULT_SO_TIMEOUTDefault value for the TCP SO_TIMEOUT property.private static ExecutorServiceexecutorServiceprivate static Loggerloggerloggerprivate static StringMBEAN_NAMEstatic StringPOOL_SIZE_PROPName the property that allow to fix the pool size for the connection's listener.private intportprivate static TcpProxyServiceproxyServiceThe proxy service reference (used to stop it).private ServerSocketserverSocketThe server socket listening to connections from the JMS clients.static StringSO_TIMEOUT_PROPName the property that allow to fix the TCP SO_TIMEOUT property for the client's connections.
-
Constructor Summary
Constructors Constructor Description TcpProxyService(int port, int backlog, String address)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()Activates the TcpProxyService (TCP/JMS connector), creates the socket and starts listeners.voidcloseAllConnections()Closes all active connections.static voidcreateExecutors()protected ServerSocketcreateServerSocket(int port, int backlog, String address)Initialize the listening socket.voiddeactivate()Deactivates the TcpProxyService (TCP/JMS connector), stops all listeners.static voidexecute(Runnable command)longgetAverageConnectionTime()Gets the average time for incoming tcp connections.(package private) TcpConnectiongetConnection(AgentId proxyId, int key)intgetFailedLoginCount()Gets the number of failed login.intgetInitiatedConnectionCount()Gets the number of connections initiated since boot time.intgetListenPort()Gets the listen port of the server.StringgetMBeanName()Gets the name of the MBean.intgetProtocolErrorCount()Gets the number of connections rejected due to a wrong protocol header.intgetRunningConnectionsCount()Gets the number of active connections.StringgetServerAddress()Gets the socket address of the server.(package private) ServerSocketgetServerSocket()Gets the listening socket.intgetTcpListenersPoolSize()Gets the number of threads listening for incoming tcp connections.StringgetVersion()Gets the name of the MBean.static voidinit(String args, boolean firstTime)Initializes the TCP entry point by creating a server socket listening to the specified port.booleanisActivated()Returns true if the TcpProxyService (TCP/JMS connector) is started.static booleanisExecutor()(package private) voidregisterConnection(TcpConnection tcpConnection)static voidremoveExecutors()protected voidresetServerSocket()Closes the listening socket and sets the variable to null.protected voidstart()private voidstop()static voidstopService()Stops the service.(package private) voidunregisterConnection(TcpConnection tcpConnection)
-
-
-
Field Detail
-
logger
private static final Logger logger
logger
-
DEBUG
private static final boolean DEBUG
-
SO_TIMEOUT_PROP
public static final String SO_TIMEOUT_PROP
Name the property that allow to fix the TCP SO_TIMEOUT property for the client's connections.- See Also:
- Constant Field Values
-
DEFAULT_SO_TIMEOUT
public static final int DEFAULT_SO_TIMEOUT
Default value for the TCP SO_TIMEOUT property.- See Also:
- Constant Field Values
-
POOL_SIZE_PROP
public static final String POOL_SIZE_PROP
Name the property that allow to fix the pool size for the connection's listener.- See Also:
- Constant Field Values
-
DEFAULT_POOL_SIZE
public static final int DEFAULT_POOL_SIZE
Default value for the pool size.- See Also:
- Constant Field Values
-
BACKLOG_PROP
public static final String BACKLOG_PROP
Name the property that allow to fix the TCP BACKLOG property for the client's connections.- See Also:
- Constant Field Values
-
DEFAULT_BACKLOG
public static final int DEFAULT_BACKLOG
Default value for the TCP BACKLOG property.- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
Default value for the TCP port of the listen socket.- See Also:
- Constant Field Values
-
DEFAULT_BINDADDRESS
public static final String DEFAULT_BINDADDRESS
Default IP address for binding the listen socket.- See Also:
- Constant Field Values
-
MBEAN_NAME
private static final String MBEAN_NAME
- See Also:
- Constant Field Values
-
proxyService
private static TcpProxyService proxyService
The proxy service reference (used to stop it).
-
executorService
private static ExecutorService executorService
-
cnxWithNoAckedQueue
private static boolean cnxWithNoAckedQueue
-
port
private int port
-
backlog
private int backlog
-
address
private String address
-
serverSocket
private ServerSocket serverSocket
The server socket listening to connections from the JMS clients.
-
connections
private Vector<TcpConnection> connections
The list of opened connections
-
connectionListeners
private TcpConnectionListener[] connectionListeners
The thread listening to incoming TCP connections.
-
activated
private boolean activated
-
-
Method Detail
-
isExecutor
public static boolean isExecutor()
-
getServerSocket
ServerSocket getServerSocket()
Gets the listening socket.- Returns:
- the listening socket.
-
resetServerSocket
protected void resetServerSocket()
Closes the listening socket and sets the variable to null.
-
createServerSocket
protected ServerSocket createServerSocket(int port, int backlog, String address) throws Exception
Initialize the listening socket.- Parameters:
port-backlog-address-- Returns:
- The initialized socket.
- Throws:
Exception
-
getVersion
public String getVersion()
Description copied from interface:ConnectionManagerMBeanGets the name of the MBean.- Specified by:
getVersionin interfaceConnectionManagerMBean
-
init
public static void init(String args, boolean firstTime) throws Exception
Initializes the TCP entry point by creating a server socket listening to the specified port.- Parameters:
args- stringified listening portfirstTime-truewhen the agent server starts.- Throws:
Exception
-
stopService
public static void stopService()
Stops the service.
-
start
protected void start()
-
getMBeanName
public String getMBeanName()
Description copied from interface:ConnectionManagerMBeanGets the name of the MBean.- Specified by:
getMBeanNamein interfaceConnectionManagerMBean
-
registerConnection
void registerConnection(TcpConnection tcpConnection)
-
unregisterConnection
void unregisterConnection(TcpConnection tcpConnection)
-
getConnection
TcpConnection getConnection(AgentId proxyId, int key)
-
stop
private void stop()
-
activate
public void activate()
Activates the TcpProxyService (TCP/JMS connector), creates the socket and starts listeners.- Specified by:
activatein interfaceConnectionManagerMBean- Specified by:
activatein interfaceTcpProxyServiceMBean
-
createExecutors
public static void createExecutors()
-
removeExecutors
public static void removeExecutors()
-
execute
public static void execute(Runnable command)
-
closeAllConnections
public void closeAllConnections()
Closes all active connections.- Specified by:
closeAllConnectionsin interfaceConnectionManagerMBean- Specified by:
closeAllConnectionsin interfaceTcpProxyServiceMBean
-
deactivate
public void deactivate()
Deactivates the TcpProxyService (TCP/JMS connector), stops all listeners.- Specified by:
deactivatein interfaceConnectionManagerMBean- Specified by:
deactivatein interfaceTcpProxyServiceMBean
-
isActivated
public boolean isActivated()
Returns true if the TcpProxyService (TCP/JMS connector) is started.- Specified by:
isActivatedin interfaceConnectionManagerMBean- Specified by:
isActivatedin interfaceTcpProxyServiceMBean- Returns:
- true if the TcpProxyService is started.
-
getRunningConnectionsCount
public int getRunningConnectionsCount()
Gets the number of active connections.- Specified by:
getRunningConnectionsCountin interfaceConnectionManagerMBean- Specified by:
getRunningConnectionsCountin interfaceTcpProxyServiceMBean- Returns:
- the number of active connections.
-
getTcpListenersPoolSize
public int getTcpListenersPoolSize()
Gets the number of threads listening for incoming tcp connections.- Specified by:
getTcpListenersPoolSizein interfaceTcpProxyServiceMBean- Returns:
- the tcp listeners pool size.
-
getAverageConnectionTime
public long getAverageConnectionTime()
Gets the average time for incoming tcp connections.- Specified by:
getAverageConnectionTimein interfaceTcpProxyServiceMBean- Returns:
- the average time for incoming tcp connections.
-
getListenPort
public int getListenPort()
Gets the listen port of the server.- Specified by:
getListenPortin interfaceTcpProxyServiceMBean- Returns:
- the listen port of the server.
-
getServerAddress
public String getServerAddress()
Gets the socket address of the server.- Specified by:
getServerAddressin interfaceTcpProxyServiceMBean- Returns:
- the server socket address.
-
getFailedLoginCount
public int getFailedLoginCount()
Gets the number of failed login.- Specified by:
getFailedLoginCountin interfaceConnectionManagerMBean- Specified by:
getFailedLoginCountin interfaceTcpProxyServiceMBean- Returns:
- the number of failed login.
-
getInitiatedConnectionCount
public int getInitiatedConnectionCount()
Gets the number of connections initiated since boot time.- Specified by:
getInitiatedConnectionCountin interfaceConnectionManagerMBean- Specified by:
getInitiatedConnectionCountin interfaceTcpProxyServiceMBean- Returns:
- the number of connections initiated since boot time.
-
getProtocolErrorCount
public int getProtocolErrorCount()
Gets the number of connections rejected due to a wrong protocol header.- Specified by:
getProtocolErrorCountin interfaceTcpProxyServiceMBean- Returns:
- the number of connections rejected due to a wrong protocol header.
-
-