當前位置: 首頁>>代碼示例>>Java>>正文


Java RegionInfo類代碼示例

本文整理匯總了Java中com.xerox.amazonws.ec2.RegionInfo的典型用法代碼示例。如果您正苦於以下問題:Java RegionInfo類的具體用法?Java RegionInfo怎麽用?Java RegionInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RegionInfo類屬於com.xerox.amazonws.ec2包,在下文中一共展示了RegionInfo類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertObject

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@Override
protected Region convertObject(RegionInfo from) {
    Region to = new Region();

    to.setRegionName(from.getName());
    to.setEndpoint(from.getUrl());

    return to;
}
 
開發者ID:primecloud-controller-org,項目名稱:primecloud-controller,代碼行數:10,代碼來源:RegionConverter.java

示例2: describeRegions

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@Override
public DescribeRegionsResult describeRegions(DescribeRegionsRequest describeRegionsRequest) {
    try {
        List<RegionInfo> infos = jec2.describeRegions(describeRegionsRequest.getRegionNames());
        List<Region> regions = new RegionConverter().convert(infos);
        return new DescribeRegionsResult().withRegions(regions);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}
 
開發者ID:primecloud-controller-org,項目名稱:primecloud-controller,代碼行數:11,代碼來源:EucaEc2Client.java

示例3: testEc2DescribeRegionsSingle

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@Override
public void testEc2DescribeRegionsSingle() throws Exception {
    // act
    List<RegionInfo> regionInfos = ec2.describeRegions(Arrays.asList(new String[] { "US_EAST" }));

    // assert
    assertEquals(1, regionInfos.size());
    assertEquals("US_EAST", regionInfos.get(0).getName());
}
 
開發者ID:barnyard,項目名稱:pi,代碼行數:10,代碼來源:Ec2TypicaTestCase.java

示例4: testEc2DescribeRegionsEmpty

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@Override
public void testEc2DescribeRegionsEmpty() throws Exception {
    // act
    List<RegionInfo> regionInfos = ec2.describeRegions(new ArrayList<String>());

    // assert
    assertEquals(3, regionInfos.size());
    assertEquals("US_EAST", regionInfos.get(0).getName());
    assertEquals("US_WEST", regionInfos.get(1).getName());
    assertEquals("UK", regionInfos.get(2).getName());
}
 
開發者ID:barnyard,項目名稱:pi,代碼行數:12,代碼來源:Ec2TypicaTestCase.java

示例5: testEc2DescribeRegions

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@Test
public void testEc2DescribeRegions() throws Exception {
    // act
    List<RegionInfo> regions = ec2.describeRegions(null);

    // assert
    assertEquals(2, regions.size());
    assertThatRegionsContainsRegion(regions, US_REGION_NAME, US_REGION_ENDPOINT);
    assertThatRegionsContainsRegion(regions, UK_REGION_NAME, UK_REGION_ENDPOINT);
}
 
開發者ID:barnyard,項目名稱:pi,代碼行數:11,代碼來源:GivenASingleNodeCloudTest.java

示例6: assertThatRegionsContainsRegion

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
private void assertThatRegionsContainsRegion(List<RegionInfo> regions, String regionName, String regionEndpoint) {
    for (RegionInfo region : regions) {
        if (region.getName().equals(regionName) && region.getUrl().equals(regionEndpoint))
            return;
    }

    fail(String.format("%s with endpoint %s not found in %s", regionName, regionEndpoint, regions));
}
 
開發者ID:barnyard,項目名稱:pi,代碼行數:9,代碼來源:GivenASingleNodeCloudTest.java

示例7: getRegionUrl

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
protected String getRegionUrl(OptionSet options) throws Exception {
    if(options.has("region")) {
        return CmdUtils.valueOf(options, "region", RegionInfo.REGIONURL_US_EAST);
    } else {
        return RegionInfo.REGIONURL_US_EAST;
    }
}
 
開發者ID:we7,項目名稱:voldemort,代碼行數:8,代碼來源:VoldemortApp.java

示例8: run

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@Override
public void run(String[] args) throws Exception {
    parser.accepts("help", "Prints this help");
    parser.accepts("logging",
                   "Options are \"debug\", \"info\" (default), \"warn\", \"error\", or \"off\"")
          .withRequiredArg();
    parser.accepts("accessid", "Access ID (used instead of accessidfile)").withRequiredArg();
    parser.accepts("accessidfile", "Access ID file (used instead of accessid)")
          .withRequiredArg();
    parser.accepts("secretkey", "Secret key (used instead of secretkeyfile)").withRequiredArg();
    parser.accepts("secretkeyfile", "Secret key file (used instead of secretkey)")
          .withRequiredArg();
    parser.accepts("securitygroups", "Security groups to allow on instances (optional)")
          .withRequiredArg();
    parser.accepts("ami", "AMI").withRequiredArg();
    parser.accepts("keypairid", "KeyPairID").withRequiredArg();
    parser.accepts("instances", "Number of instances (default 1)")
          .withRequiredArg()
          .ofType(Integer.class);
    parser.accepts("instancetype",
                   "Instance type; options are " + Ec2Connection.Ec2InstanceType.DEFAULT
                           + " (default), " + Ec2Connection.Ec2InstanceType.LARGE + ", "
                           + Ec2Connection.Ec2InstanceType.XLARGE + ", "
                           + Ec2Connection.Ec2InstanceType.MEDIUM_HCPU + ", and "
                           + Ec2Connection.Ec2InstanceType.XLARGE_HCPU).withRequiredArg();
    parser.accepts("region",
                   "Region type; options are " + RegionInfo.REGIONURL_AP_SOUTHEAST + ", "
                           + RegionInfo.REGIONURL_EU_WEST + ", " + RegionInfo.REGIONURL_US_WEST
                           + ", " + RegionInfo.REGIONURL_US_EAST + " (default) ")
          .withRequiredArg();

    OptionSet options = parse(args);
    String accessId = getAccessId(options);
    String secretKey = getSecretKey(options);
    String ami = getRequiredString(options, "ami");
    String keypairId = getRequiredString(options, "keypairid");
    String regionUrl = getRegionUrl(options);
    int instanceCount = CmdUtils.valueOf(options, "instances", 1);
    String securityGroups = CmdUtils.valueOf(options, "securitygroups", null);
    List<String> securityGroupsList = (securityGroups != null) ? Arrays.asList(securityGroups.split(","))
                                                              : null;
    Ec2Connection.Ec2InstanceType instanceType = null;

    try {
        instanceType = Ec2Connection.Ec2InstanceType.valueOf(CmdUtils.valueOf(options,
                                                                              "instancetype",
                                                                              "DEFAULT"));
    } catch(Exception e) {
        printUsage();
    }

    Ec2Connection ec2Connection = new TypicaEc2Connection(accessId, secretKey, null, regionUrl);
    List<HostNamePair> hostNamePairs = ec2Connection.createInstances(ami,
                                                                     keypairId,
                                                                     instanceType,
                                                                     instanceCount,
                                                                     securityGroupsList);

    StringBuilder s = new StringBuilder();

    for(HostNamePair hostNamePair: hostNamePairs) {
        s.append(hostNamePair.getExternalHostName());
        s.append('=');
        s.append(hostNamePair.getInternalHostName());
        s.append(Utils.NEWLINE);
    }

    System.out.print(s);
}
 
開發者ID:we7,項目名稱:voldemort,代碼行數:70,代碼來源:VoldemortEc2InstanceCreatorApp.java

示例9: run

import com.xerox.amazonws.ec2.RegionInfo; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void run(String[] args) throws Exception {
    parser.accepts("help", "Prints this help");
    parser.accepts("logging",
                   "Options are \"debug\", \"info\" (default), \"warn\", \"error\", or \"off\"")
          .withRequiredArg();
    parser.accepts("accessid", "Access ID (used instead of accessidfile)").withRequiredArg();
    parser.accepts("accessidfile", "Access ID file (used instead of accessid)")
          .withRequiredArg();
    parser.accepts("secretkey", "Secret key (used instead of secretkeyfile)").withRequiredArg();
    parser.accepts("secretkeyfile", "Secret key file (used instead of secretkey)")
          .withRequiredArg();
    parser.accepts("hostnames", "File containing host names").withRequiredArg();
    parser.accepts("instances", "File containing instance IDs").withRequiredArg();
    parser.accepts("region",
                   "Region type; options are " + RegionInfo.REGIONURL_AP_SOUTHEAST + ", "
                           + RegionInfo.REGIONURL_EU_WEST + ", " + RegionInfo.REGIONURL_US_WEST
                           + ", " + RegionInfo.REGIONURL_US_EAST + " (default) ")
          .withRequiredArg();

    OptionSet options = parse(args);
    String accessId = getAccessId(options);
    String secretKey = getSecretKey(options);
    String regionUrl = getRegionUrl(options);

    Ec2Connection ec2Connection = new TypicaEc2Connection(accessId, secretKey, null, regionUrl);

    List<String> hostNames = new ArrayList<String>();
    File hostNamesFile = getInputFile(options, "hostnames");
    File instancesFile = getInputFile(options, "instances");

    if(hostNamesFile == null && instancesFile == null)
        printUsage();

    if(hostNamesFile != null) {
        List<HostNamePair> hostNamePairs = getHostNamesPairsFromFile(hostNamesFile);

        for(HostNamePair hostNamePair: hostNamePairs)
            hostNames.add(hostNamePair.getExternalHostName());

        ec2Connection.deleteInstancesByHostName(hostNames);
    }

    if(instancesFile != null) {
        List<String> instanceIds = FileUtils.readLines(instancesFile);
        ec2Connection.deleteInstancesByInstanceId(instanceIds);
    }
}
 
開發者ID:we7,項目名稱:voldemort,代碼行數:50,代碼來源:VoldemortEc2InstanceTerminatorApp.java


注:本文中的com.xerox.amazonws.ec2.RegionInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。