Example usage for com.amazonaws.services.ecs.model Service getClusterArn

List of usage examples for com.amazonaws.services.ecs.model Service getClusterArn

Introduction

In this page you can find the example usage for com.amazonaws.services.ecs.model Service getClusterArn.

Prototype


public String getClusterArn() 

Source Link

Document

The Amazon Resource Name (ARN) of the cluster that hosts the service.

Usage

From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.ServiceCachingAgent.java

License:Apache License

public static Map<String, Object> convertServiceToAttributes(String accountName, String region,
        Service service) {
    Map<String, Object> attributes = new HashMap<>();
    String applicationName = service.getServiceName().contains("-")
            ? StringUtils.substringBefore(service.getServiceName(), "-")
            : service.getServiceName();/*from  w  ww. j a va  2 s  .  c  o  m*/
    String clusterName = StringUtils.substringAfterLast(service.getClusterArn(), "/");

    attributes.put("account", accountName);
    attributes.put("region", region);
    attributes.put("applicationName", applicationName);
    attributes.put("serviceName", service.getServiceName());
    attributes.put("serviceArn", service.getServiceArn());
    attributes.put("clusterName", clusterName);
    attributes.put("clusterArn", service.getClusterArn());
    attributes.put("roleArn", service.getRoleArn());
    attributes.put("taskDefinition", service.getTaskDefinition());
    attributes.put("desiredCount", service.getDesiredCount());
    attributes.put("maximumPercent", service.getDeploymentConfiguration().getMaximumPercent());
    attributes.put("minimumHealthyPercent", service.getDeploymentConfiguration().getMinimumHealthyPercent());
    attributes.put("loadBalancers", service.getLoadBalancers());
    attributes.put("createdAt", service.getCreatedAt().getTime());

    return attributes;
}

From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.ServiceCachingAgent.java

License:Apache License

@Override
protected Map<String, Collection<CacheData>> generateFreshData(Collection<Service> services) {
    Collection<CacheData> dataPoints = new LinkedList<>();
    Map<String, CacheData> clusterDataPoints = new HashMap<>();

    for (Service service : services) {
        Map<String, Object> attributes = convertServiceToAttributes(accountName, region, service);

        String key = Keys.getServiceKey(accountName, region, service.getServiceName());
        dataPoints.add(new DefaultCacheData(key, attributes, Collections.emptyMap()));

        Map<String, Object> clusterAttributes = EcsClusterCachingAgent
                .convertClusterArnToAttributes(accountName, region, service.getClusterArn());
        String clusterName = StringUtils.substringAfterLast(service.getClusterArn(), "/");
        key = Keys.getClusterKey(accountName, region, clusterName);
        clusterDataPoints.put(key, new DefaultCacheData(key, clusterAttributes, Collections.emptyMap()));
    }//from  ww w  .ja  v a 2  s  .  c  o m

    log.info("Caching " + dataPoints.size() + " services in " + getAgentType());
    Map<String, Collection<CacheData>> dataMap = new HashMap<>();
    dataMap.put(SERVICES.toString(), dataPoints);

    log.info("Caching " + clusterDataPoints.size() + " ECS clusters in " + getAgentType());
    dataMap.put(ECS_CLUSTERS.toString(), clusterDataPoints.values());

    return dataMap;
}