Search in sources :

Example 1 with ClusterServicesRestartResult

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartResult in project cloudbreak by hortonworks.

the class ClusterServicesRestartHandler method accept.

@Override
public void accept(Event<ClusterServicesRestartRequest> event) {
    ClusterServicesRestartRequest request = event.getData();
    ClusterServicesRestartResult result;
    int requestId;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        Optional<Stack> datalakeStack = datalakeService.getDatalakeStackByDatahubStack(stack);
        CmTemplateProcessor blueprintProcessor = getCmTemplateProcessor(stack.getCluster());
        if (datalakeStack.isPresent() && clusterServicesRestartService.isRDCRefreshNeeded(stack, datalakeStack.get())) {
            LOGGER.info("Deploying client config and restarting services");
            requestId = clusterServicesRestartService.refreshClusterOnRestart(stack, datalakeStack.get(), blueprintProcessor);
        } else {
            LOGGER.info("Restarting services");
            requestId = apiConnectors.getConnector(stack).clusterModificationService().restartClusterServices();
        }
        result = new ClusterServicesRestartResult(request, requestId);
    } catch (Exception e) {
        result = new ClusterServicesRestartResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : ClusterServicesRestartResult(com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartResult) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) ClusterServicesRestartRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 ClusterServicesRestartRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartRequest)1 ClusterServicesRestartResult (com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartResult)1