本文整理汇总了Java中com.amazonaws.services.ec2.model.InstanceStateName.Running方法的典型用法代码示例。如果您正苦于以下问题:Java InstanceStateName.Running方法的具体用法?Java InstanceStateName.Running怎么用?Java InstanceStateName.Running使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.ec2.model.InstanceStateName
的用法示例。
在下文中一共展示了InstanceStateName.Running方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import com.amazonaws.services.ec2.model.InstanceStateName; //导入方法依赖的package包/类
/**
* Converts the ec2 instance to a turbine instance.
* @param ec2 EC2 instance.
* @return Turbine instance.
*/
public com.netflix.turbine.discovery.Instance convert(final Instance ec2) {
final boolean state = InstanceStateName.fromValue(
ec2.getState().getName()
) == InstanceStateName.Running;
return new com.netflix.turbine.discovery.Instance(
ec2.getPrivateIpAddress(), this.cluster, state
);
}
示例2: countCurrentEC2Slaves
import com.amazonaws.services.ec2.model.InstanceStateName; //导入方法依赖的package包/类
/**
* Counts the number of instances in EC2 currently running that are using
* the specifed image.
*
* @param ami If AMI is left null, then all instances are counted.
* <p>
* This includes those instances that may be started outside Hudson.
*/
public int countCurrentEC2Slaves(String ami) throws AmazonClientException {
int n = 0;
for (Reservation r : connect().describeInstances().getReservations()) {
for (Instance i : r.getInstances()) {
if (isEc2ProvisionedSlave(i, ami)) {
InstanceStateName stateName = InstanceStateName.fromValue(i.getState().getName());
if (stateName == InstanceStateName.Pending || stateName == InstanceStateName.Running) {
n++;
}
}
}
}
return n;
}
示例3: stopInstance
import com.amazonaws.services.ec2.model.InstanceStateName; //导入方法依赖的package包/类
/**
* Check the instance status and order to stop it if it's running.
*
* @param instanceId instance to stop
*/
public void stopInstance(final String instanceId) {
LOG.entry();
LOG.info("Stoping instance {}", instanceId);
// Check the instance state
final InstanceStateName instanteState = getInstanceStatus(instanceId);
if (InstanceStateName.Running != instanteState) {
final String message = "Instance " + instanceId + " is not running, current status: " + instanteState;
LOG.error(message);
LOG.exit(message);
throw new AmazonClientException(message);
}
// Stop instance order
final StopInstancesRequest stopInstancesRequest = new StopInstancesRequest().withInstanceIds(instanceId);
final StopInstancesResult stopInstancesResult = amazonEC2Client.stopInstances(stopInstancesRequest);
final List<InstanceStateChange> instanceStateChangeList = stopInstancesResult.getStoppingInstances();
for (final InstanceStateChange instanceStateChange : instanceStateChangeList) {
LOG.info("Instance {} has changing state: {} -> {}", instanceStateChange.getInstanceId(), instanceStateChange.getPreviousState(), instanceStateChange.getCurrentState());
}
LOG.info("Instance {} is stoping", instanceId);
LOG.exit();
}
示例4: waitInstance
import com.amazonaws.services.ec2.model.InstanceStateName; //导入方法依赖的package包/类
public Instance waitInstance(AwsProcessClient awsProcessClient, String instanceId) {
// インスタンスの処理待ち
Instance instance;
while (true) {
try {
Thread.sleep(1000L * awsProcessClient.getDescribeInterval());
} catch (InterruptedException ignore) {
}
instance = describeInstance(awsProcessClient, instanceId);
InstanceStateName state;
try {
state = InstanceStateName.fromValue(instance.getState().getName());
} catch (IllegalArgumentException e) {
// 予期しないステータス
AutoException exception = new AutoException("EPROCESS-000104", instanceId, instance.getState()
.getName());
exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(instance));
throw exception;
}
// 安定状態のステータスになったら終了
if (state == InstanceStateName.Running || state == InstanceStateName.Terminated
|| state == InstanceStateName.Stopped) {
break;
}
}
return instance;
}