Search in sources :

Example 51 with HostGroup

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

the class HostGroupV4RequestToHostGroupConverterTest method testConvertWhenHostNameUpperCase.

@Test
public void testConvertWhenHostNameUpperCase() {
    HostGroupV4Request source = new HostGroupV4Request();
    source.setName("MixEdName");
    HostGroup actual = underTest.convert(source);
    assertEquals(actual.getName(), "mixedname");
}
Also used : HostGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.HostGroupV4Request) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Test(org.junit.jupiter.api.Test)

Example 52 with HostGroup

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

the class DatahubRestResourceAuditEventConverter method requestParameters.

@Override
public Map<String, Object> requestParameters(StructuredRestCallEvent structuredEvent) {
    Map<String, Object> params = legacyRestCommonService.addClusterCrnAndNameIfPresent(structuredEvent);
    OperationDetails operation = structuredEvent.getOperation();
    Optional<Stack> stack = stackService.findStackByNameAndWorkspaceId(operation.getResourceName(), operation.getWorkspaceId());
    AuditEventName auditEventName = auditEventName(structuredEvent);
    if (stack.isPresent() && auditEventName == AuditEventName.RESIZE_DATAHUB_CLUSTER) {
        Json json = new Json(structuredEvent.getRestCall().getRestRequest().getBody());
        String group = json.getValue("group");
        HostGroup hostGroup = hostGroupService.getByClusterIdAndNameWithRecipes(stack.get().getCluster().getId(), group);
        Integer desiredCount = json.getValue("desiredCount");
        Integer originalNodeCount = hostGroup.getInstanceGroup().getNodeCount();
        params.put("desiredCount", desiredCount);
        params.put("originalCount", originalNodeCount);
        params.put("hostGroup", group);
    }
    return params;
}
Also used : OperationDetails(com.sequenceiq.cloudbreak.structuredevent.event.legacy.OperationDetails) AuditEventName(com.sequenceiq.cloudbreak.audit.model.AuditEventName) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Json(com.sequenceiq.cloudbreak.common.json.Json) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Example 53 with HostGroup

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

the class ClouderaManagerModificationServiceTest method setUp.

@BeforeEach
void setUp() {
    MockitoAnnotations.openMocks(this);
    stack.setName(STACK_NAME);
    cluster = new Cluster();
    cluster.setId(CLUSTER_ID);
    cluster.setName(STACK_NAME);
    stack.setCluster(cluster);
    stack.setResourceCrn("crn:cdp:cloudbreak:us-west-1:someone:stack:12345");
    hostGroup = new HostGroup();
    hostGroup.setName(HOST_GROUP_NAME);
}
Also used : Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 54 with HostGroup

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

the class ClouderaManagerDecomissionerTest method createHostGroup.

private HostGroup createHostGroup() {
    HostGroup hostGroup = new HostGroup();
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setInstanceMetaData(Set.of(createDeletedInstanceMetadata(), createRunningInstanceMetadata()));
    hostGroup.setInstanceGroup(instanceGroup);
    return hostGroup;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 55 with HostGroup

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

the class ClouderaManagerDecommisionerTest method createTestHostGroup.

private HostGroup createTestHostGroup(Long id, String name, int hostCount) {
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(name);
    hostGroup.setId(id);
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setGroupName(name);
    Set<InstanceMetaData> instanceMetaDatas = new HashSet<>();
    for (long i = 0; i < hostCount; i++) {
        InstanceMetaData instanceMetaData = new InstanceMetaData();
        instanceMetaData.setInstanceId(name + "-instanceid-" + i);
        instanceMetaData.setDiscoveryFQDN(name + "-host-" + i);
        instanceMetaData.setInstanceGroup(instanceGroup);
        instanceMetaData.setInstanceStatus(InstanceStatus.SERVICES_HEALTHY);
        instanceMetaDatas.add(instanceMetaData);
    }
    instanceGroup.setInstanceMetaData(instanceMetaDatas);
    hostGroup.setInstanceGroup(instanceGroup);
    return hostGroup;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) HashSet(java.util.HashSet)

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