У меня проблемы с получением / настройкой кластера ElastiCache из моего экземпляра EC2. Я получаю - СЕРЬЕЗНО: net.spy.memcached.OperationTimeoutException: Тайм-аут ожидания значения
- ошибка.
Когда я пытаюсь получить или установить значение. Я использовал тот же код на своем локальном компьютере (хотя и общался с локальным сервером memcached), и все работает нормально.Полную трассировку стека можно найти здесь - http://pastebin.com/tYcCJ6cj
Я впервые увидел, что могу по крайней мере получить IP-адреса всех узлов кластера, чтобы передать его в мой клиент мембраны, и я действительно могу узнать IP-адреса узла. Я также убедился, что все мои группы безопасности EC2 также добавлены в группу безопасности кластера кэша по умолчанию.
Любые указания по этому поводу будут очень полезны.
ОБНОВЛЕНИЕ
Фрагмент кода, используемый для получения определенной записи.
public String getCachedValue(String namespace, String key) {
String value = null;
try {
MemcachedClient client
= CacheConnectionUtil.connectToElastiCacheMemcachedServer();
// Point of origin for the exception.
return (String) client.get(namespace + "$" + hashKey(key));
} catch (IOException e) {
e.printStackTrace();
}
return value;
}
Фрагмент кода, используемый для подключения к серверу ElastiCache
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 clusters = cacheClustersInfo.getCacheClusters();
if (clusters == null || clusters.isEmpty()) {
throw new IOException("No ElastiCache Clusters available.");
}
List serverList = new ArrayList();
for (CacheCluster cluster : clusters) {
if (cluster != null
&& AWSConstants
.CACHE_CLUSTER_ID
.equalsIgnoreCase(cluster.getCacheClusterId())) {
List 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));
}