Java 类com.amazonaws.services.route53.model.RRType 实例源码

项目:TopStackDNS53    文件:Route53Test.java   
public static void createARecords(AmazonRoute53Client client) {
    ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest();
    request.setHostedZoneId("Z6C671E6E1A044F6695AD50EE258D8BAE");
    ChangeBatch changeBatch = new ChangeBatch();
    Collection<Change> changes = new LinkedList<Change>();
    for (int i = 1; i < 151; ++i) {
        Change change = new Change();
        change.setAction(ChangeAction.CREATE);
        ResourceRecordSet rrs = new ResourceRecordSet();
        rrs.setType(RRType.A);
        rrs.setTTL(900L);
        rrs.setName("inst-" + i + ".msicluster.momentumsoftware.com");
        Collection<ResourceRecord> rr = new LinkedList<ResourceRecord>();
        ResourceRecord e = new ResourceRecord();
        e.setValue("172.31.253." + i);
        rr.add(e);
        rrs.setResourceRecords(rr);
        change.setResourceRecordSet(rrs);
        changes.add(change);
    }
    changeBatch.setChanges(changes);
    request.setChangeBatch(changeBatch);
    client.changeResourceRecordSets(request);

}
项目:TopStackDNS53    文件:Route53Test.java   
public static void createCNAMERecords(AmazonRoute53Client client) {
    ChangeResourceRecordSetsRequest request = new ChangeResourceRecordSetsRequest();
    request.setHostedZoneId("Z9366F3515BBA46B2AA8C86B1D6DF0311");
    ChangeBatch changeBatch = new ChangeBatch();
    Collection<Change> changes = new LinkedList<Change>();
    Change change = new Change();
    change.setAction(ChangeAction.CREATE);
    ResourceRecordSet rrs = new ResourceRecordSet();
    rrs.setType(RRType.CNAME);
    rrs.setTTL(900L);
    rrs.setName("devessex.essex.momentumsoftware.com");

    Collection<ResourceRecord> rr = new LinkedList<ResourceRecord>();
    ResourceRecord e = new ResourceRecord();
    e.setValue("inst-5.essex.momentumsoftware.com");
    rr.add(e);
    rrs.setResourceRecords(rr);
    change.setResourceRecordSet(rrs);
    changes.add(change);
    changeBatch.setChanges(changes);
    request.setChangeBatch(changeBatch);
    client.changeResourceRecordSets(request);

}
项目:ec2-util    文件:AwsRoute53Client.java   
public static ResourceRecordSet generateResourceRecordSetForARecord(String publicIp, String domain) {
    ArrayList<ResourceRecord> resourceRecords = new ArrayList<>();
    ResourceRecord resourceRecord = new ResourceRecord().withValue(publicIp);
    resourceRecords.add(resourceRecord);

    ResourceRecordSet resourceRecordSet = new ResourceRecordSet();
    resourceRecordSet.setTTL(300L);
    resourceRecordSet.setName(domain);
    resourceRecordSet.setType(RRType.A);
    resourceRecordSet.setResourceRecords(resourceRecords);
    return resourceRecordSet;
}
项目:route53-dynamic-dns    文件:UpdateDns.java   
/**
 * TODO: assumes exactly one A record for record set
 * @param recordSetName
 * @return value for A record of record set
 */
private String getCurrentAValue(final String recordSetName) {
    final ListResourceRecordSetsRequest listResourceRecordSetsRequest = new ListResourceRecordSetsRequest()
            .withHostedZoneId(hostedZoneId)
            .withMaxItems("1")
            .withStartRecordName(recordSetName);
    ListResourceRecordSetsResult listResourceRecordSetsResult = execWithRetries(new Callable<ListResourceRecordSetsResult>() {
        @Override
        public ListResourceRecordSetsResult call() throws Exception {
            return route53.listResourceRecordSets(listResourceRecordSetsRequest);
        }
    });

    List<ResourceRecordSet> resourceRecordSets = listResourceRecordSetsResult.getResourceRecordSets();
    if (resourceRecordSets.isEmpty()) {
        throw new IllegalStateException("Could not find any resource record sets for \"" + recordSetName + "\" in hosted zone \"" + hostedZoneId + "\"");
    }

    for (ResourceRecordSet resourceRecordSet : resourceRecordSets) {
        if (RRType.valueOf(resourceRecordSet.getType()) == RRType.A) {
            List<ResourceRecord> resourceRecords = resourceRecordSet.getResourceRecords();
            if (resourceRecords.isEmpty()) {
                throw new IllegalStateException("Could not find any A records for set \"" + resourceRecordSet.getName() + "\" in hosted zone \"" + hostedZoneId + "\"");
            }
            return resourceRecords.get(0).getValue();
        }
    }
    throw new IllegalStateException("Could not find any A records for record set \"" + recordSetName + "\"");
}
项目:route53-dynamic-dns    文件:UpdateDns.java   
private void updateAValue(final String recordSetName, final String newValue) {
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue(newValue);

    ResourceRecordSet resourceRecordSet = new ResourceRecordSet()
            .withName(recordSetName)
            .withType(RRType.A)
            .withTTL(TTL)
            .withResourceRecords(Collections.singleton(resourceRecord));

    Change deleteChange = new Change()
            .withAction(ChangeAction.DELETE)
            .withResourceRecordSet(resourceRecordSet);

    Change createChange = new Change()
            .withAction(ChangeAction.CREATE)
            .withResourceRecordSet(resourceRecordSet);

    ChangeBatch changeBatch = new ChangeBatch()
            .withChanges(deleteChange, createChange);

    final ChangeResourceRecordSetsRequest changeResourceRecordSetsRequest = new ChangeResourceRecordSetsRequest()
            .withHostedZoneId(hostedZoneId)
            .withChangeBatch(changeBatch);

    execWithRetries(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            route53.changeResourceRecordSets(changeResourceRecordSetsRequest);
            // TODO - poll until the change as propagated?
            return null;
        }
    });
}
项目:java-translatebot    文件:WebsiteDeployer.java   
public void deploy() {

        /*
         * check for existence because once created, we aren't going to delete
         * it. Amazon could give the name to someone else. This won't matter
         * when we move CDN.
         */
        final Optional<Bucket> maybeBucket = this.s3.listBuckets()
                .stream()
                .filter(b -> b.getName().equals(BucketName))
                .findAny();
        if (!maybeBucket.isPresent()) {
            this.s3.createBucket(new CreateBucketRequest(BucketName));
        }

        this.s3.setBucketWebsiteConfiguration(BucketName, new BucketWebsiteConfiguration("index.html"));

        /*
         * Zone must exist
         */
        final HostedZone zone = this.route53.listHostedZonesByName(new ListHostedZonesByNameRequest().withDNSName(Tld))
                .getHostedZones()
                .stream()
                .findAny()
                .get();

        final String zoneId = zone.getId().replaceAll("/.*/", "");
        final ResourceRecord record = new ResourceRecord().withValue(Domain + ".s3.amazonaws.com");
        final ResourceRecordSet records = new ResourceRecordSet().withName(Domain + ".")
                .withType(RRType.CNAME)
                .withTTL(60L)
                .withResourceRecords(record);
        final Change change = new Change().withAction(ChangeAction.UPSERT).withResourceRecordSet(records);
        final List<Change> changes = Collections.singletonList(change);

        final ChangeBatch changeBatch = new ChangeBatch().withChanges(changes);
        final ChangeResourceRecordSetsRequest changeRecordsRequest = new ChangeResourceRecordSetsRequest()
                .withHostedZoneId(zoneId).withChangeBatch(changeBatch);
        this.route53.changeResourceRecordSets(changeRecordsRequest);

        upload(SignupObjectName);
        upload(ThankYouObjectName);

    }
项目:TopStackDNS53    文件:DNS53MetadataUtil.java   
public void populateServiceMetadata(
        final ServletConfig config, String serviceName) {
    logger.debug("init(): TXT record will be created for this service regarding its port and context path.");
    String contextPath = config.getServletContext().getContextPath();
    String port = Appctx.getBean("TOMCAT_PORT");
    String master_passwd = Appctx.getBean("DB_PASSWORD");

    final String fqdn = (String) ConfigurationUtil
            .getConfiguration(Arrays.asList(new String[] { "FQDN" }));
    final String domain = (String) ConfigurationUtil
            .getConfiguration(Arrays.asList(new String[] { "FQDN_DOMAIN" }));
    String txtRecordValue = ":" + port + contextPath;
    String baseDNSServerURL = "http://localhost:" + port + "/DNS53Server/2012-02-29/";

    logger.debug("Tomcat port = " + port + "; FQDN = " + fqdn + "; domain = " + domain + "; TXT Record Value = " + txtRecordValue + "; BaseDNSServerUrl = " + baseDNSServerURL);

    DNS53Client client = new DNS53Client(baseDNSServerURL + "hostedzone", baseDNSServerURL + "change",
            "admin", master_passwd);

    logger.debug("Service name = " + serviceName);
    String recordName = serviceName + "-" + fqdn;
    logger.debug("TXT Record Name: " + recordName);

    logger.debug("init(): Calling ListHostedZones to find the target zone!");
    ListHostedZonesRequest lhzReq = new ListHostedZonesRequest();
    lhzReq.setMaxItems("1");

    ListHostedZonesResult lhzResult = client.listHostedZones(lhzReq);

    HostedZone zone = null;
    List<HostedZone> zones = lhzResult.getHostedZones();
    if(zones != null && zones.size() > 0){
        for(HostedZone hz : zones){
            if(hz.getName().equals(domain + ".") || hz.getName().equals(domain)){
                zone = hz;
            }
        }
    } else{
        logger.error("BaseAsyncServlet encountered an error while it was trying to find the target hosted zone.");
        throw ErrorResponse.InternalFailure();
    }

    if(zone == null){
        logger.error("BaseAsyncServlet could not find any zone for this TopStackWeb instance.");
        throw ErrorResponse.InternalFailure();
    }

    // TODO (optional) check for the CNAME record for this service before proceeding

    logger.debug("init(): Creating a new TXT record for " + recordName + " with \"" + txtRecordValue + "\" as its value!");
    String zoneId = zone.getId();
    ChangeResourceRecordSetsRequest crrsReq = new ChangeResourceRecordSetsRequest();
    crrsReq.setHostedZoneId(zoneId);
    ChangeBatch cb = new ChangeBatch();
    cb.setComment("BaseAsyncServlet => init(): Registering " + serviceName + " service for Transcend TopStack.");
    Collection<Change> changes = new LinkedList<Change>();
    Change change = new Change();
    change.setAction(ChangeAction.CREATE);
    ResourceRecordSet rrSet = new ResourceRecordSet();
    rrSet.setName(recordName);
    rrSet.setTTL(900L);
    rrSet.setType(RRType.TXT);
    Collection<ResourceRecord> rr = new LinkedList<ResourceRecord>();
    ResourceRecord record = new ResourceRecord();
    record.setValue(txtRecordValue);
    rr.add(record);
    rrSet.setResourceRecords(rr);
    change.setResourceRecordSet(rrSet);
    changes.add(change);
    cb.setChanges(changes);
    crrsReq.setChangeBatch(cb);
    ChangeResourceRecordSetsResult result = client.changeResourceRecordSets(crrsReq);
    logger.debug("Result for the last ChangeResourceRecordSets request: " + result.toString());
}