/** * Get the AWS account id where an ASG is created. * Warning: This is expensive as it loops through all instances currently registered. * * @param asgName The name of the ASG * @return the account id */ private String getASGAccount(String asgName) { Applications apps = registry.getApplicationsFromLocalRegionOnly(); for (Application app : apps.getRegisteredApplications()) { for (InstanceInfo instanceInfo : app.getInstances()) { String thisAsgName = instanceInfo.getASGName(); if (thisAsgName != null && thisAsgName.equals(asgName)) { String localAccountId = getAccountId(instanceInfo, null); if (localAccountId != null) { return localAccountId; } } } } logger.info("Couldn't get the ASG account for {}, using the default accountId instead", asgName); return accountId; }
/** * Get the cacheKeys of all the ASG to which query AWS for. * * <p> * The names are obtained from the {@link com.netflix.eureka.registry.InstanceRegistry} which is then * used for querying the AWS. * </p> * * @return the set of ASG cacheKeys (asgName + accountId). */ private Set<CacheKey> getCacheKeys() { Set<CacheKey> cacheKeys = new HashSet<CacheKey>(); Applications apps = registry.getApplicationsFromLocalRegionOnly(); for (Application app : apps.getRegisteredApplications()) { for (InstanceInfo instanceInfo : app.getInstances()) { String localAccountId = getAccountId(instanceInfo, accountId); String asgName = instanceInfo.getASGName(); if (asgName != null) { CacheKey key = new CacheKey(localAccountId, asgName); cacheKeys.add(key); } } } return cacheKeys; }
/** * Get the AWS account id where an ASG is created. * Warning: This is expensive as it loops through all instances currently registered. * * @param asgName The name of the ASG * @return the account id */ private String getASGAccount(String asgName) { Applications apps = registry.getApplicationsFromLocalRegionOnly(); for (Application app : apps.getRegisteredApplications()) { for (InstanceInfo instanceInfo : app.getInstances()) { String thisAsgName = instanceInfo.getASGName(); if (thisAsgName != null && thisAsgName.equals(asgName)) { String localAccountId = getAccountId(instanceInfo, null); if (localAccountId != null) { return localAccountId; } } } } logger.info("Couldn't get the ASG account for {}, using the default accountId instead", asgName); return accountId; }
/** * Get the cacheKeys of all the ASG to which query AWS for. * * <p> * The names are obtained from the {@link com.netflix.eureka.registry.InstanceRegistry} which is then * used for querying the AWS. * </p> * * @return the set of ASG cacheKeys (asgName + accountId). */ private Set<CacheKey> getCacheKeys() { Set<CacheKey> cacheKeys = new HashSet<CacheKey>(); Applications apps = registry.getApplicationsFromLocalRegionOnly(); for (Application app : apps.getRegisteredApplications()) { for (InstanceInfo instanceInfo : app.getInstances()) { String localAccountId = getAccountId(instanceInfo, accountId); String asgName = instanceInfo.getASGName(); if (asgName != null) { CacheKey key = new CacheKey(localAccountId, asgName); cacheKeys.add(key); } } } return cacheKeys; }