Search in sources :

Example 1 with DnsResolverType

use of com.sequenceiq.cloudbreak.domain.stack.DnsResolverType in project cloudbreak by hortonworks.

the class UpdateDomainDnsResolverHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpdateDomainDnsResolverRequest> updateDomainDnsResolverRequestHandlerEvent) {
    UpdateDomainDnsResolverRequest event = updateDomainDnsResolverRequestHandlerEvent.getData();
    try {
        Stack stack = stackService.getByIdWithLists(event.getResourceId());
        DnsResolverType actualDnsResolverType = targetedUpscaleSupportService.getActualDnsResolverType(stack);
        if (!actualDnsResolverType.equals(stack.getDomainDnsResolver())) {
            LOGGER.debug("New value of domainDnsResolver field for stack {} is {}", stack.getResourceCrn(), actualDnsResolverType);
            stack.setDomainDnsResolver(actualDnsResolverType);
            stackService.save(stack);
            LOGGER.debug("domainDnsResolver field of stack {} has been successfully updated!", stack.getResourceCrn());
        } else {
            LOGGER.debug("Currently set and actual domainDnsResolverType is the same, not need for update, value {}", actualDnsResolverType);
        }
    } catch (Exception e) {
        LOGGER.debug("We couldn't update domainDnsResolver field of stack, so we move on with current value of the field.", e);
    }
    return new UpdateDomainDnsResolverResult(event.getResourceId());
}
Also used : UpdateDomainDnsResolverRequest(com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverRequest) DnsResolverType(com.sequenceiq.cloudbreak.domain.stack.DnsResolverType) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) UpdateDomainDnsResolverResult(com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverResult)

Aggregations

DnsResolverType (com.sequenceiq.cloudbreak.domain.stack.DnsResolverType)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 UpdateDomainDnsResolverRequest (com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverRequest)1 UpdateDomainDnsResolverResult (com.sequenceiq.cloudbreak.reactor.api.event.stack.UpdateDomainDnsResolverResult)1