I'm having trouble getting / set for an ElastiCache cluster from my EC2 instance. I get - SEVERE: net.spy.memcached.OperationTimeoutException: Timeout waiting for value - error.
When I try to get or set a value. I used the same code on my local machine (although I communicated with the local memcached server) and everything works fine. The full stack can be found here - http://pastebin.com/tYcCJ6cj
At first I saw that I can at least get the IP address of all the nodes in the cluster so that I can forward it to my membase client, and I can really find out the IP addresses of the node. I also made sure that all my EC2 security groups are added to the cluster security group by default.
Any pointers to this would be very helpful.
UPDATE
A snippet of code used to retrieve a specific entry.
public String getCachedValue(String namespace, String key) { String value = null; try { MemcachedClient client = CacheConnectionUtil.connectToElastiCacheMemcachedServer();
Code snippet used to connect to ElastiCache server
private static MemcachedClient connectToElastiCacheMemcachedServer() throws IOException { DescribeCacheClustersResult cacheClustersInfo = null; DescribeCacheClustersRequest cacheClusterRequest = new DescribeCacheClustersRequest(); cacheClusterRequest.setShowCacheNodeInfo(true); try { cacheClustersInfo = AWSConnectionUtil .getElastiCacheObject(null) .describeCacheClusters(cacheClusterRequest); } catch (Exception e) { e.printStackTrace(); throw new IOException("Unable to connect to ElastiCache Cluster.", e); } if (cacheClustersInfo == null) { throw new IOException("ElastiCache Cluster Info Object is null."); } List<CacheCluster> clusters = cacheClustersInfo.getCacheClusters(); if (clusters == null || clusters.isEmpty()) { throw new IOException("No ElastiCache Clusters available."); } List<String> serverList = new ArrayList<String>(); for (CacheCluster cluster : clusters) { if (cluster != null && AWSConstants .CACHE_CLUSTER_ID .equalsIgnoreCase(cluster.getCacheClusterId())) { List<CacheNode> nodes = cluster.getCacheNodes(); if (nodes != null ) { for (CacheNode node : nodes) { if (node != null) { Endpoint endpoint = node.getEndpoint(); if (endpoint != null && endpoint.getAddress() != null) { serverList.add(endpoint.getAddress() + ":" + endpoint.getPort()); } } } } } } if (serverList.isEmpty()) { throw new IOException("No Cached nodes available for cluster - " + AWSConstants.CACHE_CLUSTER_ID); } return new MemcachedClient(AddrUtil.getAddresses(serverList)); }
source share