Search in sources :

Example 1 with RecordData

use of com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData in project vespa by vespa-engine.

the class ApplicationController method registerRotationInDns.

/**
 * Register a DNS name for rotation
 */
private void registerRotationInDns(Rotation rotation, String dnsName) {
    try {
        Optional<Record> record = nameService.findRecord(Record.Type.CNAME, RecordName.from(dnsName));
        RecordData rotationName = RecordData.fqdn(rotation.name());
        if (record.isPresent()) {
            // Ensure that the existing record points to the correct rotation
            if (!record.get().data().equals(rotationName)) {
                nameService.updateRecord(record.get().id(), rotationName);
                log.info("Updated mapping for record ID " + record.get().id().asString() + ": '" + dnsName + "' -> '" + rotation.name() + "'");
            }
        } else {
            RecordId id = nameService.createCname(RecordName.from(dnsName), rotationName);
            log.info("Registered mapping with record ID " + id.asString() + ": '" + dnsName + "' -> '" + rotation.name() + "'");
        }
    } catch (RuntimeException e) {
        log.log(Level.WARNING, "Failed to register CNAME", e);
    }
}
Also used : RecordData(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData) Record(com.yahoo.vespa.hosted.controller.api.integration.dns.Record) RecordId(com.yahoo.vespa.hosted.controller.api.integration.dns.RecordId)

Aggregations

Record (com.yahoo.vespa.hosted.controller.api.integration.dns.Record)1 RecordData (com.yahoo.vespa.hosted.controller.api.integration.dns.RecordData)1 RecordId (com.yahoo.vespa.hosted.controller.api.integration.dns.RecordId)1