Search in sources :

Example 1 with UpdateServiceConfigFailure

use of com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigFailure in project cloudbreak by hortonworks.

the class UpdateServiceConfigHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<UpdateServiceConfigRequest> event) {
    UpdateServiceConfigRequest request = event.getData();
    Stack stack = request.getStack();
    requireNonNull(stack);
    requireNonNull(stack.getCluster());
    try {
        LOGGER.debug("Gathering entries for Hue knox_proxyhosts property.");
        Set<String> proxyhosts = new HashSet<>();
        if (StringUtils.isNotEmpty(stack.getPrimaryGatewayInstance().getDiscoveryFQDN())) {
            proxyhosts.add(stack.getPrimaryGatewayInstance().getDiscoveryFQDN());
        }
        if (StringUtils.isNotEmpty(stack.getPrimaryGatewayInstance().getDiscoveryFQDN())) {
            proxyhosts.add(stack.getCluster().getFqdn());
        }
        String loadBalancerFqdn = loadBalancerConfigService.getLoadBalancerUserFacingFQDN(stack.getId());
        if (StringUtils.isNotEmpty(loadBalancerFqdn)) {
            proxyhosts.add(loadBalancerFqdn);
        }
        LOGGER.debug("Hue knox_proxyhosts setting will be updated to {}", proxyhosts);
        ClusterApi clusterApi = clusterApiConnectors.getConnector(stackService.getByIdWithListsInTransaction(event.getData().getResourceId()));
        clusterApi.clusterModificationService().updateServiceConfigAndRestartService(HUE_SERVICE, HUE_KNOX_PROXYHOSTS, String.join(",", proxyhosts));
        LOGGER.debug("Updating CM frontend URL with load balancer DNS");
        clusterHostServiceRunner.updateClusterConfigs(stack, stack.getCluster());
        LOGGER.debug("Service config update was successful");
        return new UpdateServiceConfigSuccess(stack);
    } catch (Exception e) {
        LOGGER.warn("Error updating HUE and CM service configuration.", e);
        return new UpdateServiceConfigFailure(request.getResourceId(), e);
    }
}
Also used : UpdateServiceConfigRequest(com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigRequest) UpdateServiceConfigFailure(com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigFailure) UpdateServiceConfigSuccess(com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigSuccess) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) HashSet(java.util.HashSet)

Aggregations

ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 UpdateServiceConfigFailure (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigFailure)1 UpdateServiceConfigRequest (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigRequest)1 UpdateServiceConfigSuccess (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigSuccess)1 HashSet (java.util.HashSet)1