Search in sources :

Example 1 with IntegrationDeploymentState

use of io.syndesis.common.model.integration.IntegrationDeploymentState in project syndesis by syndesisio.

the class IntegrationController method checkIntegrationStatus.

private void checkIntegrationStatus(IntegrationDeployment integrationDeployment) {
    if (integrationDeployment == null) {
        return;
    }
    IntegrationDeploymentState desiredState = integrationDeployment.getTargetState();
    IntegrationDeploymentState currentState = integrationDeployment.getCurrentState();
    if (!currentState.equals(desiredState)) {
        integrationDeployment.getId().ifPresent(integrationDeploymentId -> {
            StateChangeHandler statusChangeHandler = handlers.get(desiredState);
            if (statusChangeHandler != null) {
                LOG.info("Integration {} : Desired status \"{}\" != current status \"{}\" --> calling status change handler", integrationDeploymentId, desiredState.toString(), currentState);
                callStateChangeHandler(statusChangeHandler, integrationDeploymentId);
            }
        });
    } else {
        scheduledChecks.remove(getIntegrationMarkerKey(integrationDeployment));
    }
}
Also used : IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) StateChangeHandler(io.syndesis.server.controller.StateChangeHandler)

Example 2 with IntegrationDeploymentState

use of io.syndesis.common.model.integration.IntegrationDeploymentState in project syndesis-qe by syndesisio.

the class CommonValidationSteps method verifyIntegrationOnOffNTimes.

@Then("switch Inactive and Active state on integration {string} for {int} times and check pods")
public void verifyIntegrationOnOffNTimes(String integrationName, int switchNTimes) {
    final String integrationId = integrationsEndpoint.getIntegrationId(integrationName).get();
    for (int i = 0; i <= switchNTimes; i++) {
        final IntegrationDeploymentState newDepState;
        final Integration integration = integrationsEndpoint.get(integrationId);
        int integrationVersion = integration.getVersion();
        log.info("Getting integrationDeployment with deployment number: {}", integrationVersion);
        IntegrationDeployment currentDeployment = integrationsEndpoint.getCurrentIntegrationDeployment(integrationId, integrationVersion);
        if (currentDeployment.getCurrentState().equals(IntegrationDeploymentState.Published)) {
            newDepState = IntegrationDeploymentState.Unpublished;
            log.info("Unpublishing integration with integration version: {}", integrationVersion);
            integrationsEndpoint.deactivateIntegration(integrationId, integrationVersion);
        } else {
            newDepState = IntegrationDeploymentState.Published;
            log.info("Publishing integration: {}", integrationId);
            integrationsEndpoint.activateIntegration(integrationId);
        }
        if (newDepState.equals(IntegrationDeploymentState.Published)) {
            verifyPodCount(integrationName, 1);
        } else {
            verifyPodCount(integrationName, 0);
        }
    }
}
Also used : Integration(io.syndesis.common.model.integration.Integration) IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) IntegrationOverviewEndpoint(io.syndesis.qe.endpoint.IntegrationOverviewEndpoint) Then(io.cucumber.java.en.Then)

Example 3 with IntegrationDeploymentState

use of io.syndesis.common.model.integration.IntegrationDeploymentState in project syndesis by syndesisio.

the class UnpublishHandler method execute.

@Override
public StateUpdate execute(IntegrationDeployment integrationDeployment) {
    Map<String, String> stepsDone = new HashMap<>(integrationDeployment.getStepsDone());
    // we are literally undoing this step.
    stepsDone.remove("deploy");
    IntegrationDeploymentState currentState = IntegrationDeploymentState.Pending;
    Map<String, String> labels = new HashMap<>();
    labels.put(OpenShiftService.INTEGRATION_ID_LABEL, Labels.validate(integrationDeployment.getIntegrationId().get()));
    labels.put(OpenShiftService.DEPLOYMENT_VERSION_LABEL, String.valueOf(integrationDeployment.getVersion()));
    if (!openShiftService().getDeploymentsByLabel(labels).isEmpty()) {
        try {
            openShiftService().scale(integrationDeployment.getSpec().getName(), labels, 0, 1, TimeUnit.MINUTES);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            return new StateUpdate(currentState, stepsDone);
        }
    } else {
        currentState = IntegrationDeploymentState.Unpublished;
    }
    return new StateUpdate(currentState, stepsDone);
}
Also used : IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) StateUpdate(io.syndesis.server.controller.StateUpdate) HashMap(java.util.HashMap)

Aggregations

IntegrationDeploymentState (io.syndesis.common.model.integration.IntegrationDeploymentState)3 Then (io.cucumber.java.en.Then)1 Integration (io.syndesis.common.model.integration.Integration)1 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)1 IntegrationOverviewEndpoint (io.syndesis.qe.endpoint.IntegrationOverviewEndpoint)1 IntegrationsEndpoint (io.syndesis.qe.endpoint.IntegrationsEndpoint)1 StateChangeHandler (io.syndesis.server.controller.StateChangeHandler)1 StateUpdate (io.syndesis.server.controller.StateUpdate)1 HashMap (java.util.HashMap)1