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

Java ResourceRecord类代码示例

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

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



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

示例1: createARecords

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
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);

}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:26,代码来源:Route53Test.java


示例2: createCNAMERecords

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
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);

}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:25,代码来源:Route53Test.java


示例3: testChangeResourceRecordSets

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
public static void testChangeResourceRecordSets(AmazonRoute53Client client) {
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId("Z3HKYAOP6P7EX7");
    ChangeBatch batch = new ChangeBatch();
    Collection<Change> changes = new LinkedList<Change>();
    Change change = new Change();
    change.setAction("DELETE");
    ResourceRecordSet rrSet = new ResourceRecordSet();
    rrSet.setName("www.examplethatshouldntbequeried.com.");
    rrSet.setType("A");
    rrSet.setTTL(300L);
    rrSet.setWeight(1L);
    Collection<ResourceRecord> rrs = new LinkedList<ResourceRecord>();
    ResourceRecord e = new ResourceRecord();
    e.setValue("172.31.255.2");
    rrs.add(e);
    rrSet.setResourceRecords(rrs);
    rrSet.setSetIdentifier("1");
    rrSet.setTTL(300L);
    change.setResourceRecordSet(rrSet);
    changes.add(change);
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    client.changeResourceRecordSets(req);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:26,代码来源:Route53Test.java


示例4: getCurrentIP

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Override
public String getCurrentIP() {
	ResourceRecordSet set = getCurrentRecordSet();
	if (set != null && set.getResourceRecords() != null
			&& set.getResourceRecords().size() > 0) {
		ResourceRecord rr = set.getResourceRecords().get(0);
		if (rr != null) {
			return rr.getValue();
		}
	}
	return null;
}
 
开发者ID:maroussil,项目名称:Ec2InstanceStarter,代码行数:13,代码来源:SimpleRecordService.java


示例5: generateResourceRecordSetForARecord

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
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;
}
 
开发者ID:betahikaru,项目名称:ec2-util,代码行数:13,代码来源:AwsRoute53Client.java


示例6: getCurrentIP

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Override
public String getCurrentIP() {
	ResourceRecordSet set = getCurrentRecordSet();
	if (set!=null && set.getResourceRecords() != null && set.getResourceRecords().size() > 0){
		ResourceRecord	rr = set.getResourceRecords().get(0);
		if(rr!=null){
			return rr.getValue();
		}
	}
	return null;
}
 
开发者ID:renatodelgaudio,项目名称:awsroute53,代码行数:12,代码来源:SimpleRecordService.java


示例7: getCurrentAValue

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
/**
 * 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 + "\"");
}
 
开发者ID:elprespufferfish,项目名称:route53-dynamic-dns,代码行数:34,代码来源:UpdateDns.java


示例8: updateAValue

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
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;
        }
    });
}
 
开发者ID:elprespufferfish,项目名称:route53-dynamic-dns,代码行数:35,代码来源:UpdateDns.java


示例9: changeResourceRecordSets0

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Test
public void changeResourceRecordSets0() {
    String batchComment = "I have no idea what I'm doing.";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    changes.add(new Change().withAction("CREATE").withResourceRecordSet(
            new ResourceRecordSet().withName("www." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:28,代码来源:DNS53IntegrationTest.java


示例10: changeResourceRecordSets1

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Test
public void changeResourceRecordSets1() {
    String batchComment = "I have no idea what I'm doing.";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    ResourceRecord resourceRecord2 = new ResourceRecord()
            .withValue("172.31.255.254");
    changes.add(new Change().withAction("CREATE").withResourceRecordSet(
            new ResourceRecordSet().withName("w2." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord, resourceRecord2)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:30,代码来源:DNS53IntegrationTest.java


示例11: changeResourceRecordSets2

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Test
public void changeResourceRecordSets2() {
    String batchComment = "Now I know what I'm doing. Kind of...";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    ResourceRecord resourceRecord2 = new ResourceRecord()
            .withValue("172.31.255.254");
    changes.add(new Change().withAction("DELETE").withResourceRecordSet(
            new ResourceRecordSet().withName("w2." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord, resourceRecord2)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:30,代码来源:DNS53IntegrationTest.java


示例12: changeResourceRecordSets3

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Test
public void changeResourceRecordSets3() {
    String batchComment = "I definitely know what I'm doing.";
    ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
    req.setHostedZoneId(getZoneId(zoneName0));
    ChangeBatch batch = new ChangeBatch();
    batch.setComment(batchComment);
    Collection<Change> changes = new LinkedList<Change>();
    ResourceRecord resourceRecord = new ResourceRecord()
            .withValue("172.31.255.235");
    changes.add(new Change().withAction("DELETE").withResourceRecordSet(
            new ResourceRecordSet().withName("www." + zoneName0)
                    .withType("A").withTTL(300L)
                    .withResourceRecords(resourceRecord)));
    batch.setChanges(changes);
    req.setChangeBatch(batch);
    ChangeResourceRecordSetsResult result = customDNS53Client
            .changeResourceRecordSets(req);

    assertNotNull(result);
    assertNotNull(result.getChangeInfo());
    assertNotNull(result.getChangeInfo().getId());
    assertNotNull(result.getChangeInfo().getStatus());
    assertNotNull(result.getChangeInfo().getSubmittedAt());

    System.out.println(result);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:28,代码来源:DNS53IntegrationTest.java


示例13: testChangeResourceRecordSets0

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Test
public void testChangeResourceRecordSets0(){
	/*ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
	req.setHostedZoneId("Z5A748ACB59134595AAF7FD013A0F4D72");
	ChangeBatch batch = new ChangeBatch();
	batch.setComment("I have no idea what I'm doing.");
	Collection<Change> changes = new LinkedList<Change>();
	ResourceRecord resourceRecord = new ResourceRecord().withValue("172.31.255.1");
	ResourceRecord resourceRecord2 = new ResourceRecord().withValue("172.31.255.2");
	changes.add(new Change().withAction("CREATE").withResourceRecordSet(
			new ResourceRecordSet().withName("www.example-dkim2.com").withType("A").withTTL(300L).withResourceRecords(resourceRecord, resourceRecord2)));
	batch.setChanges(changes);
	req.setChangeBatch(batch);*/

	ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
	req.setHostedZoneId("ZB20159C9F447440CA75A34B7AAB1BFFA");
	ChangeBatch batch = new ChangeBatch();
	batch.setComment("I have no idea what I'm doing.");
	Collection<Change> changes = new LinkedList<Change>();
	ResourceRecord resourceRecord = new ResourceRecord().withValue("172.31.255.1");
	ResourceRecord resourceRecord2 = new ResourceRecord().withValue("172.31.255.2");
	changes.add(new Change().withAction("CREATE").withResourceRecordSet(
			new ResourceRecordSet().withName("www.dkim4.com")
			.withType("A").withTTL(300L).withResourceRecords(resourceRecord, resourceRecord2)));
	batch.setChanges(changes);
	req.setChangeBatch(batch);


	this.getRoute53Client().changeResourceRecordSets(req);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:31,代码来源:DNS53HostedZonesTest.java


示例14: testChangeResourceRecordSets1

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Test
public void testChangeResourceRecordSets1(){
	ChangeResourceRecordSetsRequest req = new ChangeResourceRecordSetsRequest();
	req.setHostedZoneId("ZDF69134B71A944C99CC46E2CEC45E1A0");
	ChangeBatch batch = new ChangeBatch();
	batch.setComment("I have no idea what I'm doing.");
	Collection<Change> changes = new LinkedList<Change>();
	ResourceRecord resourceRecord = new ResourceRecord().withValue("172.31.255.1");
	changes.add(new Change().withAction("DELETE").withResourceRecordSet(
			new ResourceRecordSet().withName("www.example-meh.com.").withType("A").withSetIdentifier("sid0").withWeight(3L)
			.withTTL(300L).withResourceRecords(resourceRecord)));
	batch.setChanges(changes);
	req.setChangeBatch(batch);
	this.getRoute53Client().changeResourceRecordSets(req);
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:16,代码来源:DNS53HostedZonesTest.java


示例15: makeRecordCNAME

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
public ResourceRecordSet makeRecordCNAME(final String source,
		final String target) {

	final Collection<ResourceRecord> resourceList = new ArrayList<ResourceRecord>();
	resourceList.add(new ResourceRecord(target));

	final ResourceRecordSet record = new ResourceRecordSet();
	record.setName(source);
	record.setTTL(60L);
	record.setType("CNAME");
	record.setResourceRecords(resourceList);

	return record;
}
 
开发者ID:jwrapper,项目名称:jwrapper-maven-plugin,代码行数:15,代码来源:CarrotRoute53.java


示例16: deploy

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
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);

    }
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:45,代码来源:WebsiteDeployer.java


示例17: updateRecord

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Override
public boolean updateRecord(String ip) {

	String recordName = config.getRecordName();

	ChangeResourceRecordSetsRequest changeRequest = new ChangeResourceRecordSetsRequest();
	changeRequest.setHostedZoneId(config.getZoneId());
	ChangeBatch batch = new ChangeBatch();
	Change change = new Change();

	ResourceRecordSet set = getCurrentRecordSet();
	if (set != null) {
		if (!equalsIgnoreCase("A", set.getType())) {
			log.error("Record already exists but not as Type A. No actions were performed.");
			return false;
		}
		change.setAction("UPSERT");
		log.info("Record [" + recordName
				+ "] already present on AWS Route 53. Upating it..");
	} else {
		change.setAction("CREATE");
		log.info("Record [" + recordName
				+ "] not present on AWS Route 53. Creating it..");
		set = new ResourceRecordSet().withName(recordName).withType("A");
	}

	set.setTTL(Long.parseLong(config.getTTL()));
	List<ResourceRecord> l = new ArrayList<ResourceRecord>();
	l.add(new ResourceRecord(ip));
	set.setResourceRecords(l);

	change.setResourceRecordSet(set);
	batch.withChanges(change);

	changeRequest.setChangeBatch(batch);

	log.info("Updating DNS " + recordName + " with IP " + ip);

	ChangeResourceRecordSetsResult result = config.getAmazonRoute53Client()
			.changeResourceRecordSets(changeRequest);
	log.info(result.toString());
	return true;
}
 
开发者ID:maroussil,项目名称:Ec2InstanceStarter,代码行数:44,代码来源:SimpleRecordService.java


示例18: updateRecord

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
@Override
public boolean updateRecord(String ip) {
    
    String recordName = config.getRecordName();
	
	ChangeResourceRecordSetsRequest changeRequest = new ChangeResourceRecordSetsRequest();
	changeRequest.setHostedZoneId(config.getZoneId());
	ChangeBatch batch = new ChangeBatch();
	Change change = new Change();
	
	
	ResourceRecordSet set = getCurrentRecordSet();
	if (set!=null){
		if (!equalsIgnoreCase("A", set.getType())){
			log.error("Record already exists but not as Type A. No actions were performed.");
			return false;
		}
		change.setAction("UPSERT");
		log.info("Record ["+recordName+"] already present on AWS Route 53. Upating it..");
	} else{
		change.setAction("CREATE");
		log.info("Record ["+recordName+"] not present on AWS Route 53. Creating it..");
		set = new ResourceRecordSet().withName(recordName).withType("A");
	}

	
	set.setTTL(Long.parseLong(config.getTTL()));
	List<ResourceRecord> l = new ArrayList<ResourceRecord>();
	l.add(new ResourceRecord(ip));
	set.setResourceRecords(l);

	change.setResourceRecordSet(set);
	batch.withChanges(change);

	changeRequest.setChangeBatch(batch);

	log.info("Updating DNS "+recordName+" with IP "+ip);

	ChangeResourceRecordSetsResult result =  config.getAmazonClient().changeResourceRecordSets(changeRequest);
	log.info(result.toString()); 
	return true;
}
 
开发者ID:renatodelgaudio,项目名称:awsroute53,代码行数:43,代码来源:SimpleRecordService.java


示例19: populateServiceMetadata

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
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());
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:75,代码来源:DNS53MetadataUtil.java


示例20: listResourceRecordSets

import com.amazonaws.services.route53.model.ResourceRecord; //导入依赖的package包/类
public ListResourceRecordSetsResult listResourceRecordSets(ListResourceRecordSetsRequest req) throws AmazonServiceException, AmazonClientException{
	Client c = Client.create();
	WebResource r = c.resource(this.serverURL);
	MultivaluedMap<String, String> paramMap = new MultivaluedMapImpl();
	if(req.getStartRecordName() != null){
		paramMap.add("name", req.getStartRecordName());
	}
	if(req.getStartRecordType() != null){
		paramMap.add("type", req.getStartRecordType());
	}
	if(req.getStartRecordIdentifier() != null){
		paramMap.add("identifier", req.getStartRecordIdentifier());
	}
	if(req.getMaxItems() != null){
		paramMap.add("maxitems", req.getMaxItems());	
	}
	
	ClientResponse response = r
			.path(req.getHostedZoneId() + "/rrset")
			.queryParams(paramMap)
			.type(MediaType.APPLICATION_XML_TYPE)
			.accept(MediaType.TEXT_XML)
			.header("X-Amzn-Authorization",
					"AWS3 AWSAccessKeyId=" + this.accessKey + "," +
							"Algorithm=HmacSHA256," +
							"SignedHeaders=Host;X-Amz-Date," +
					"Signature=THISISANEXAMPLESIGNATURE=")
					.get(ClientResponse.class);

	String resultXml = response.getEntity(String.class);
	if(response.getStatus() != 200){
		exceptionMapper(response, resultXml);
	}
	
	
	
	
	ListResourceRecordSetsResponsePOJO interResult = null;
	try {
		StringReader reader = new StringReader(resultXml);
		JAXBContext context = JAXBContext.newInstance(ListResourceRecordSetsResponsePOJO.class);
		Unmarshaller unmarshaller = context.createUnmarshaller();
		interResult = (ListResourceRecordSetsResponsePOJO) unmarshaller.unmarshal(reader);
	} catch (JAXBException e) {
		e.printStackTrace();
		return null;
	}
	if(interResult == null){
		return null;
	}

	ListResourceRecordSetsResult result = new ListResourceRecordSetsResult();
	result.setMaxItems(interResult.getMaxItems());
	result.setIsTruncated(interResult.isTruncated());
	if(interResult.getResourceRecordSets() != null){
		Collection<ResourceRecordSet> rrSets = new LinkedList<ResourceRecordSet>();
		for(ResourceRecordSetPOJO p : interResult.getResourceRecordSets()){
			ResourceRecordSet temp = new ResourceRecordSet();
			temp.setName(p.getName());
			temp.setSetIdentifier(p.getSetIdentifier());
			temp.setTTL(p.getTTL());
			temp.setType(p.getType());
			temp.setWeight(p.getWeight());
			if(p.getResourceRecords() != null){
				Collection<ResourceRecord> resourceRecords = new LinkedList<ResourceRecord>();
				for(ResourceRecordPOJO record : p.getResourceRecords()){
					ResourceRecord newRec = new ResourceRecord();
					newRec.setValue(record.getValue());
					resourceRecords.add(newRec);
				}
				temp.setResourceRecords(resourceRecords);
			}
			rrSets.add(temp);
		}
		result.setResourceRecordSets(rrSets);
	}

	return result;
}
 
开发者ID:TranscendComputing,项目名称:TopStackDNS53,代码行数:80,代码来源:DNS53Client.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DatanodeReportType类代码示例发布时间:2022-05-23
下一篇:
Java WxMpMessageHandler类代码示例发布时间: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