我正在尝试使用AutoDiscovery测试亚马逊的新Memcached客户端。我有一个memcached节点,我可以使用XMemcached 1.3.5以及标准的SpyMemcached库连接到该节点。
我按照此处的说明操作:http://docs.amazonwebservices.com/AmazonElastiCache/latest/UserGuide/AutoDiscovery.html
代码几乎与示例相同,并且是:
String configEndpoint = "<server name>.rgcl8z.cfg.use1.cache.amazonaws.com";
Integer clusterPort = 11211;
MemcachedClient client = new MemcachedClient(new InetSocketAddress(configEndpoint, clusterPort));
client.set("theKey", 3600, "This is the data value");
创建连接时,我在日志中看到以下内容。当我尝试设置值时发生错误:
2013-01-04 22:05:30.445 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/<ip>:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2013-01-04 22:05:32.861 INFO net.spy.memcached.ConfigurationPoller: Starting configuration poller.
2013-01-04 22:05:32.861 INFO net.spy.memcached.ConfigurationPoller: Endpoint to use for configuration access in this poll NodeEndPoint - HostName:<our-server>.rgcl8z.cfg.use1.cache.amazonaws.com IpAddress:<ip> Port:11211
2013-01-04 22:05:32.950 WARN net.spy.memcached.MemcachedClient: Configuration endpoint timed out for config call. Leaving the initialization work to configuration poller.
Exception in thread "main" java.lang.IllegalStateException: Client is not initialized
at net.spy.memcached.MemcachedClient.checkState(MemcachedClient.java:1623)
at net.spy.memcached.MemcachedClient.enqueueOperation(MemcachedClient.java:1617)
at net.spy.memcached.MemcachedClient.asyncStore(MemcachedClient.java:474)
at net.spy.memcached.MemcachedClient.set(MemcachedClient.java:905)
at com.thinknear.venice.initializers.VeniceAssets.main(VeniceAssets.java:227)
有关为什么配置端点超时的想法?
答案 0 :(得分:8)
客户端未初始化: 你不能通过你的本地机器直接连接亚马逊弹性缓存节点你只能通过ec2 machiene访问它。如果你想检查你可以从你的本地机器telnet它不会连接我也同样的问题。你可以从您的Ec2机器上telnet它。所以在ec2机器上尝试你的代码它会起作用。
答案 1 :(得分:0)
在memcache服务器上执行telnet以检查连接性,在我的情况下,它未列出,因此无法建立连接, 通过将我的服务器列入memcache来解决问题。