}
private final Random random = new Random();
public void send(final Command msg) throws MemcachedException {
MemcachedSession session = (MemcachedSession) this
.findSessionByKey(msg.getKey());
if (session == null) {
throw new MemcachedException(
"There is no available connection at this moment");
}
// If session was closed,try to use standby memcached node
if (session.isClosed()) {
session = this.findStandbySession(session);
}
if (session.isClosed()) {
throw new MemcachedException("Session("
+ SystemUtils.getRawAddress(session
.getRemoteSocketAddress()) + ":"
+ session.getRemoteSocketAddress().getPort()
+ ") has been closed");
}
if (session.isAuthFailed()) {
throw new MemcachedException("Auth failed to connection "
+ session.getRemoteSocketAddress());
}
session.write(msg);
}