Search in sources :

Example 1 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class InstanceGroupToInstanceGroupResponseConverter method convert.

public InstanceGroupResponse convert(InstanceGroup source, Boolean includeAllInstances) {
    InstanceGroupResponse instanceGroupResponse = new InstanceGroupResponse();
    instanceGroupResponse.setName(source.getGroupName());
    if (source.getTemplate() != null) {
        instanceGroupResponse.setInstanceTemplate(templateResponseConverter.convert(source.getTemplate()));
    }
    Set<InstanceMetaData> metaDataSet = includeAllInstances ? source.getInstanceMetaDataSet() : source.getNotTerminatedInstanceMetaDataSet();
    instanceGroupResponse.setMetaData(metaDataConverter.convert(metaDataSet));
    if (source.getSecurityGroup() != null) {
        instanceGroupResponse.setSecurityGroup(securityGroupConverter.convert(source.getSecurityGroup()));
    }
    if (source.getInstanceGroupNetwork() != null) {
        instanceGroupResponse.setNetwork(instanceGroupNetworkConverter.convert(source.getInstanceGroupNetwork()));
    }
    instanceGroupResponse.setNodeCount(source.getNodeCount());
    instanceGroupResponse.setName(source.getGroupName());
    return instanceGroupResponse;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceGroupResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)

Example 2 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class FreeIpaDownscaleActions method downscaleAddAdditionalHostnamesAction.

@Bean(name = "DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_STATE")
public Action<?, ?> downscaleAddAdditionalHostnamesAction() {
    return new AbstractDownscaleAction<>(CollectAdditionalHostnamesResponse.class) {

        @Override
        protected void doExecute(StackContext context, CollectAdditionalHostnamesResponse payload, Map<Object, Object> variables) throws Exception {
            Stack stack = context.getStack();
            Set<String> knownHostnamesFromStack = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).collect(Collectors.toSet());
            List<String> currentHostsToRemove = getDownscaleHosts(variables);
            Set<String> newHostsToRemove = payload.getHostnames().stream().filter(hostname -> !currentHostsToRemove.contains(hostname)).filter(hostname -> !knownHostnamesFromStack.contains(hostname)).collect(Collectors.toSet());
            if (isRepair(variables) && !newHostsToRemove.isEmpty()) {
                LOGGER.info("Adding hostnames [{}] to the list of hostnames to remove", newHostsToRemove);
                List<String> allHostnamesToRemove = new LinkedList<>(currentHostsToRemove);
                allHostnamesToRemove.addAll(newHostsToRemove);
                setDownscaleHosts(variables, allHostnamesToRemove);
            }
            sendEvent(context, DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) DOWNSCALE_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_FINISHED_EVENT) Action(org.springframework.statemachine.action.Action) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_ADD_ADDITIONAL_HOSTNAMES_FINISHED_EVENT) LoggerFactory(org.slf4j.LoggerFactory) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) ClientErrorException(javax.ws.rs.ClientErrorException) CollectAdditionalHostnamesRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesRequest) RemoveHostsFromOrchestrationSuccess(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationSuccess) DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FINISHED_EVENT) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) Map(java.util.Map) ClusterProxyUpdateRegistrationFailedToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.ClusterProxyUpdateRegistrationFailedToDownscaleFailureEventConverter) ClusterProxyUpdateRegistrationRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.clusterproxy.ClusterProxyUpdateRegistrationRequest) DownscaleStackCollectResourcesRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesRequest) EnvironmentEndpoint(com.sequenceiq.environment.api.v1.environment.endpoint.EnvironmentEndpoint) PayloadConverter(com.sequenceiq.flow.core.PayloadConverter) RemoveReplicationAgreementsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removereplication.RemoveReplicationAgreementsRequest) RevokeCertsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsResponse) UPDATE_METADATA_FOR_DELETION_REQUEST_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.UPDATE_METADATA_FOR_DELETION_REQUEST_FINISHED_EVENT) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) Set(java.util.Set) WebApplicationExceptionMessageExtractor(com.sequenceiq.cloudbreak.common.exception.WebApplicationExceptionMessageExtractor) FlowParameters(com.sequenceiq.flow.core.FlowParameters) DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FAILED_EVENT) Collectors(java.util.stream.Collectors) RevokeCertsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.cert.RevokeCertsRequest) STARTING_DOWNSCALE_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.STARTING_DOWNSCALE_FINISHED_EVENT) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) UpdateDnsSoaRecordsRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsRequest) RemoveDnsResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RemoveDnsResponseToDownscaleFailureEventConverter) Objects(java.util.Objects) Configuration(org.springframework.context.annotation.Configuration) DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.DownscaleStackCollectResourcesResultToDownscaleFailureEventConverter) DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_ENVIRONMENT_STACK_CONFIG_FINISHED_EVENT) List(java.util.List) DownscaleStackCollectResourcesResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackCollectResourcesResult) StackUpdater(com.sequenceiq.freeipa.service.stack.StackUpdater) Flow(com.sequenceiq.flow.core.Flow) CollectAdditionalHostnamesResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesResponse) KerberosConfigUpdateService(com.sequenceiq.freeipa.service.config.KerberosConfigUpdateService) InstanceGroupService(com.sequenceiq.freeipa.service.stack.instance.InstanceGroupService) RevokeCertsResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RevokeCertsResponseToDownscaleFailureEventConverter) DownscaleStackResultToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.DownscaleStackResultToDownscaleFailureEventConverter) RemoveServersResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RemoveServersResponseToDownscaleFailureEventConverter) StopTelemetryRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryRequest) DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.DOWNSCALE_UPDATE_KERBEROS_NAMESERVERS_CONFIG_FAILED_EVENT) FAIL_HANDLED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.FAIL_HANDLED_EVENT) UPDATE_METADATA_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent.UPDATE_METADATA_FINISHED_EVENT) StopTelemetryResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.stoptelemetry.StopTelemetryResponse) DownscaleStackResult(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackResult) RemoveServersResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersResponse) UpdateDnsSoaRecordsResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.dnssoarecords.UpdateDnsSoaRecordsResponse) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) StateContext(org.springframework.statemachine.StateContext) DownscaleFlowEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleFlowEvent) CleanupEvent(com.sequenceiq.freeipa.flow.freeipa.cleanup.CleanupEvent) LinkedList(java.util.LinkedList) RemoveServersRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removeserver.RemoveServersRequest) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) RemoveHostsFromOrchestrationRequest(com.sequenceiq.freeipa.flow.freeipa.downscale.event.removehosts.RemoveHostsFromOrchestrationRequest) Logger(org.slf4j.Logger) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ClusterProxyUpdateRegistrationSuccess(com.sequenceiq.freeipa.flow.freeipa.provision.event.clusterproxy.ClusterProxyUpdateRegistrationSuccess) DownscaleState(com.sequenceiq.freeipa.flow.freeipa.downscale.DownscaleState) RemoveDnsResponse(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsResponse) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) DownscaleFailureEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleFailureEvent) TerminationService(com.sequenceiq.freeipa.flow.stack.termination.action.TerminationService) DownscaleEvent(com.sequenceiq.freeipa.flow.freeipa.downscale.event.DownscaleEvent) SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) RemoveHostsResponseToDownscaleFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.downscale.failure.RemoveHostsResponseToDownscaleFailureEventConverter) Bean(org.springframework.context.annotation.Bean) RemoveDnsRequest(com.sequenceiq.freeipa.flow.freeipa.cleanup.event.dns.RemoveDnsRequest) Collections(java.util.Collections) DownscaleStackRequest(com.sequenceiq.cloudbreak.cloud.event.resource.DownscaleStackRequest) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) StackContext(com.sequenceiq.freeipa.flow.stack.StackContext) CollectAdditionalHostnamesResponse(com.sequenceiq.freeipa.flow.freeipa.downscale.event.collecthostnames.CollectAdditionalHostnamesResponse) Map(java.util.Map) LinkedList(java.util.LinkedList) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 3 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class ChangePrimaryGatewayActions method clusterProxyRegistrationAction.

@Bean(name = "CHANGE_PRIMARY_GATEWAY_CLUSTERPROXY_REGISTRATION_STATE")
public Action<?, ?> clusterProxyRegistrationAction() {
    return new AbstractChangePrimaryGatewayAction<>(StackEvent.class) {

        @Override
        protected void doExecute(ChangePrimaryGatewayContext context, StackEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Changing the primary gateway cluster proxy registration");
            List<String> repairInstanceIds = getInstanceIds(variables);
            ClusterProxyUpdateRegistrationRequest request;
            if (Objects.nonNull(repairInstanceIds)) {
                List<String> instanceIdsToRegister = stack.getNotDeletedInstanceMetaDataList().stream().map(InstanceMetaData::getInstanceId).filter(instanceId -> !repairInstanceIds.contains(instanceId)).collect(Collectors.toList());
                LOGGER.debug("When changing the primary gateway cluster proxy in stack {}, [{}] will be reregistered", stack.getId(), instanceIdsToRegister);
                request = new ClusterProxyUpdateRegistrationRequest(stack.getId(), instanceIdsToRegister);
            } else {
                LOGGER.debug("When changing the primary gateway cluster proxy in stack {}, the whole stack will be reregistered", stack.getId());
                request = new ClusterProxyUpdateRegistrationRequest(stack.getId());
            }
            sendEvent(context, request.selector(), request);
        }
    };
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Action(org.springframework.statemachine.action.Action) HealthCheckFailedToChangePrimaryGatewayFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.failure.HealthCheckFailedToChangePrimaryGatewayFailureEventConverter) ChangePrimaryGatewaySelectionRequest(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionRequest) LoggerFactory(org.slf4j.LoggerFactory) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ArrayList(java.util.ArrayList) ChangePrimaryGatewayEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent) Inject(javax.inject.Inject) ClusterProxyUpdateRegistrationFailedToChangePrimaryGatewayFailureEventConverter(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.failure.ClusterProxyUpdateRegistrationFailedToChangePrimaryGatewayFailureEventConverter) HealthCheckRequest(com.sequenceiq.freeipa.flow.stack.HealthCheckRequest) StateContext(org.springframework.statemachine.StateContext) Map(java.util.Map) ChangePrimaryGatewayFlowEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayFlowEvent) ClusterProxyUpdateRegistrationRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.clusterproxy.ClusterProxyUpdateRegistrationRequest) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) PayloadConverter(com.sequenceiq.flow.core.PayloadConverter) CHANGE_PRIMARY_GATEWAY_METADATA_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_METADATA_FINISHED_EVENT) Logger(org.slf4j.Logger) FAIL_HANDLED_EVENT(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayFlowEvent.FAIL_HANDLED_EVENT) CHANGE_PRIMARY_GATEWAY_METADATA_FAILED_EVENT(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_METADATA_FAILED_EVENT) CHANGE_PRIMARY_GATEWAY_STARTING_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_STARTING_FINISHED_EVENT) FailureDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.FailureDetails) Set(java.util.Set) FlowParameters(com.sequenceiq.flow.core.FlowParameters) Collectors(java.util.stream.Collectors) HealthCheckSuccess(com.sequenceiq.freeipa.flow.stack.HealthCheckSuccess) OperationService(com.sequenceiq.freeipa.service.operation.OperationService) Objects(java.util.Objects) Configuration(org.springframework.context.annotation.Configuration) ChangePrimaryGatewayFailureEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayFailureEvent) CHANGE_PRIMARY_GATEWAY_FINISHED_EVENT(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayFlowEvent.CHANGE_PRIMARY_GATEWAY_FINISHED_EVENT) ChangePrimaryGatewayService(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayService) List(java.util.List) ChangePrimaryGatewayState(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayState) StackUpdater(com.sequenceiq.freeipa.service.stack.StackUpdater) Flow(com.sequenceiq.flow.core.Flow) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) SuccessDetails(com.sequenceiq.freeipa.api.v1.freeipa.user.model.SuccessDetails) Bean(org.springframework.context.annotation.Bean) ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) Collections(java.util.Collections) ChangePrimaryGatewaySelectionSuccess(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionSuccess) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) ClusterProxyUpdateRegistrationRequest(com.sequenceiq.freeipa.flow.freeipa.provision.event.clusterproxy.ClusterProxyUpdateRegistrationRequest) ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) Map(java.util.Map) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 4 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class DiagnosticsPreFlightCheckHandler method executeOperation.

@Override
public Selectable executeOperation(HandlerEvent<DiagnosticsCollectionEvent> event) throws Exception {
    DiagnosticsCollectionEvent data = event.getData();
    Long resourceId = data.getResourceId();
    String resourceCrn = data.getResourceCrn();
    DiagnosticParameters parameters = data.getParameters();
    Stack stack = stackService.getByIdWithListsInTransaction(resourceId);
    Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.findNotTerminatedForStack(resourceId);
    instanceMetaDataSet.stream().filter(im -> im.getInstanceMetadataType() == InstanceMetadataType.GATEWAY_PRIMARY).forEach(instance -> executeNetworkReport(stack, instance));
    return DiagnosticsCollectionEvent.builder().withResourceCrn(resourceCrn).withResourceId(resourceId).withSelector(START_DIAGNOSTICS_INIT_EVENT.selector()).withParameters(parameters).build();
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceMetaDataService(com.sequenceiq.freeipa.service.stack.instance.InstanceMetaDataService) Logger(org.slf4j.Logger) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) LoggerFactory(org.slf4j.LoggerFactory) START_DIAGNOSTICS_INIT_EVENT(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionStateSelectors.START_DIAGNOSTICS_INIT_EVENT) Set(java.util.Set) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) NodeStatusProto(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto) InstanceMetadataType(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetadataType) Inject(javax.inject.Inject) FreeIpaNodeStatusService(com.sequenceiq.freeipa.service.stack.FreeIpaNodeStatusService) Component(org.springframework.stereotype.Component) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) StackService(com.sequenceiq.freeipa.service.stack.StackService) PREFLIGHT_CHECK_DIAGNOSTICS_EVENT(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionHandlerSelectors.PREFLIGHT_CHECK_DIAGNOSTICS_EVENT) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) DiagnosticParameters(com.sequenceiq.common.model.diagnostics.DiagnosticParameters) DiagnosticsCollectionEvent(com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 5 with InstanceMetaData

use of com.sequenceiq.freeipa.entity.InstanceMetaData in project cloudbreak by hortonworks.

the class StackStatusTest method setUp.

void setUp(int instanceCount) throws Exception {
    underTest.setLocalId(STACK_ID.toString());
    stack = new Stack();
    stack.setId(STACK_ID);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setDetailedStackStatus(DetailedStackStatus.PROVISIONED);
    stack.setStackStatus(stackStatus);
    when(stackService.getByIdWithListsInTransaction(STACK_ID)).thenReturn(stack);
    when(flowLogService.isOtherFlowRunning(STACK_ID)).thenReturn(false);
    InstanceGroup instanceGroup1 = new InstanceGroup();
    Set<InstanceMetaData> instances = new HashSet<>();
    if (instanceCount >= 1) {
        instances.add(createInstance(INSTANCE_1));
    }
    if (instanceCount >= 2) {
        instances.add(createInstance(INSTANCE_2));
    }
    if (instanceCount >= 3) {
        instances.add(createInstance(INSTANCE_3));
    }
    instanceGroup1.setInstanceMetaData(instances);
    stack.setInstanceGroups(Set.of(instanceGroup1));
    notTerminatedInstances = instances;
    when(instanceMetaDataService.findNotTerminatedForStack(STACK_ID)).thenReturn(notTerminatedInstances);
    rpcResponse = new RPCResponse<>();
    when(freeIpaInstanceHealthDetailsService.checkFreeIpaHealth(eq(stack), any())).thenReturn(rpcResponse);
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup) HashSet(java.util.HashSet)

Aggregations

InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)163 Stack (com.sequenceiq.freeipa.entity.Stack)104 Test (org.junit.jupiter.api.Test)77 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)30 List (java.util.List)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)18 Inject (javax.inject.Inject)18 Set (java.util.Set)16 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)13 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)13 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)12 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)11 StackService (com.sequenceiq.freeipa.service.stack.StackService)10 ArrayList (java.util.ArrayList)10 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)9 HealthDetailsFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse)9 Operation (com.sequenceiq.freeipa.entity.Operation)9