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

Java AllocateAddressResult类代码示例

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

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



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

示例1: allocateElasticIPAddress

import com.amazonaws.services.ec2.model.AllocateAddressResult; //导入依赖的package包/类
/**
 * Allocate an elastic IP address
 */
public DeferredResult<String> allocateElasticIPAddress() {
    AllocateAddressRequest req = new AllocateAddressRequest()
            .withDomain(DomainType.Vpc);

    String message = "Allocate AWS Elastic IP Address for use with instances in a VPC.";

    AWSDeferredResultAsyncHandler<AllocateAddressRequest, AllocateAddressResult> handler = new
            AWSDeferredResultAsyncHandler<>(this.service, message);
    this.client.allocateAddressAsync(req, handler);
    return handler.toDeferredResult()
            .thenApply(AllocateAddressResult::getAllocationId);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:16,代码来源:AWSNetworkClient.java


示例2: main

import com.amazonaws.services.ec2.model.AllocateAddressResult; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply an instance id\n" +
        "Ex: AllocateAddress <instance_id>\n";

    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String instance_id = args[0];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    AllocateAddressRequest allocate_request = new AllocateAddressRequest()
        .withDomain(DomainType.Vpc);

    AllocateAddressResult allocate_response =
        ec2.allocateAddress(allocate_request);

    String allocation_id = allocate_response.getAllocationId();

    AssociateAddressRequest associate_request =
        new AssociateAddressRequest()
            .withInstanceId(instance_id)
            .withAllocationId(allocation_id);

    AssociateAddressResult associate_response =
        ec2.associateAddress(associate_request);

    System.out.printf(
        "Successfully associated Elastic IP address %s " +
        "with instance %s",
        associate_response.getAssociationId(),
        instance_id);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:38,代码来源:AllocateAddress.java


示例3: allocateAddress

import com.amazonaws.services.ec2.model.AllocateAddressResult; //导入依赖的package包/类
public static Address allocateAddress(AmazonEC2 ec2, DomainType domainType) {
	AllocateAddressRequest addressRequest = new AllocateAddressRequest().withDomain(domainType);
	AllocateAddressResult addressResult = ec2.allocateAddress(addressRequest);
	Address address = new Address().withAllocationId(addressResult.getAllocationId())
			.withDomain(addressResult.getDomain()).withPublicIp(addressResult.getPublicIp());
	return address;
}
 
开发者ID:betahikaru,项目名称:ec2-util,代码行数:8,代码来源:AwsEc2Client.java


示例4: assignEIP

import com.amazonaws.services.ec2.model.AllocateAddressResult; //导入依赖的package包/类
public String assignEIP(final String instanceId) throws Exception {
    final AllocateAddressResult address = ec2.allocateAddress(new AllocateAddressRequest().withDomain("vpc"));
    logger.info("associate eip to instance, instanceId={}, ip={}", instanceId, address.getPublicIp());

    new Runner<>()
        .retryInterval(Duration.ofSeconds(10))
        .maxAttempts(3)
        .retryOn(e -> e instanceof AmazonServiceException)
        .run(() -> {
            ec2.associateAddress(new AssociateAddressRequest().withInstanceId(instanceId).withAllocationId(address.getAllocationId()));
            return null;
        });

    return address.getPublicIp();
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:16,代码来源:EC2VPC.java


示例5: createAddress

import com.amazonaws.services.ec2.model.AllocateAddressResult; //导入依赖的package包/类
/**
 * TODO: メソッドコメント
 * 
 * @param awsProcessClient
 * @return
 */
public AwsAddress createAddress(AwsProcessClient awsProcessClient) {
    // Elastic IPの確保
    AllocateAddressRequest request = new AllocateAddressRequest();
    if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) {
        request.withDomain(DomainType.Vpc);
    }

    String publicIp;
    try {
        AllocateAddressResult result = awsProcessClient.getEc2Client().allocateAddress(request);
        publicIp = result.getPublicIp();

    } catch (AutoException e) {
        // Elastic IPの上限オーバーの場合
        if (e.getCause() instanceof AmazonServiceException
                && "AddressLimitExceeded".equals(((AmazonServiceException) e.getCause()).getErrorCode())) {
            throw new AutoApplicationException("EPROCESS-000134");
        }

        throw e;
    }

    // イベントログ出力
    processLogger.debug(null, null, "AwsElasticIpAllocate", new Object[] {
            awsProcessClient.getPlatform().getPlatformName(), publicIp });

    // AWSアドレス情報を作成
    AwsAddress awsAddress = new AwsAddress();
    awsAddress.setUserNo(awsProcessClient.getUserNo());
    awsAddress.setPlatformNo(awsProcessClient.getPlatform().getPlatformNo());
    awsAddress.setPublicIp(publicIp);
    awsAddress.setComment("Allocate at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    awsAddressDao.create(awsAddress);

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


示例6: allocateElasticIPs

import com.amazonaws.services.ec2.model.AllocateAddressResult; //导入依赖的package包/类
/**
 * Allocate Elastic IPs as needed and assign it to the endpoints. If there are
 * any errors, roll back by releasing all allocated IPs if possible
 *
 * @param vpnEndpoints
 */
private void allocateElasticIPs(List<VPNEndpoint> vpnEndpoints) {

  for (VPNEndpoint vpnEndpoint : vpnEndpoints) {
    ec2Client.setEndpoint(vpnEndpoint.getRegion().getEndpoint());
    AllocateAddressResult allocAddrResult = ec2Client.allocateAddress(new AllocateAddressRequest().withDomain(DomainType.Vpc));
    String publicIp = allocAddrResult.getPublicIp();
    vpnEndpoint.setElasticIPAddress(publicIp);
    vpnEndpoint.setElasticIPAllocationId(allocAddrResult.getAllocationId());
    LOG.debug("Allocated elastic IP " + publicIp + " in " + vpnEndpoint.getRegion().getEndpoint());
  }
}
 
开发者ID:vinayselvaraj,项目名称:vpc2vpc,代码行数:18,代码来源:CreateConnection.java


示例7: allocateAddress

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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