• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AttachVolumeRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.ec2.model.AttachVolumeRequest的典型用法代码示例。如果您正苦于以下问题:Java AttachVolumeRequest类的具体用法?Java AttachVolumeRequest怎么用?Java AttachVolumeRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AttachVolumeRequest类属于com.amazonaws.services.ec2.model包,在下文中一共展示了AttachVolumeRequest类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: attachVolume

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
public void attachVolume(String volumneId, String instanceId, String device) {
    AttachVolumeRequest attachVolumeRequest = new AttachVolumeRequest(volumneId, instanceId, device);
    asynchEc2Client.attachVolume(attachVolumeRequest);
    RebootInstancesRequest rebootInstancesRequest = new RebootInstancesRequest();
    rebootInstancesRequest.withInstanceIds(instanceId);
    asynchEc2Client.rebootInstances(rebootInstancesRequest);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:8,代码来源:AmazonInstance.java


示例2: attachVolume

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

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

    // ボリュームのアタッチ
    AttachVolumeRequest request = new AttachVolumeRequest();
    request.withVolumeId(volumeId);
    request.withInstanceId(awsInstance.getInstanceId());
    request.withDevice(awsVolume.getDevice());
    AttachVolumeResult result = awsProcessClient.getEc2Client().attachVolume(request);
    VolumeAttachment attachment = result.getAttachment();

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100123", volumeId, attachment.getInstanceId()));
    }

    // データベースの更新
    awsVolume.setInstanceId(attachment.getInstanceId());
    awsVolumeDao.update(awsVolume);
}
 
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:32,代码来源:AwsVolumeProcess.java


示例3: attachToInstance

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
@Override
public AttachVolumeResult attachToInstance(AttachVolumeRequest request,
        ResultCapture<AttachVolumeResult> extractor) {

    ActionResult result = resource.performAction("AttachToInstance",
            request, extractor);

    if (result == null) return null;
    return (AttachVolumeResult) result.getData();
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:VolumeImpl.java


示例4: attachVolume

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
@Override
public AttachVolumeResult attachVolume(AttachVolumeRequest request,
        ResultCapture<AttachVolumeResult> extractor) {

    ActionResult result = resource.performAction("AttachVolume", request,
            extractor);

    if (result == null) return null;
    return (AttachVolumeResult) result.getData();
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:InstanceImpl.java


示例5: attachVolume

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
@Override
public AttachVolumeResult attachVolume(AttachVolumeRequest attachVolumeRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java


示例6: attachExternalDisks

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
private DeferredResult<DiskState> attachExternalDisks( String id,
        List<DiskState> externalDisks, List<String> availableEbsDiskNames,
        AmazonEC2AsyncClient client) {

    List<DeferredResult<Pair<DiskState, Throwable>>> diskStateResults =
            externalDisks.stream().map(externalDisk -> {
                String deviceName = availableEbsDiskNames.get(0);
                availableEbsDiskNames.remove(0);
                externalDisk.customProperties.put(DEVICE_NAME, deviceName);

                AttachVolumeRequest attachVolumeRequest = new AttachVolumeRequest()
                        .withInstanceId(id)
                        .withVolumeId(externalDisk.id)
                        .withDevice(deviceName);

                DeferredResult<DiskState> diskDr = new DeferredResult<>();

                AWSAsyncHandler<AttachVolumeRequest, AttachVolumeResult> attachDiskHandler =
                        new AWSAsyncHandler<AttachVolumeRequest, AttachVolumeResult>() {
                            @Override protected void handleError(
                                    Exception exception) {
                                diskDr.fail(exception);
                            }

                            @Override protected void handleSuccess(
                                    AttachVolumeRequest request,
                                    AttachVolumeResult result) {
                                diskDr.complete(externalDisk);
                            }
                        };
                client.attachVolumeAsync(attachVolumeRequest, attachDiskHandler);
                return diskDr;
            }).map(diskDr -> diskDr
                    .thenApply(
                            diskState -> Pair.of(diskState, (Throwable) null))
                    .exceptionally(ex -> Pair.of(null, ex.getCause())))
                    .collect(Collectors.toList());

    return DeferredResult.allOf(diskStateResults)
            .thenCompose(pairs -> {
                // Collect error messages if any for all the external disks.
                StringJoiner stringJoiner = new StringJoiner(",");
                pairs.stream().filter(p -> p.left == null)
                        .forEach(p -> stringJoiner.add(p.right.getMessage()));
                if (stringJoiner.length() > 0) {
                    return DeferredResult.failed(new Throwable(stringJoiner
                            .toString()));
                } else {
                    return DeferredResult.completed(new DiskState());
                }
            });
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:53,代码来源:AWSInstanceService.java


示例7: performAttachOperation

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
private DeferredResult<DiskContext> performAttachOperation(DiskContext context) {
    DeferredResult<DiskContext> dr = new DeferredResult();
    try {
        if (context.request.isMockRequest) {
            updateComputeAndDiskState(dr, context);
            return dr;
        }

        String instanceId = context.computeState.id;
        if (instanceId == null || !instanceId.startsWith(AWS_INSTANCE_ID_PREFIX)) {
            return failTask(context, "compute id cannot be empty");
        }

        String diskId = context.diskState.id;
        if (diskId == null || !diskId.startsWith(AWS_VOLUME_ID_PREFIX)) {
            return failTask(context, "disk id cannot be empty");
        }

        String deviceName = getAvailableDeviceName(context, instanceId);
        if (deviceName == null) {
            return failTask(context, "No device name is available for attaching new disk");
        }

        context.diskState.customProperties.put(DEVICE_NAME, deviceName);

        AttachVolumeRequest attachVolumeRequest = new AttachVolumeRequest()
                .withInstanceId(instanceId)
                .withVolumeId(diskId)
                .withDevice(deviceName);

        AWSAsyncHandler<AttachVolumeRequest, AttachVolumeResult> attachDiskHandler = new AWSAttachDiskHandler(
                this, dr, context);

        context.amazonEC2Client.attachVolumeAsync(attachVolumeRequest, attachDiskHandler);

    } catch (Exception e) {
        return failTask(context, e);
    }

    return dr;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:42,代码来源:AWSComputeDiskDay2Service.java


示例8: handleSuccess

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
@Override
protected void handleSuccess(AttachVolumeRequest request, AttachVolumeResult result) {
    updateComputeAndDiskState(this.dr, this.context);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:5,代码来源:AWSComputeDiskDay2Service.java


示例9: attachVolumes

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
/**
 * Attaches volume(s) for EBS.
 * @return true if successful attachment, or nothing to do. false otherwise
 */
private boolean attachVolumes() {

	// If volume is found in map, it has been successfully created (no need to check here)
	for( Map.Entry<String,String> entry : this.storageIdToVolumeId.entrySet()) {

		String volumeId = entry.getValue();
		String storageId = entry.getKey();

		// Give a name to the volume before attaching
		String nameTemplate = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_NAME_PREFIX);
		String name = Ec2IaasHandler.expandVolumeName(
				nameTemplate, this.applicationName, this.scopedInstance.getName());
		if(Utils.isEmptyOrWhitespaces(name)) name = "Created by Roboconf for " + this.tagName;
		tagResource(volumeId, name);

		// Attach volume now
		String mountPoint = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_MOUNT_POINT_PREFIX);
		if(Utils.isEmptyOrWhitespaces(mountPoint)) mountPoint = "/dev/sdf";

		AttachVolumeRequest attachRequest = new AttachVolumeRequest()
			.withInstanceId(this.machineId)
			.withDevice(mountPoint)
			.withVolumeId(volumeId);

		try {
			this.ec2Api.attachVolume(attachRequest);
		} catch(Exception e) {
			this.logger.warning("EBS Volume attachment error: " + e);
		}

		// Set deleteOnTermination flag ?
		if(Boolean.parseBoolean(Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_DELETE_OT_PREFIX))) {
			EbsInstanceBlockDeviceSpecification ebsSpecification = new EbsInstanceBlockDeviceSpecification()
				.withVolumeId(volumeId)
				.withDeleteOnTermination(true);

			InstanceBlockDeviceMappingSpecification mappingSpecification = new InstanceBlockDeviceMappingSpecification()
				.withDeviceName(mountPoint)
				.withEbs(ebsSpecification);

			ModifyInstanceAttributeRequest request = new ModifyInstanceAttributeRequest()
				.withInstanceId(this.machineId)
				.withBlockDeviceMappings(mappingSpecification);

			this.ec2Api.modifyInstanceAttribute(request);
		}
	}

	return true;
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:55,代码来源:Ec2MachineConfigurator.java


示例10: attachVolume

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
/**
 * Performs the <code>AttachVolume</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Instance</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>InstanceId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return The response of the low-level client operation associated with
 *         this resource action.
 * @see AttachVolumeRequest
 */
AttachVolumeResult attachVolume(AttachVolumeRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:22,代码来源:Instance.java


示例11: attachToInstance

import com.amazonaws.services.ec2.model.AttachVolumeRequest; //导入依赖的package包/类
/**
 * Performs the <code>AttachToInstance</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Volume</code> resource, and any conflicting parameter value set in
 * the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>VolumeId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return The response of the low-level client operation associated with
 *         this resource action.
 * @see AttachVolumeRequest
 */
AttachVolumeResult attachToInstance(AttachVolumeRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:22,代码来源:Volume.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AtomicNotNullLazyValue类代码示例发布时间:2022-05-22
下一篇:
Java ProcessorNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap