Beispiel #1
0
  /**
   * Describe a set of specific auto-scaling instances.
   *
   * @param instanceIds the instance ids
   * @return the instances
   */
  public List<AutoScalingInstanceDetails> describeAutoScalingInstances(String... instanceIds) {
    if (instanceIds == null || instanceIds.length == 0) {
      LOGGER.info("Getting all auto-scaling instances.");
    } else {
      LOGGER.info(String.format("Getting auto-scaling instances for %d ids.", instanceIds.length));
    }

    List<AutoScalingInstanceDetails> instances = new LinkedList<AutoScalingInstanceDetails>();

    AmazonAutoScalingClient asgClient = asgClient();
    DescribeAutoScalingInstancesRequest request = new DescribeAutoScalingInstancesRequest();
    if (instanceIds != null) {
      request.setInstanceIds(Arrays.asList(instanceIds));
    }
    DescribeAutoScalingInstancesResult result = asgClient.describeAutoScalingInstances(request);

    instances.addAll(result.getAutoScalingInstances());
    while (result.getNextToken() != null) {
      request = request.withNextToken(result.getNextToken());
      result = asgClient.describeAutoScalingInstances(request);
      instances.addAll(result.getAutoScalingInstances());
    }

    LOGGER.info(String.format("Got %d auto-scaling instances.", instances.size()));
    return instances;
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof DescribeAutoScalingInstancesResult == false) return false;
    DescribeAutoScalingInstancesResult other = (DescribeAutoScalingInstancesResult) obj;
    if (other.getAutoScalingInstances() == null ^ this.getAutoScalingInstances() == null)
      return false;
    if (other.getAutoScalingInstances() != null
        && other.getAutoScalingInstances().equals(this.getAutoScalingInstances()) == false)
      return false;
    if (other.getNextToken() == null ^ this.getNextToken() == null) return false;
    if (other.getNextToken() != null && other.getNextToken().equals(this.getNextToken()) == false)
      return false;
    return true;
  }