Search in sources :

Example 1 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class ClusterMonitoringEngineTest method createInstanceMetadataSet.

private Set<InstanceMetaData> createInstanceMetadataSet() {
    Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
    InstanceMetaData instanceMetaData = new InstanceMetaData();
    instanceMetaData.setId(1L);
    InstanceGroup instanceGroup = new InstanceGroup();
    Template template = new Template();
    instanceGroup.setTemplate(template);
    instanceMetaData.setInstanceGroup(instanceGroup);
    instanceMetaDataSet.add(instanceMetaData);
    return instanceMetaDataSet;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template)

Example 2 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class ClusterBuilderService method finalizeClusterInstall.

public void finalizeClusterInstall(Long stackId) throws CloudbreakException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    Set<HostGroup> hostGroups = hostGroupService.getByClusterWithRecipes(stack.getCluster().getId());
    try {
        transactionService.required(() -> {
            Set<InstanceMetaData> instanceMetaDatas = loadInstanceMetadataForHostGroups(hostGroups).values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
            finalizeClusterInstallHandlerService.finalizeClusterInstall(instanceMetaDatas, stack.getCluster());
        });
    } catch (TransactionExecutionException e) {
        throw new CloudbreakException(e.getCause());
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 3 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class ClusterUpscaleServiceTest method testInstallServicesOnNewHostWithRestartButThereIsAnUnhealthyNode.

@Test
public void testInstallServicesOnNewHostWithRestartButThereIsAnUnhealthyNode() throws CloudbreakException {
    Stack stack = new Stack();
    stack.setId(1L);
    Cluster cluster = new Cluster();
    cluster.setId(2L);
    stack.setCluster(cluster);
    when(stackService.getByIdWithClusterInTransaction(eq(1L))).thenReturn(stack);
    ClusterApi clusterApi = mock(ClusterApi.class);
    when(clusterApiConnectors.getConnector(any(Stack.class))).thenReturn(clusterApi);
    HostGroup hostGroup = new HostGroup();
    InstanceGroup instanceGroup = new InstanceGroup();
    InstanceMetaData im1 = new InstanceMetaData();
    im1.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    InstanceMetaData im2 = new InstanceMetaData();
    im2.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
    InstanceMetaData im3 = new InstanceMetaData();
    im3.setInstanceStatus(InstanceStatus.DELETED_BY_PROVIDER);
    stack.setInstanceGroups(Set.of(instanceGroup));
    instanceGroup.setInstanceMetaData(Set.of(im1, im2, im3));
    hostGroup.setInstanceGroup(instanceGroup);
    when(hostGroupService.getByClusterWithRecipes(any())).thenReturn(Set.of(hostGroup));
    when(parcelService.removeUnusedParcelComponents(stack)).thenReturn(new ParcelOperationStatus(Collections.emptyMap(), Collections.emptyMap()));
    underTest.installServicesOnNewHosts(1L, Set.of("master"), true, true);
    verify(clusterApi, times(1)).upscaleCluster(any());
    verify(clusterApi, times(0)).restartAll(false);
    verify(parcelService).removeUnusedParcelComponents(stack);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.jupiter.api.Test)

Example 4 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class ClusterBootstrapper method collectAndCheckGateways.

private List<GatewayConfig> collectAndCheckGateways(Stack stack) {
    LOGGER.info("Collect and check gateways for {}", stack.getName());
    List<GatewayConfig> allGatewayConfig = new ArrayList<>();
    for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, isKnoxEnabled(stack));
        LOGGER.info("Add gateway config: {}", gatewayConfig);
        allGatewayConfig.add(gatewayConfig);
        ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
        validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
    }
    return allGatewayConfig;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ArrayList(java.util.ArrayList) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 5 with InstanceMetaData

use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.

the class ClusterBootstrapper method bootstrapNewNodesOnHost.

private void bootstrapNewNodesOnHost(Stack stack, List<GatewayConfig> allGatewayConfigs, Set<Node> nodes, Set<Node> allNodes) throws CloudbreakOrchestratorException {
    LOGGER.info("Bootstrap new nodes: {}", nodes);
    Cluster cluster = stack.getCluster();
    Boolean enableKnox = cluster.getGateway() != null;
    for (InstanceMetaData gateway : stack.getNotTerminatedAndNotZombieGatewayInstanceMetadata()) {
        GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gateway, enableKnox);
        ExtendedPollingResult bootstrapApiPolling = hostBootstrapApiPollingService.pollWithAbsoluteTimeout(hostBootstrapApiCheckerTask, new HostBootstrapApiContext(stack, gatewayConfig, hostOrchestrator), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
        validatePollingResultForCancellation(bootstrapApiPolling.getPollingResult(), "Polling of bootstrap API was cancelled.");
    }
    byte[] stateZip = null;
    ClusterComponent stateComponent = clusterComponentProvider.getComponent(cluster.getId(), ComponentType.SALT_STATE);
    if (stateComponent != null) {
        String content = (String) stateComponent.getAttributes().getMap().getOrDefault(ComponentType.SALT_STATE.name(), "");
        if (!content.isEmpty()) {
            stateZip = Base64.decodeBase64(content);
        }
    }
    BootstrapParams params = createBootstrapParams(stack);
    hostOrchestrator.bootstrapNewNodes(allGatewayConfigs, nodes, allNodes, stateZip, params, clusterDeletionBasedModel(stack.getId(), null));
    InstanceMetaData primaryGateway = stack.getPrimaryGatewayInstance();
    GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, primaryGateway, enableKnox);
    ExtendedPollingResult allNodesAvailabilityPolling = hostClusterAvailabilityPollingService.pollWithAbsoluteTimeout(hostClusterAvailabilityCheckerTask, new HostOrchestratorClusterContext(stack, hostOrchestrator, gatewayConfig, nodes), POLL_INTERVAL, MAX_POLLING_ATTEMPTS);
    validatePollingResultForCancellation(allNodesAvailabilityPolling.getPollingResult(), "Polling of new nodes availability was cancelled.");
    if (allNodesAvailabilityPolling.isTimeout()) {
        clusterBootstrapperErrorHandler.terminateFailedNodes(hostOrchestrator, null, stack, gatewayConfig, nodes);
    }
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostOrchestratorClusterContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostOrchestratorClusterContext) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) BootstrapParams(com.sequenceiq.cloudbreak.orchestrator.model.BootstrapParams) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ExtendedPollingResult(com.sequenceiq.cloudbreak.polling.ExtendedPollingResult) HostBootstrapApiContext(com.sequenceiq.cloudbreak.core.bootstrap.service.host.context.HostBootstrapApiContext) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)415 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)165 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)152 Test (org.junit.jupiter.api.Test)143 Map (java.util.Map)92 HashSet (java.util.HashSet)90 Set (java.util.Set)86 List (java.util.List)84 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)77 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)73 Collectors (java.util.stream.Collectors)71 ArrayList (java.util.ArrayList)62 Test (org.junit.Test)60 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)57 Optional (java.util.Optional)52 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)48 Inject (javax.inject.Inject)47 Logger (org.slf4j.Logger)47 LoggerFactory (org.slf4j.LoggerFactory)47 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)45