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


Java InstanceState.getCode方法代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.InstanceState.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java InstanceState.getCode方法的具体用法?Java InstanceState.getCode怎么用?Java InstanceState.getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.ec2.model.InstanceState的用法示例。


在下文中一共展示了InstanceState.getCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isRunningOrPending

import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的package包/类
private boolean isRunningOrPending(InstanceState state) {
  boolean ret = false;
  if (state != null) {
    ret = state.getCode() == 0 || state.getCode() == 16; //0 - pending. 16 -- running
  }
  return ret;
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:8,代码来源:ReconcileWithAwsJob.java

示例2: mapToPowerState

import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的package包/类
/**
 * Maps the Aws machine state to {@link PowerState}
 *
 * @param state
 * @return the {@link PowerState} of the machine
 */
public static PowerState mapToPowerState(InstanceState state) {
    PowerState powerState = PowerState.UNKNOWN;
    switch (state.getCode()) {
    case 16:
        powerState = PowerState.ON;
        break;
    case 80:
        powerState = PowerState.OFF;
        break;
    default:
        break;
    }
    return powerState;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:21,代码来源:AWSUtils.java

示例3: terminateInstance

import com.amazonaws.services.ec2.model.InstanceState; //导入方法依赖的package包/类
/**
 * Terminates the specified instance.
 *
 * @param  instanceId  Id of the instance to terminate
 */
public boolean terminateInstance(final String instanceId) {
    TerminateInstancesRequest terminateRequest = new TerminateInstancesRequest();
    terminateRequest.withInstanceIds(instanceId);

    if(client == null){
        throw new RuntimeException("The client is not initialized");
    }
    TerminateInstancesResult result = client.terminateInstances(terminateRequest);
    List<InstanceStateChange> stateChanges = result.getTerminatingInstances();
    boolean terminatedInstance = false;
    for (InstanceStateChange stateChange : stateChanges) {
        if (instanceId.equals(stateChange.getInstanceId())) {
            terminatedInstance = true;

            InstanceState currentState = stateChange.getCurrentState();
            if (currentState.getCode() != 32 && currentState.getCode() != 48) {
                log.error(String.format(
                        "Machine state for id %s should be terminated (48) or shutting down (32) but was %s instead",
                        instanceId, currentState.getCode()));
                return false;
            }
        }
    }

    if (!terminatedInstance) {
        log.error("Matching terminated instance was not found for instance " + instanceId);
        return false;
    }

    return true;
}
 
开发者ID:RetailMeNot,项目名称:SeleniumGridScaler,代码行数:37,代码来源:AwsVmManager.java


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