Search in sources :

Example 1 with UpdateServiceConfigSuccess

use of com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigSuccess 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)

Example 2 with UpdateServiceConfigSuccess

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

the class StackLoadBalancerUpdateActions method restartCmAction.

@Bean(name = "RESTARTING_CM_STATE")
public Action<?, ?> restartCmAction() {
    return new AbstractStackLoadBalancerUpdateAction<>(UpdateServiceConfigSuccess.class) {

        @Override
        protected void doExecute(StackContext context, UpdateServiceConfigSuccess payload, Map<Object, Object> variables) {
            stackLoadBalancerUpdateService.restartingCm(context.getStack());
            StackContext newContext = new StackContext(context.getFlowParameters(), payload.getStack(), context.getCloudContext(), context.getCloudCredential(), context.getCloudStack());
            sendEvent(newContext);
        }

        @Override
        protected Selectable createRequest(StackContext context) {
            return new RestartCmForLbRequest(context.getStack());
        }
    };
}
Also used : UpdateServiceConfigSuccess(com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigSuccess) RestartCmForLbRequest(com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.RestartCmForLbRequest) StackContext(com.sequenceiq.cloudbreak.core.flow2.stack.StackContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Aggregations

UpdateServiceConfigSuccess (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigSuccess)2 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)1 StackContext (com.sequenceiq.cloudbreak.core.flow2.stack.StackContext)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 RestartCmForLbRequest (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.RestartCmForLbRequest)1 UpdateServiceConfigFailure (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigFailure)1 UpdateServiceConfigRequest (com.sequenceiq.cloudbreak.reactor.api.event.stack.loadbalancer.UpdateServiceConfigRequest)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1