use of com.yahoo.vespa.hosted.controller.api.integration.dns.RecordId 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);
}
}
Aggregations