List of usage examples for com.amazonaws.services.elasticache.model CacheCluster getCacheClusterStatus
public String getCacheClusterStatus()
The current state of this cluster, one of the following values: available
, creating
, deleted
, deleting
, incompatible-network
, modifying
, rebooting cluster nodes
, restore-failed
, or snapshotting
.
From source file:org.springframework.cloud.aws.cache.ElastiCacheFactoryBean.java
License:Apache License
@Override protected Cache createInstance() throws Exception { DescribeCacheClustersRequest describeCacheClustersRequest = new DescribeCacheClustersRequest() .withCacheClusterId(getCacheClusterName()); describeCacheClustersRequest.setShowCacheNodeInfo(true); DescribeCacheClustersResult describeCacheClustersResult = this.amazonElastiCache .describeCacheClusters(describeCacheClustersRequest); CacheCluster cacheCluster = describeCacheClustersResult.getCacheClusters().get(0); if (!"available".equals(cacheCluster.getCacheClusterStatus())) { LOGGER.warn(/*from www .j a v a2 s.co m*/ "Cache cluster is not available now. Connection may fail during cache access. Current status is {}", cacheCluster.getCacheClusterStatus()); } Endpoint configurationEndpoint = getEndpointForCache(cacheCluster); for (CacheFactory cacheFactory : this.cacheFactories) { if (cacheFactory.isSupportingCacheArchitecture(cacheCluster.getEngine())) { return cacheFactory.createCache(this.cacheClusterId, configurationEndpoint.getAddress(), configurationEndpoint.getPort()); } } throw new IllegalArgumentException("No CacheFactory configured for engine: " + cacheCluster.getEngine()); }
From source file:org.springframework.cloud.aws.cache.ElastiCacheMemcachedFactoryBean.java
License:Apache License
@Override protected MemcachedClient createInstance() throws Exception { DescribeCacheClustersResult describeCacheClustersResult = this.amazonElastiCache.describeCacheClusters( new DescribeCacheClustersRequest().withCacheClusterId(getCacheClusterName())); CacheCluster cacheCluster = describeCacheClustersResult.getCacheClusters().get(0); if (!"available".equals(cacheCluster.getCacheClusterStatus())) { LOGGER.warn(//from ww w . jav a 2 s .c o m "Cache cluster is not available now. Connection may fail during cache access. Current status is {}", cacheCluster.getCacheClusterStatus()); } if (!"memcached".equals(cacheCluster.getEngine())) { throw new IllegalStateException("Currently only memcached is supported as the cache cluster engine"); } Endpoint configurationEndpoint = cacheCluster.getConfigurationEndpoint(); // We return every time one configuration endpoint. The amazon memcached client will connect to all nodes. return new MemcachedClient( new InetSocketAddress(configurationEndpoint.getAddress(), configurationEndpoint.getPort())); }