コード例 #1
0
ファイル: AutoScaling.java プロジェクト: rajatdt/typica
 /**
  * Terminates a running instance.
  *
  * @param instanceId An instance id
  * @param shouldDecrement true of desired capacity should be decremented at the same time
  * @return activity description
  * @throws AutoScalingException wraps checked exceptions
  */
 public Activity terminateInstancesInAutoScalingGroup(String instanceId, boolean shouldDecrement)
     throws AutoScalingException {
   Map<String, String> params = new HashMap<String, String>();
   params.put("InstanceId", instanceId);
   params.put("ShouldDecrementDesiredCapacity", shouldDecrement ? "true" : "false");
   HttpGet method = new HttpGet();
   TerminateInstanceInAutoScalingGroupResponse response =
       makeRequestInt(
           method,
           "TerminateInstanceInAutoScalingGroup",
           params,
           TerminateInstanceInAutoScalingGroupResponse.class);
   TerminateInstanceInAutoScalingGroupResult result =
       response.getTerminateInstanceInAutoScalingGroupResult();
   com.xerox.amazonws.typica.autoscale.jaxb.Activity activity = result.getActivity();
   Activity ret =
       new Activity(
           activity.getActivityId(),
           activity.getDescription(),
           activity.getCause(),
           activity.getStartTime().toString(),
           activity.getEndTime().toString(),
           activity.getStatusCode(),
           activity.getStatusMessage(),
           activity.getProgress().intValue());
   return ret;
 }
コード例 #2
0
ファイル: AutoScaling.java プロジェクト: rajatdt/typica
  /**
   * Describes the autoScaling activities for a given group.
   *
   * @param activityIds activity ids used to filter the list, null for all
   * @param autoScalingGroupName an auto scaling group name
   * @return activity descriptions
   * @throws AutoScalingException wraps checked exceptions
   */
  public List<Activity> describeScalingActivities(
      List<String> activityIds, String autoScalingGroupName) throws AutoScalingException {
    Map<String, String> params = new HashMap<String, String>();
    if (activityIds != null && activityIds.size() > 0) {
      int i = 0;
      for (String id : activityIds) {
        params.put("ActivityIds.member." + (i + 1), id);
        i++;
      }
    }
    params.put("AutoScalingGroupName", autoScalingGroupName);
    HttpGet method = new HttpGet();
    List<Activity> ret = new ArrayList<Activity>();
    String nextToken = null;
    do {
      if (nextToken != null) {
        params.put("NextToken", nextToken);
      }
      DescribeScalingActivitiesResponse response =
          makeRequestInt(
              method, "DescribeScalingActivities", params, DescribeScalingActivitiesResponse.class);

      DescribeScalingActivitiesResult result = response.getDescribeScalingActivitiesResult();
      List<com.xerox.amazonws.typica.autoscale.jaxb.Activity> activities =
          result.getActivities().getMembers();
      for (com.xerox.amazonws.typica.autoscale.jaxb.Activity activity : activities) {
        Activity newActivity =
            new Activity(
                activity.getActivityId(),
                activity.getDescription(),
                activity.getCause(),
                activity.getStartTime().toString(),
                activity.getEndTime().toString(),
                activity.getStatusCode(),
                activity.getStatusMessage(),
                activity.getProgress().intValue());
        ret.add(newActivity);
      }
      nextToken = result.getNextToken();
    } while (nextToken != null);
    return ret;
  }