public class TcpConnection extends Object implements TcpConnectionMBean, ProxyMessageSender
UserConnection
in order to invoke the user's proxy and get
its replies.TcpProxyService
,
TcpConnectionListener
Modifier and Type | Field and Description |
---|---|
private boolean |
closeConnection |
private Date |
creationDate |
private ReliableConnectionContext |
ctx |
private Identity |
identity |
private IOControl |
ioctrl |
static Logger |
logger
logger
|
private AgentId |
proxyId |
private TcpProxyService |
proxyService
The TCP proxy service used to register and unregister this connection.
|
private TcpReader |
tcpReader
The reader thread responsible for reading the requests (input).
|
private TcpWriter |
tcpWriter
The writer thread responsible for writing the replies (output).
|
Constructor and Description |
---|
TcpConnection(IOControl ioctrl,
ReliableConnectionContext ctx,
AgentId proxyId,
TcpProxyService proxyService,
Identity identity)
Creates a new TCP connection.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Stops the connection reader and
writer threads.
|
void |
execute(Runnable runnable)
Executes a task.
|
int |
getAckedQueueSize()
Gets the AckedQueue size.
|
String |
getAddress()
Gets the socket address used by the connection.
|
Date |
getCreationDate()
Gets connection creation date.
|
int |
getKey() |
private String |
getMBeanName() |
AgentId |
getProxyId() |
int |
getQueueWorkerSize()
Gets the QueueWorker size.
|
int |
getReaderQueueSize()
Gets the ReaderQueue size.
|
long |
getReceivedCount()
Gets the number of replies received on the connection.
|
long |
getSentCount()
Gets the number of requests sent on the connection.
|
String |
getUserName()
Gets connected user's name.
|
boolean |
isExecutor()
States whether executing a task is allowed.
|
void |
send(ProxyMessage msg)
Sends a message to the client.
|
(package private) void |
start()
Starts the connection reader and writer threads.
|
public static Logger logger
private IOControl ioctrl
private AgentId proxyId
private ReliableConnectionContext ctx
private TcpReader tcpReader
private TcpWriter tcpWriter
private TcpProxyService proxyService
private boolean closeConnection
private Identity identity
private Date creationDate
public TcpConnection(IOControl ioctrl, ReliableConnectionContext ctx, AgentId proxyId, TcpProxyService proxyService, Identity identity)
ioctrl
- ctx
- proxyId
- proxyService
- the TCP proxy serviceidentity
- private String getMBeanName()
public final AgentId getProxyId()
public final int getKey()
void start() throws Exception
Exception
public void close()
close
in interface ProxyMessageSender
close
in interface TcpConnectionMBean
public String getUserName()
TcpConnectionMBean
getUserName
in interface TcpConnectionMBean
public String getAddress()
TcpConnectionMBean
getAddress
in interface TcpConnectionMBean
public Date getCreationDate()
TcpConnectionMBean
getCreationDate
in interface TcpConnectionMBean
public long getReceivedCount()
TcpConnectionMBean
getReceivedCount
in interface TcpConnectionMBean
public long getSentCount()
TcpConnectionMBean
getSentCount
in interface TcpConnectionMBean
public int getAckedQueueSize()
TcpConnectionMBean
getAckedQueueSize
in interface TcpConnectionMBean
public int getQueueWorkerSize()
TcpConnectionMBean
getQueueWorkerSize
in interface TcpConnectionMBean
public int getReaderQueueSize()
TcpConnectionMBean
getReaderQueueSize
in interface TcpConnectionMBean
public void send(ProxyMessage msg) throws Exception
ProxyMessageSender
send
in interface ProxyMessageSender
msg
- the message to be sentException
- if an error occurspublic boolean isExecutor()
ProxyMessageSender
isExecutor
in interface ProxyMessageSender
true
if executing a task is allowed;
false
otherwise.public void execute(Runnable runnable)
ProxyMessageSender
execute
in interface ProxyMessageSender
runnable
- task to be executedCopyright © 2022 ScalAgent D.T.. All rights reserved.