Search in sources :

Example 1 with ClusterServicesRestartRequest

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

the class CusterServicesRestartHandlerTest method testRefreshNeeded.

@Test
public void testRefreshNeeded() throws Exception {
    when(clusterServicesRestartService.isRDCRefreshNeeded(any(), any())).thenReturn(true);
    underTest.accept(new Event(new ClusterServicesRestartRequest(stack.getId())));
    verify(clusterServicesRestartService).refreshClusterOnRestart(any(), any(), any());
    verifyNoInteractions(apiConnectors);
}
Also used : Event(reactor.bus.Event) ClusterServicesRestartRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartRequest) Test(org.junit.jupiter.api.Test)

Example 2 with ClusterServicesRestartRequest

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

the class CusterServicesRestartHandlerTest method testRefreshNotNeeded.

@Test
public void testRefreshNotNeeded() throws Exception {
    when(apiConnectors.getConnector(any(Stack.class))).thenReturn(connector);
    when(connector.clusterModificationService()).thenReturn(clusterModificationService);
    when(clusterServicesRestartService.isRDCRefreshNeeded(any(), any())).thenReturn(false);
    underTest.accept(new Event(new ClusterServicesRestartRequest(stack.getId())));
    verify(clusterServicesRestartService, times(0)).refreshClusterOnRestart(any(), any(), any());
    verify(clusterModificationService).restartClusterServices();
}
Also used : Event(reactor.bus.Event) ClusterServicesRestartRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartRequest) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 3 with ClusterServicesRestartRequest

use of com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartRequest 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

ClusterServicesRestartRequest (com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartRequest)3 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 Test (org.junit.jupiter.api.Test)2 Event (reactor.bus.Event)2 CmTemplateProcessor (com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor)1 ClusterServicesRestartResult (com.sequenceiq.cloudbreak.reactor.api.event.cluster.restart.ClusterServicesRestartResult)1