我正在尝试使用 AutoDiscovery 测试 Amazon 的新 Memcached 客户端。我有一个可以使用 XMemcached 1.3.5 以及标准 SpyMemcached 库连接到的 memcached 节点。
我按照此处的说明进行操作: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)
关于为什么配置端点会超时的任何想法?
最佳答案
客户端未初始化: 你不能通过你的本地机器直接连接到亚马逊弹性缓存节点,你只能通过你的 ec2 机器访问它。如果你想检查你可以从你的本地机器远程登录它不会连接我也遇到了同样的问题。你可以从您的 Ec2 机器远程登录它。所以在 ec2 机器上尝试您的代码它会工作。
关于java - Amazon Elasticache Auto Discovery - 客户端未初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14169189/