How to get Address of elasticache nodes from Java API?
-
24-06-2021 - |
题
I am making a describeCacheClusters request as follows and get a valid response but the getCacheClusters() method returns null even though that cluster has available nodes. Is there another request I should be using or a missing parameter?
DescribeCacheClustersResult result = awsClient
.describeCacheClusters(new DescribeCacheClustersRequest()
.withCacheClusterId(ELASTICACHE_CLUSTER_ID));
解决方案
You are missing a parameter indeed due to a somewhat confusing API design resp. documentation issue with Amazon ElastiCache:
You need to add setShowCacheNodeInfo() to your DescribeCacheClustersRequest and call getCacheNodes() for each CacheCluster retrieved via getCacheClusters() from the DescribeCacheClustersResult - see my answer to the semantic duplicate Finding AWS ElastiCache endpoints with Java for details and code samples.
不隶属于 StackOverflow