Search in sources :

Example 1 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class RecipeEngineTest method testUploadUpscaleRecipesWithoutRecipe.

@Test
public void testUploadUpscaleRecipesWithoutRecipe() throws CloudbreakException {
    // GIVEN
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName("worker");
    // WHEN
    recipeEngine.uploadUpscaleRecipes(stack(), Set.of(hostGroup), hostGroups());
    // THEN
    verify(orchestratorRecipeExecutor, times(0)).uploadRecipes(any(Stack.class), anyMap());
    verify(recipeTemplateService, times(0)).updateAllGeneratedRecipes(anySet(), anyMap());
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup 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 HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClusterUpscaleService method uploadRecipesOnNewHosts.

public void uploadRecipesOnNewHosts(Long stackId, Set<String> hostGroupNames) throws CloudbreakException {
    Stack stack = stackService.getByIdWithListsInTransaction(stackId);
    LOGGER.debug("Start executing pre recipes");
    Set<HostGroup> hostGroups = hostGroupService.getByClusterWithRecipes(stack.getCluster().getId());
    Set<HostGroup> targetHostGroups = hostGroups.stream().filter(hostGroup -> hostGroupNames.contains(hostGroup.getName())).collect(Collectors.toSet());
    recipeEngine.uploadUpscaleRecipes(stack, targetHostGroups, hostGroups);
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) CloudbreakException(com.sequenceiq.cloudbreak.service.CloudbreakException) LoggerFactory(org.slf4j.LoggerFactory) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) Function(java.util.function.Function) KerberosConfigService(com.sequenceiq.cloudbreak.kerberos.KerberosConfigService) ClusterApi(com.sequenceiq.cloudbreak.cluster.api.ClusterApi) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) Map(java.util.Map) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) RecipeEngine(com.sequenceiq.cloudbreak.service.cluster.flow.recipe.RecipeEngine) Logger(org.slf4j.Logger) ParcelOperationStatus(com.sequenceiq.cloudbreak.cluster.model.ParcelOperationStatus) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) ParcelService(com.sequenceiq.cloudbreak.service.parcel.ParcelService) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) List(java.util.List) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) KerberosConfig(com.sequenceiq.cloudbreak.dto.KerberosConfig) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 4 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup 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 5 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClusterRepairFlowEventChainFactoryTest method setupHostGroup.

private HostGroup setupHostGroup(InstanceGroup instanceGroup) {
    HostGroup hostGroup = mock(HostGroup.class);
    when(hostGroup.getName()).thenReturn("hostGroupName");
    when(hostGroup.getInstanceGroup()).thenReturn(instanceGroup);
    return hostGroup;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)132 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)66 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)60 HashSet (java.util.HashSet)55 Test (org.junit.jupiter.api.Test)52 List (java.util.List)50 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)43 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)37 Map (java.util.Map)37 Set (java.util.Set)37 Collectors (java.util.stream.Collectors)35 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)25 Optional (java.util.Optional)25 ArrayList (java.util.ArrayList)24 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)22 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)21 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)21 HashMap (java.util.HashMap)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19