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));
}
}
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);
}
}
}
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);
}
Aggregations