Esempio n. 1
0
  /**
   * @Title: getSpotRequestsIds @Description: get spot request ids for all spot instances
   *
   * @return
   * @throws
   */
  public synchronized Collection<String> getSpotRequestsIds() {
    Collection<InstanceStatus> spotInstances = getSpotInstances();
    List<String> requestsIds = new ArrayList<String>();
    for (InstanceStatus instanceStatus : spotInstances) {
      SpotInstanceStatus spotInstanceStatus = (SpotInstanceStatus) instanceStatus;
      requestsIds.add(spotInstanceStatus.getSpotRequestId());
    }

    return requestsIds;
  }
Esempio n. 2
0
  /**
   * @Title: getSpotInstanceStatusByRequestId @Description: get spot instances by spot request id
   *
   * @param spotInstanceRequestId the spot request id
   * @return the spot instance (null if not found)
   * @throws
   */
  public synchronized InstanceStatus getSpotInstanceStatusByRequestId(
      String spotInstanceRequestId) {
    if (spotInstanceRequestId == null) {
      throw new NullPointerException("spot request id cannot be null");
    }
    Collection<InstanceStatus> instances = getSpotInstances();
    for (InstanceStatus instance : instances) {
      SpotInstanceStatus instanceStatus = (SpotInstanceStatus) instance;
      if (instanceStatus.getSpotRequestId().equals(spotInstanceRequestId)) {
        return instanceStatus;
      }
    }

    return null;
  }