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);
}
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();
}
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));
}
Aggregations