当前位置: 首页>>代码示例>>Java>>正文


Java InstanceStateName.Running方法代码示例

本文整理汇总了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
    );
}
 
开发者ID:ContaAzul,项目名称:turbine-ec2,代码行数:14,代码来源:EC2ToTurbineInstance.java

示例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;
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:23,代码来源:EC2Cloud.java

示例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();
}
 
开发者ID:Sylvain-Bugat,项目名称:aws-ec2-start-stop-tools,代码行数:34,代码来源:AmazonEC2Service.java

示例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;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:31,代码来源:AwsCommonProcess.java


注:本文中的com.amazonaws.services.ec2.model.InstanceStateName.Running方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。