Send cluster messages with a pool of sockets (25).
FIXME support processing stats
| Method from org.apache.catalina.cluster.tcp.PooledSocketSender Detail: |
public synchronized void connect() throws IOException {
//do nothing, happens in the socket sender itself
senderQueue.open();
setSocketConnected(true);
connectCounter++;
}
|
public synchronized void disconnect() {
senderQueue.close();
setSocketConnected(false);
disconnectCounter++;
}
|
public int getInPoolSize() {
return senderQueue.getInPoolSize();
}
|
public int getInUsePoolSize() {
return senderQueue.getInUsePoolSize();
}
|
public String getInfo() {
return (info);
}
Return descriptive information about this implementation and the
corresponding version number, in the format
<description>/<version>. |
public int getMaxPoolSocketLimit() {
return maxPoolSocketLimit;
}
|
public void sendMessage(ClusterData data) throws IOException {
//get a socket sender from the pool
if(!isConnected()) {
synchronized(this) {
if(!isConnected())
connect();
}
}
SocketSender sender = senderQueue.getSender(0);
if (sender == null) {
log.warn(sm.getString("PoolSocketSender.noMoreSender", this.getAddress(), new Integer(this.getPort())));
return;
}
//send the message
try {
sender.sendMessage(data);
} finally {
//return the connection to the pool
senderQueue.returnSender(sender);
}
addStats(data.getMessage().length);
}
send message and use a pool of SocketSenders |
public void setMaxPoolSocketLimit(int limit) {
maxPoolSocketLimit = limit;
senderQueue.setLimit(limit);
}
|
public String toString() {
StringBuffer buf = new StringBuffer("PooledSocketSender[");
buf.append(getAddress()).append(":").append(getPort()).append("]");
return buf.toString();
}
|