com.amazonaws.services.ec2.model.Instance.getState()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中com.amazonaws.services.ec2.model.Instance.getState()方法的一些代码示例,展示了Instance.getState()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getState()方法的具体详情如下:
包路径:com.amazonaws.services.ec2.model.Instance
类名称:Instance
方法名:getState

Instance.getState介绍

[英]The current state of the instance.
[中]实例的当前状态。

代码示例

代码示例来源:origin: h2oai/h2o-2

private static String ip(Instance instance) {
 String ip = instance.getPublicIpAddress();
 if( ip != null && ip.length() != 0 )
  if( instance.getState().getName().equals("running") )
   return ip;
 return null;
}

代码示例来源:origin: aws/aws-sdk-java

if (getRamdiskId() != null)
  sb.append("RamdiskId: ").append(getRamdiskId()).append(",");
if (getState() != null)
  sb.append("State: ").append(getState()).append(",");
if (getStateTransitionReason() != null)
  sb.append("StateTransitionReason: ").append(getStateTransitionReason()).append(",");

代码示例来源:origin: apache/incubator-gobblin

/***
 * Get list of EC2 {@link Instance}s for a auto scaling group
 *
 * @param groupName Auto scaling group name
 * @param status Instance status (eg. running)
 * @return List of EC2 instances found for the input auto scaling group
 */
public List<Instance> getInstancesForGroup(String groupName,
  String status) {
 final AmazonEC2 amazonEC2 = getEc2Client();
 final DescribeInstancesResult instancesResult = amazonEC2.describeInstances(new DescribeInstancesRequest()
   .withFilters(new Filter().withName("tag:aws:autoscaling:groupName").withValues(groupName)));
 final List<Instance> instances = new ArrayList<>();
 for (Reservation reservation : instancesResult.getReservations()) {
  for (Instance instance : reservation.getInstances()) {
   if (null == status|| null == instance.getState()
     || status.equals(instance.getState().getName())) {
    instances.add(instance);
    LOGGER.info("Found instance: " + instance + " which qualified filter: " + status);
   } else {
    LOGGER.info("Found instance: " + instance + " but did not qualify for filter: " + status);
   }
  }
 }
 return instances;
}

代码示例来源:origin: aws/aws-sdk-java

hashCode = prime * hashCode + ((getPublicIpAddress() == null) ? 0 : getPublicIpAddress().hashCode());
hashCode = prime * hashCode + ((getRamdiskId() == null) ? 0 : getRamdiskId().hashCode());
hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode());
hashCode = prime * hashCode + ((getStateTransitionReason() == null) ? 0 : getStateTransitionReason().hashCode());
hashCode = prime * hashCode + ((getSubnetId() == null) ? 0 : getSubnetId().hashCode());

代码示例来源:origin: apache/usergrid

for ( com.amazonaws.services.ec2.model.Instance in : reservation.getInstances() ) {
  stateStr = in.getState().getName();
  LOG.info( "{} is {}", in.getInstanceId(), in.getState().getName() );
    if ( in.getState().getName().equals( state.toString() ) ) {
      instanceIdCopy.remove( in.getInstanceId() );

代码示例来源:origin: aws/aws-sdk-java

if (other.getRamdiskId() != null && other.getRamdiskId().equals(this.getRamdiskId()) == false)
  return false;
if (other.getState() == null ^ this.getState() == null)
  return false;
if (other.getState() != null && other.getState().equals(this.getState()) == false)
  return false;
if (other.getStateTransitionReason() == null ^ this.getStateTransitionReason() == null)

代码示例来源:origin: awsdocs/aws-doc-sdk-examples

instance.getImageId(),
instance.getInstanceType(),
instance.getState().getName(),
instance.getMonitoring().getState());

代码示例来源:origin: aws-amplify/aws-sdk-android

if (getInstanceId() != null) sb.append("InstanceId: " + getInstanceId() + ",");
if (getImageId() != null) sb.append("ImageId: " + getImageId() + ",");
if (getState() != null) sb.append("State: " + getState() + ",");
if (getPrivateDnsName() != null) sb.append("PrivateDnsName: " + getPrivateDnsName() + ",");
if (getPublicDnsName() != null) sb.append("PublicDnsName: " + getPublicDnsName() + ",");

代码示例来源:origin: apache/usergrid

/**
 * Constructs and returns an BasicInstance object, using information from <code>ec2</code>
 *
 * @param ec2
 * @return
 */
protected static Instance toInstance( com.amazonaws.services.ec2.model.Instance ec2 ) {
  Instance instance;
  BasicInstanceSpec spec;
  spec = new BasicInstanceSpec();
  spec.setImageId( ec2.getImageId() );
  spec.setKeyName( ec2.getKeyName() );
  spec.setType( ec2.getInstanceType() );
  instance = new BasicInstance(
          ec2.getInstanceId(),
          spec,
          InstanceState.fromValue( ec2.getState().getName() ),
          ec2.getPrivateDnsName(),
          ec2.getPublicDnsName(),
          ec2.getPrivateIpAddress(),
          ec2.getPublicIpAddress()
      );
  return instance;
}

代码示例来源:origin: aws-amplify/aws-sdk-android

hashCode = prime * hashCode + ((getState() == null) ? 0 : getState().hashCode()); 
hashCode = prime * hashCode + ((getPrivateDnsName() == null) ? 0 : getPrivateDnsName().hashCode()); 
hashCode = prime * hashCode + ((getPublicDnsName() == null) ? 0 : getPublicDnsName().hashCode());

代码示例来源:origin: com.github.vatbub/awsec2wakelauncher.common

/**
 * Returns the state of the specified instance
 *
 * @param instanceId The id of the instance to get the state for
 * @return The state of the specified instance
 */
public InstanceState getInstanceState(String instanceId) {
  return getInstanceDescription(instanceId).getState();
}

代码示例来源:origin: aws-amplify/aws-sdk-android

if (other.getImageId() == null ^ this.getImageId() == null) return false;
if (other.getImageId() != null && other.getImageId().equals(this.getImageId()) == false) return false; 
if (other.getState() == null ^ this.getState() == null) return false;
if (other.getState() != null && other.getState().equals(this.getState()) == false) return false; 
if (other.getPrivateDnsName() == null ^ this.getPrivateDnsName() == null) return false;
if (other.getPrivateDnsName() != null && other.getPrivateDnsName().equals(this.getPrivateDnsName()) == false) return false;

代码示例来源:origin: com.elastisys.scale/cloudpool.aws.commons

@Override
  public boolean test(Instance state) {
    return this.acceptableStates.contains(state.getState().getName());
  }
}

代码示例来源:origin: org.apache.airavata/gfac-core

private boolean anyInstancesStateEqual(List<Instance> instances, InstanceStateName name) {
  for (Iterator<Instance> iterator = instances.iterator(); iterator.hasNext();) {
    Instance instance = (Instance) iterator.next();
    // if one of instance is not running, return false
    if (InstanceStateName.fromValue(instance.getState().getName()) == name) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.apache.airavata/gfac-core

private boolean allInstancesStateEqual(List<Instance> instances, InstanceStateName name) {
  for (Iterator<Instance> iterator = instances.iterator(); iterator.hasNext();) {
    Instance instance = (Instance) iterator.next();
    // if one of instance is not running, return false
    if (InstanceStateName.fromValue(instance.getState().getName()) != name) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: org.jenkins-ci.plugins/ec2

protected boolean isAlive(boolean force) {
  fetchLiveInstanceData(force);
  if (lastFetchInstance == null)
    return false;
  if (lastFetchInstance.getState().getName().equals(InstanceStateName.Terminated.toString()))
    return false;
  return true;
}

代码示例来源:origin: jenkinsci/ec2-plugin

protected boolean isAlive(boolean force) {
  fetchLiveInstanceData(force);
  if (lastFetchInstance == null)
    return false;
  if (lastFetchInstance.getState().getName().equals(InstanceStateName.Terminated.toString()))
    return false;
  return true;
}

代码示例来源:origin: org.jenkins-ci.plugins/ec2

/**
 * Gets the current state of the instance.
 *
 * <p>
 * Unlike {@link #describeInstance()}, this method always return the current status by calling EC2.
 */
public InstanceState getState() throws AmazonClientException, InterruptedException {
  ec2InstanceDescription=_describeInstance();
  return InstanceState.find(ec2InstanceDescription.getState().getName());
}

代码示例来源:origin: paulhoule/infovore

private boolean instanceStarting(String instanceId) {
  DescribeInstancesResult result=ec2Client.describeInstances(new DescribeInstancesRequest().withInstanceIds(instanceId));
  return result.getReservations().get(0).getInstances().get(0).getState().getName().equals(InstanceStateName.Pending.toString());
};

代码示例来源:origin: jenkinsci/ec2-plugin

/**
 * Gets the current state of the instance.
 *
 * <p>
 * Unlike {@link #describeInstance()}, this method always return the current status by calling EC2.
 */
public InstanceState getState() throws AmazonClientException, InterruptedException {
  ec2InstanceDescription = CloudHelper.getInstanceWithRetry(getInstanceId(), getCloud());
  return InstanceState.find(ec2InstanceDescription.getState().getName());
}

相关文章

Instance类方法