Send cluster messages from a Message queue with only one socket. Ack and keep
Alive Handling is supported.
| Method from org.apache.catalina.cluster.tcp.AsyncSocketSender Detail: |
protected void checkThread() {
if (queueThread == null) {
if (log.isInfoEnabled())
log.info(sm.getString("AsyncSocketSender.create.thread",
getAddress(), new Integer(getPort())));
queueThread = new QueueThread(this);
queueThread.setDaemon(true);
queueThread.start();
}
}
Start Queue thread as daemon |
public void connect() throws IOException {
super.connect();
checkThread();
}
|
public void disconnect() {
stopThread();
super.disconnect();
}
Disconnect socket ad stop queue thread |
public long getInQueueCounter() {
return inQueueCounter;
}
|
public String getInfo() {
return (info);
}
Return descriptive information about this implementation and the
corresponding version number, in the format
<description>/<version>. |
public long getOutQueueCounter() {
return outQueueCounter;
}
|
public int getQueueSize() {
return queue.size();
}
|
public long getQueuedNrOfBytes() {
if(queueThread != null)
return queueThread.getQueuedNrOfBytes();
return 0l ;
}
|
public synchronized void resetStatistics() {
super.resetStatistics();
inQueueCounter = queue.size();
outQueueCounter = 0;
}
|
public void sendMessage(ClusterData data) throws IOException {
SmartQueue.SmartEntry entry = new SmartQueue.SmartEntry(data.getUniqueId(), data);
queue.add(entry);
synchronized (this) {
inQueueCounter++;
if(queueThread != null)
queueThread.incQueuedNrOfBytes(data.getMessage().length);
}
if (log.isTraceEnabled())
log.trace(sm.getString("AsyncSocketSender.queue.message",
getAddress().getHostAddress(), new Integer(getPort()), data.getUniqueId(), new Long(
data.getMessage().length)));
}
Send message to queue for later sending |
protected void stopThread() {
if (queueThread != null) {
queueThread.stopRunning();
queueThread = null;
}
}
|
public String toString() {
StringBuffer buf = new StringBuffer("AsyncSocketSender[");
buf.append(getAddress().getHostAddress()).append(":").append(getPort()).append("]");
return buf.toString();
}
Name of this SockerSender |