private IntegrationDeploymentState getTargetStateInitialize() { return IntegrationDeployment.super.getTargetState(); }
private String getIntegrationMarkerKey(IntegrationDeployment integrationDeployment) { return integrationDeployment.getTargetState() + ":" + integrationDeployment.getId().orElseThrow(() -> new IllegalArgumentException("No id set in integration " + integrationDeployment)); }
private boolean stale(StateChangeHandler handler, IntegrationDeployment integrationDeployment) { if (integrationDeployment == null || handler == null) { return true; } IntegrationDeploymentState desiredState = integrationDeployment.getTargetState(); return desiredState.equals(integrationDeployment.getCurrentState()); }
/** * Re-conciliates the state of the deployment between the database and Openshift. * This is mostly needed for cases where an active integration has been tampered with external tools. * For example: Deleted or Scaled down DeploymentConfig. */ private IntegrationDeployment reconcileDeployment(IntegrationDeployment integrationDeployment) { IntegrationDeploymentState actualState = determineState(integrationDeployment); LOG.debug("Actual state: {}, Persisted state: {}, Desired state: {}", actualState, integrationDeployment.getCurrentState(), integrationDeployment.getTargetState()); //We also need to compare with current state to make sure we only call the unpublished() once. Calling it multiple times, might loose the steps perfromed, causing an infinite loop. if (actualState == IntegrationDeploymentState.Unpublished && actualState != integrationDeployment.getCurrentState()) { return integrationDeployment.unpublished(); } else { return integrationDeployment.withCurrentState(actualState); } } }
private void checkIntegrationStatus(IntegrationDeployment integrationDeployment) { if (integrationDeployment == null) { return; } IntegrationDeployment reconciled = reconcileDeployment(integrationDeployment); IntegrationDeploymentState desiredState = reconciled.getTargetState(); IntegrationDeploymentState currentState = reconciled.getCurrentState(); if (!currentState.equals(desiredState)) { reconciled.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, reconciled); } }); } else if (reconciled.getCurrentState() != integrationDeployment.getCurrentState()) { dataManager.update(reconciled); scheduledChecks.remove(getIntegrationMarkerKey(reconciled)); } else { scheduledChecks.remove(getIntegrationMarkerKey(reconciled)); } }
final String version = String.valueOf(integrationDeployment.getVersion()); final String compositeId = IntegrationDeployment.compositeId(integrationId, integrationDeployment.getVersion()); final IntegrationDeploymentState targetState = integrationDeployment.getTargetState();