Search in sources :

Example 31 with Stack

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

the class ChangePrimaryGatewayActions method startingAction.

@Bean(name = "CHANGE_PRIMARY_GATEWAY_STATE_STARTING")
public Action<?, ?> startingAction() {
    return new AbstractChangePrimaryGatewayAction<>(ChangePrimaryGatewayEvent.class) {

        @Override
        protected void doExecute(ChangePrimaryGatewayContext context, ChangePrimaryGatewayEvent payload, Map<Object, Object> variables) {
            Stack stack = context.getStack();
            String operationId = payload.getOperationId();
            setOperationId(variables, operationId);
            setInstanceIds(variables, payload.getRepairInstaceIds());
            setFinalChain(variables, payload.isFinalChain());
            LOGGER.info("Starting to change the primary gateway {}", payload);
            stackUpdater.updateStackStatus(stack.getId(), DetailedStackStatus.REPAIR_IN_PROGRESS, "Starting to change the primary gateway");
            sendEvent(context, CHANGE_PRIMARY_GATEWAY_STARTING_FINISHED_EVENT.selector(), new StackEvent(stack.getId()));
        }
    };
}
Also used : StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) ChangePrimaryGatewayContext(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.ChangePrimaryGatewayContext) Map(java.util.Map) ChangePrimaryGatewayEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayEvent) Stack(com.sequenceiq.freeipa.entity.Stack) Bean(org.springframework.context.annotation.Bean)

Example 32 with Stack

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

the class SelectionHandler method accept.

@Override
public void accept(Event<ChangePrimaryGatewaySelectionRequest> changePrimaryGatewaySelectionRequestEvent) {
    ChangePrimaryGatewaySelectionRequest request = changePrimaryGatewaySelectionRequestEvent.getData();
    Selectable result;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        Optional<String> formerPrimaryGatewayInstanceId = changePrimaryGatewayService.getPrimaryGatewayInstanceId(stack);
        String newPrimaryGatewayInstanceId = changePrimaryGatewayService.selectNewPrimaryGatewayInstanceId(stack, request.getRepairInstanceIds());
        result = new ChangePrimaryGatewaySelectionSuccess(request.getResourceId(), formerPrimaryGatewayInstanceId, newPrimaryGatewayInstanceId);
    } catch (Exception e) {
        LOGGER.error("Failed to select the new primary gateway", e);
        result = new ChangePrimaryGatewayFailureEvent(request.getResourceId(), "Selecting primary gateway", Set.of(), Map.of(), e);
    }
    eventBus.notify(result.selector(), new Event<>(changePrimaryGatewaySelectionRequestEvent.getHeaders(), result));
}
Also used : Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) ChangePrimaryGatewayFailureEvent(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.ChangePrimaryGatewayFailureEvent) ChangePrimaryGatewaySelectionSuccess(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionSuccess) ChangePrimaryGatewaySelectionRequest(com.sequenceiq.freeipa.flow.freeipa.repair.changeprimarygw.event.selection.ChangePrimaryGatewaySelectionRequest) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 33 with Stack

use of com.sequenceiq.freeipa.entity.Stack 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)

Example 34 with Stack

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

the class AvailabilityCheckerTest method testAvailable.

@Test
public void testAvailable() {
    Stack stack = new Stack();
    stack.setAppVersion("2.20.0-rc.1");
    assertTrue(underTest.isAvailable(stack, afterVersion1));
    stack.setAppVersion("2.21.0-rc.1");
    assertTrue(underTest.isAvailable(stack, afterVersion1));
    stack.setAppVersion("2.20.0");
    assertTrue(underTest.isAvailable(stack, afterVersion1));
    stack.setAppVersion("2.20.0-dev.2");
    assertTrue(underTest.isAvailable(stack, afterVersion1));
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.Test)

Example 35 with Stack

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

the class HealthCheckAvailabilityCheckerTest method testAvailable.

@Test
public void testAvailable() {
    Stack stack = new Stack();
    stack.setAppVersion(AVAILABLE_VERSION);
    stack.setAccountId(ACCOUNT_ID);
    assertTrue(underTest.isCdpFreeIpaHeathAgentAvailable(stack));
}
Also used : Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

Stack (com.sequenceiq.freeipa.entity.Stack)468 Test (org.junit.jupiter.api.Test)237 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)107 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)63 Map (java.util.Map)63 Bean (org.springframework.context.annotation.Bean)50 StackContext (com.sequenceiq.freeipa.flow.stack.StackContext)45 StackEvent (com.sequenceiq.freeipa.flow.stack.StackEvent)41 List (java.util.List)37 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)34 Inject (javax.inject.Inject)30 CloudStack (com.sequenceiq.cloudbreak.cloud.model.CloudStack)29 Collectors (java.util.stream.Collectors)29 Logger (org.slf4j.Logger)29 LoggerFactory (org.slf4j.LoggerFactory)29 Set (java.util.Set)28 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)25 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)25 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)24 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)23