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


Java Volume.getState方法代码示例

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


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

示例1: add

import com.amazonaws.services.ec2.model.Volume; //导入方法依赖的package包/类
@Override
public Event add(Ec2Volume newResource) {
    Volume volume = newResource.getResource();
    String state = volume.getState();
    switch (state) {
    case "creating":
        return createEvent(null, newResource, EventType.Ec2_Volume_Creating);
    case "available":
    case "in-use":
        return createEvent(null, newResource, EventType.Ec2_Volume_Create);
    case "deleting":
        return createEvent(null, newResource, EventType.Ec2_Volume_Deleting);
    case "error":
        return createEvent(null, newResource, EventType.Ec2_Volume_Error);
    default:
        log.error("not handled instance state:{}", state);
        return createEvent(null, newResource, EventType.Unknown);
    }
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:20,代码来源:Ec2VolumeComparator.java

示例2: compareVolumeState

import com.amazonaws.services.ec2.model.Volume; //导入方法依赖的package包/类
private void compareVolumeState(Collection<Event> result, Ec2Volume oldResource, Ec2Volume newResource) {
    Volume oldVolume = oldResource.getResource();
    Volume newVolume = newResource.getResource();
    String oldState = oldVolume.getState();
    String newState = newVolume.getState();
    if (equal(newState, oldState)) {
        return;
    }
    switch (newState) {
    case "deleting":
        result.add(createEvent(oldResource, newResource, EventType.Ec2_Volume_Deleting));
        break;
    case "creating":
    case "available":
    case "in-use":
    case "error":
        break;
    default:
        log.error("not handled volume state:{}", newState);
        result.add(createEvent(oldResource, newResource, EventType.Unknown));
    }
}
 
开发者ID:veyronfei,项目名称:clouck,代码行数:23,代码来源:Ec2VolumeComparator.java

示例3: waitVolume

import com.amazonaws.services.ec2.model.Volume; //导入方法依赖的package包/类
public Volume waitVolume(AwsProcessClient awsProcessClient, String volumeId) {
    // ボリュームの処理待ち
    Volume volume;
    while (true) {
        try {
            Thread.sleep(1000L * awsProcessClient.getDescribeInterval());
        } catch (InterruptedException ignore) {
        }

        volume = describeVolume(awsProcessClient, volumeId);
        VolumeState state;
        try {
            state = VolumeState.fromValue(volume.getState());
        } catch (IllegalArgumentException e) {
            // 予期しないステータス
            AutoException exception = new AutoException("EPROCESS-000112", volume, volume.getState());
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
            throw exception;
        }

        // 安定状態のステータスになったら終了
        if (state == VolumeState.Available || state == VolumeState.InUse || state == VolumeState.Deleted
                || state == VolumeState.Error) {
            break;
        }
    }

    return volume;
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:30,代码来源:AwsCommonProcess.java

示例4: waitCreateVolume

import com.amazonaws.services.ec2.model.Volume; //导入方法依赖的package包/类
public void waitCreateVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
    AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
    String volumeId = awsVolume.getVolumeId();

    // ボリュームの作成待ち
    Volume volume;
    try {
        volume = awsCommonProcess.waitVolume(awsProcessClient, volumeId);

        if (!StringUtils.equals(volume.getState(), VolumeState.Available.toString())) {
            // ボリューム作成失敗時
            AutoException exception = new AutoException("EPROCESS-000113", volumeId, volume.getState());
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
            throw exception;
        }

        // ログ出力
        if (log.isInfoEnabled()) {
            log.info(MessageUtils.getMessage("IPROCESS-100122", volumeId));
        }
    } catch (AutoException e) {
        // ボリューム作成失敗時
        awsVolume = awsVolumeDao.read(volumeNo);
        awsVolume.setVolumeId(null);
        awsVolume.setStatus(null);
        awsVolumeDao.update(awsVolume);

        throw e;
    }

    //イベントログ出力
    Component component = null;
    if (awsVolume.getComponentNo() != null) {
        component = componentDao.read(awsVolume.getComponentNo());
    }
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(component, instance, "AwsEbsCreateFinish", new Object[] {
            awsProcessClient.getPlatform().getPlatformName(), awsVolume.getVolumeId(), awsVolume.getSize() });

    // データベース更新
    awsVolume = awsVolumeDao.read(volumeNo);
    awsVolume.setStatus(volume.getState());
    awsVolumeDao.update(awsVolume);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:45,代码来源:AwsVolumeProcess.java

示例5: waitAttachVolume

import com.amazonaws.services.ec2.model.Volume; //导入方法依赖的package包/类
public void waitAttachVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
    AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
    String volumeId = awsVolume.getVolumeId();

    Volume volume = null;
    try {
        // volume = awsProcessClient.waitAttachVolume(volumeId, instanceId);
        // TODO: アタッチ情報がすぐに更新されない問題に暫定的に対応
        int retry = 6;
        for (int i = 0; i < retry; i++) {
            volume = awsCommonProcess.waitVolume(awsProcessClient, volumeId);
            if (StringUtils.equals(volume.getState(), VolumeState.InUse.toString())) {
                break;
            }
        }

        if (!StringUtils.equals(volume.getState(), VolumeState.InUse.toString())) {
            // アタッチに失敗した場合
            AutoException exception = new AutoException("EPROCESS-000115", awsVolume.getInstanceId(), volumeId,
                    volume.getState());
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
            throw exception;
        }

        // ログ出力
        if (log.isInfoEnabled()) {
            log.info(MessageUtils.getMessage("IPROCESS-100124", volumeId, awsVolume.getInstanceId()));
        }
    } catch (AutoException e) {
        // アタッチに失敗した場合
        awsVolume = awsVolumeDao.read(volumeNo);
        awsVolume.setStatus(VolumeState.Error.toString());
        awsVolume.setInstanceId(null);
        awsVolumeDao.update(awsVolume);

        throw e;
    }

    //イベントログ出力
    Component component = null;
    if (awsVolume.getComponentNo() != null) {
        component = componentDao.read(awsVolume.getComponentNo());
    }
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(component, instance, "AwsEbsAttachFinish", new Object[] { instance.getInstanceName(),
            awsVolume.getVolumeId(), awsVolume.getDevice() });

    // データベースの更新
    awsVolume = awsVolumeDao.read(volumeNo);
    awsVolume.setStatus(volume.getState());
    awsVolumeDao.update(awsVolume);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:53,代码来源:AwsVolumeProcess.java

示例6: waitDetachVolume

import com.amazonaws.services.ec2.model.Volume; //导入方法依赖的package包/类
public void waitDetachVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
    AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
    String volumeId = awsVolume.getVolumeId();
    String instanceId = awsVolume.getInstanceId();

    Volume volume = null;
    try {
        // TODO: アタッチ情報がすぐに更新されない問題に暫定的に対応
        int retry = 6;
        for (int i = 0; i < retry; i++) {
            volume = awsCommonProcess.waitVolume(awsProcessClient, volumeId);
            if (StringUtils.equals(volume.getState(), VolumeState.Available.toString())) {
                break;
            }
        }

        if (!StringUtils.equals(volume.getState(), VolumeState.Available.toString())) {
            // デタッチに失敗した場合
            AutoException exception = new AutoException("EPROCESS-000116", instanceId, volumeId, volume.getState());
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
            throw exception;
        }

        // ログ出力
        if (log.isInfoEnabled()) {
            log.info(MessageUtils.getMessage("IPROCESS-100126", volumeId, instanceId));
        }
    } catch (AutoException e) {
        // デタッチに失敗した場合
        awsVolume = awsVolumeDao.read(volumeNo);
        awsVolume.setStatus(VolumeState.Error.toString());
        awsVolume.setInstanceId(null);
        awsVolumeDao.update(awsVolume);

        throw e;
    }

    //イベントログ出力
    Component component = null;
    if (awsVolume.getComponentNo() != null) {
        component = componentDao.read(awsVolume.getComponentNo());
    }
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(component, instance, "AwsEbsDetachFinish", new Object[] { instance.getInstanceName(),
            awsVolume.getVolumeId(), awsVolume.getDevice() });

    // データベースの更新
    awsVolume = awsVolumeDao.read(volumeNo);
    awsVolume.setStatus(volume.getState());
    awsVolume.setInstanceId(null);
    awsVolumeDao.update(awsVolume);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:53,代码来源:AwsVolumeProcess.java


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