int itemNumber = this.itemNumbersList.remove();
Queue<Session> sessions = this.memcachedClient.getConnector()
.getSessionByAddress(this.inetSocketAddress);
if (sessions == null || sessions.size() == 0) {
throw new MemcachedException(
"The memcached server is not connected,address="
+ this.inetSocketAddress);
}
Session session = sessions.peek();
CountDownLatch latch = new CountDownLatch(1);
if (this.memcachedClient.getProtocol() == Protocol.Text) {
TextCacheDumpCommand textCacheDumpCommand = new TextCacheDumpCommand(
latch, itemNumber);
session.write(textCacheDumpCommand);
if (!latch.await(this.opTimeout, TimeUnit.MILLISECONDS)) {
throw new TimeoutException("stats cachedump timeout");
}
if (textCacheDumpCommand.getException() != null) {
if (textCacheDumpCommand.getException() instanceof MemcachedException) {
throw (MemcachedException) textCacheDumpCommand
.getException();
} else {
throw new MemcachedServerException(textCacheDumpCommand
.getException());
}
}
this.currentKeyList = (LinkedList<String>) textCacheDumpCommand
.getResult();
} else {
throw new MemcachedException(
this.memcachedClient.getProtocol().name()
+ " protocol doesn't support iterating all keys in memcached");
}
return next();
}