Search in sources :

Example 1 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method addClusterServices.

public NodeReachabilityResult addClusterServices(Long stackId, Map<String, Integer> hostGroupWithAdjustment, boolean repair) {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Cluster cluster = stack.getCluster();
    Map<String, String> candidates = collectUpscaleCandidates(cluster.getId(), hostGroupWithAdjustment);
    Set<String> gatewayHosts = stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata().stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toSet());
    boolean candidatesContainGatewayNode = candidates.keySet().stream().anyMatch(gatewayHosts::contains);
    NodeReachabilityResult nodeReachabilityResult;
    if (!repair && !candidatesContainGatewayNode && targetedUpscaleSupportService.targetedUpscaleOperationSupported(stack)) {
        nodeReachabilityResult = runTargetedClusterServices(stack, cluster, candidates);
    } else {
        nodeReachabilityResult = runClusterServices(stack, cluster, candidates);
    }
    return nodeReachabilityResult;
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 2 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class ClusterHostServiceRunner method addClusterServices.

public NodeReachabilityResult addClusterServices(Stack stack, Cluster cluster, Map<String, Integer> hostGroupWithAdjustment, boolean repair) {
    Map<String, String> candidates = collectUpscaleCandidates(cluster.getId(), hostGroupWithAdjustment);
    Set<String> gatewayHosts = stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata().stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toSet());
    boolean candidatesContainGatewayNode = candidates.keySet().stream().anyMatch(gatewayHosts::contains);
    NodeReachabilityResult nodeReachabilityResult;
    if (!repair && !candidatesContainGatewayNode && targetedUpscaleSupportService.targetedUpscaleOperationSupported(stack)) {
        nodeReachabilityResult = runTargetedClusterServices(stack, cluster, candidates);
    } else {
        nodeReachabilityResult = runClusterServices(stack, cluster, candidates);
    }
    return nodeReachabilityResult;
}
Also used : NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult)

Example 3 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class ClusterManagerUpscaleServiceTest method testUpscaleIfTargetedUpscaleNotSupportedOrPrimaryGatewayChanged.

@Test
public void testUpscaleIfTargetedUpscaleNotSupportedOrPrimaryGatewayChanged() throws ClusterClientInitException {
    Stack stack = getStack();
    when(stackService.getByIdWithListsInTransaction(any())).thenReturn(stack);
    when(clusterService.findOneWithLists(1L)).thenReturn(Optional.of(stack.getCluster()));
    when(clusterHostServiceRunner.addClusterServices(any(), any(), any(), anyBoolean())).thenReturn(new NodeReachabilityResult(Set.of(), Set.of()));
    doNothing().when(clusterServiceRunner).updateAmbariClientConfig(any(), any());
    doNothing().when(clusterService).updateInstancesToRunning(any(), any());
    when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
    underTest.upscaleClusterManager(1L, Collections.singletonMap("hg", 1), true, false);
    verifyNoInteractions(targetedUpscaleSupportService);
    when(targetedUpscaleSupportService.targetedUpscaleOperationSupported(any())).thenReturn(Boolean.FALSE);
    underTest.upscaleClusterManager(1L, Collections.singletonMap("hg", 1), false, false);
    verifyNoMoreInteractions(clusterServiceRunner);
    verify(clusterApi, times(2)).waitForHosts(any());
}
Also used : NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 4 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class ClusterManagerUpscaleServiceTest method testUpscaleIfTargetedUpscaleSupported.

@Test
public void testUpscaleIfTargetedUpscaleSupported() throws ClusterClientInitException {
    Stack stack = getStack();
    when(stackService.getByIdWithListsInTransaction(any())).thenReturn(stack);
    when(clusterService.findOneWithLists(1L)).thenReturn(Optional.of(stack.getCluster()));
    when(clusterHostServiceRunner.addClusterServices(any(), any(), any(), anyBoolean())).thenReturn(new NodeReachabilityResult(Set.of(), Set.of()));
    doNothing().when(clusterService).updateInstancesToRunning(any(), any());
    when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
    when(targetedUpscaleSupportService.targetedUpscaleOperationSupported(any())).thenReturn(Boolean.TRUE);
    underTest.upscaleClusterManager(1L, Collections.singletonMap("hg", 1), false, false);
    verifyNoInteractions(clusterServiceRunner);
    verify(clusterApi).waitForHosts(any());
}
Also used : NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 5 with NodeReachabilityResult

use of com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult in project cloudbreak by hortonworks.

the class StackUtil method collectReachableAndUnreachableNodes.

public NodeReachabilityResult collectReachableAndUnreachableNodes(Stack stack) {
    NodeReachabilityResult nodeReachabilityResult = hostOrchestrator.getResponsiveNodes(collectNodes(stack), gatewayConfigService.getPrimaryGatewayConfig(stack));
    LOGGER.debug("Node reachability result: {}", nodeReachabilityResult);
    return nodeReachabilityResult;
}
Also used : NodeReachabilityResult(com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult)

Aggregations

NodeReachabilityResult (com.sequenceiq.cloudbreak.orchestrator.model.NodeReachabilityResult)14 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)9 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)8 Test (org.junit.jupiter.api.Test)6 HashSet (java.util.HashSet)5 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)4 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)4 TemporaryStorage (com.sequenceiq.cloudbreak.common.type.TemporaryStorage)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 HostOrchestrator (com.sequenceiq.cloudbreak.orchestrator.host.HostOrchestrator)3 InstanceMetaDataService (com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService)3 IOException (java.io.IOException)3 Map (java.util.Map)3 Set (java.util.Set)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)2 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)2 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)2