this is the stack trace:
2010-02-10 15:14:10.315 INFO net.spy.memcached.MemcachedConnection:
Connection state changed for sun.nio.ch.SelectionKeyImpl@dd5b
exception: Timeout waiting for value
net.spy.memcached.OperationTimeoutException: Timeout waiting for value
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:853)
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:868)
at com.adxpose.affinity.MemCacheTest.main(MemCacheTest.java:32)
Caused by:
net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out
waiting for operation - failing node: localhost/127.0.0.1:11211
at
net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:
59)
at net.spy.memcached.internal.GetFuture.get(GetFuture.java:37)
at net.spy.memcached.MemcachedClient.get(MemcachedClient.java:846)
... 2 more
OS: Linux 2.6 (Ubuntu 8.04 LTS)
JVM: 1.6 (Java HotSpot(TM) Client VM)
MemCached server: 1.4.4 (compiled from source)
spymemcached: 2.4.2
I found a similar issue posted in an archive that got closed with
2.4.2 of the client. however, I'm using the new client.
I'll attach the two programs.
import net.spy.memcached.MemcachedClient;
import java.net.InetSocketAddress;
import java.util.Random;
import com.mpire.common.ExceptionsUtil;/*
public class MemCacheTest {
public static void main(String[] args) {
MemcachedClient mc = null;
try {
mc = new MemcachedClient(new
InetSocketAddress("localhost", 11211));
Random r = new Random();
final int MAX = 1000000;
for (int i=0; i<MAX; i++) {
mc.set(String.valueOf(i),100,r.nextInt(MAX));
}
for (int i=0; i<MAX; i++) {
Object obj = mc.get(String.valueOf(i));
if (obj != null) {
System.out.println((Integer)obj);
} else System.out.println("undef");
}
} catch (Exception e) {
System.err.println("exception: " + e.getMessage());
e.printStackTrace();
} finally {
if (mc != null) mc.shutdown();
}
}
}
#!/usr/bin/perl
use Cache::Memcached;
$memd = new Cache::Memcached {
'servers' => [ "localhost:11211" ],
};
my $MAX = 1000000;
for (my $i=0; $i<$MAX; $i++){
$n = int(rand($MAX));
$memd->set($i, $n);
}
for (my $i=0; $i<$MAX; $i++){
$n = $memd->get($i);
print defined $n ? "$n\n" : "undef\n";
}