Search in sources :

Example 56 with Integration

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

the class PublishHandler method execute.

@Override
public StateUpdate execute(final IntegrationDeployment integrationDeployment) {
    final int maxIntegrationsPerUser = properties.getMaxIntegrationsPerUser();
    if (maxIntegrationsPerUser != ControllersConfigurationProperties.UNLIMITED) {
        int userIntegrations = countActiveIntegrationsOfSameUserAs(integrationDeployment);
        if (userIntegrations >= maxIntegrationsPerUser) {
            // What the user sees.
            return new StateUpdate(IntegrationDeploymentState.Unpublished, integrationDeployment.getStepsDone(), "User has currently " + userIntegrations + " integrations, while the maximum allowed number is " + maxIntegrationsPerUser + ".");
        }
    }
    final int maxDeploymentsPerUser = properties.getMaxDeploymentsPerUser();
    if (maxDeploymentsPerUser != ControllersConfigurationProperties.UNLIMITED) {
        int userDeployments = countDeployments(integrationDeployment);
        if (userDeployments >= maxDeploymentsPerUser) {
            // What we actually want to limit. So even though this should never happen, we still need to make sure.
            return new StateUpdate(IntegrationDeploymentState.Unpublished, integrationDeployment.getStepsDone(), "User has currently " + userDeployments + " deployments, while the maximum allowed number is " + maxDeploymentsPerUser + ".");
        }
    }
    logInfo(integrationDeployment, "Build started: {}, isRunning: {}, Deployment ready: {}", isBuildStarted(integrationDeployment), isRunning(integrationDeployment), isReady(integrationDeployment));
    BuildStepPerformer stepPerformer = new BuildStepPerformer(integrationDeployment);
    logInfo(integrationDeployment, "Steps performed so far: " + stepPerformer.getStepsPerformed());
    if (isBuildFailed(integrationDeployment)) {
        return new StateUpdate(IntegrationDeploymentState.Error, stepPerformer.getStepsPerformed(), "Error");
    }
    final Integration integration = integrationOf(integrationDeployment);
    try {
        setVersion(integrationDeployment);
        deactivatePreviousDeployments(integrationDeployment);
        DeploymentData deploymentData = createDeploymentData(integration, integrationDeployment);
        stepPerformer.perform("build", this::build, deploymentData);
        deploymentData = new DeploymentData.Builder().createFrom(deploymentData).withImage(stepPerformer.stepsPerformed.get("build")).build();
        if (hasPublishedDeployments(integrationDeployment)) {
            return new StateUpdate(IntegrationDeploymentState.Unpublished, integrationDeployment.getStepsDone(), "Integration has still active deployments. Will retry shortly");
        }
        stepPerformer.perform("deploy", this::deploy, deploymentData);
    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {
        logError(integrationDeployment, "[ERROR] Activation failure", e);
        // Setting a message to update means implicitly thats in an error state (for the UI)
        return new StateUpdate(IntegrationDeploymentState.Pending, stepPerformer.getStepsPerformed(), e.getMessage());
    }
    // Set status to activate if finally running. Also clears the previous step which has been performed
    if (isRunning(integrationDeployment)) {
        logInfo(integrationDeployment, "[ACTIVATED] bc. integration is running with 1 pod");
        updateDeploymentState(integrationDeployment, IntegrationDeploymentState.Published);
        return new StateUpdate(IntegrationDeploymentState.Published, stepPerformer.getStepsPerformed());
    }
    logInfo(integrationDeployment, "Build started: {}, isRunning: {}, Deployment ready: {}", isBuildStarted(integrationDeployment), isRunning(integrationDeployment), isReady(integrationDeployment));
    logInfo(integrationDeployment, "[PENDING] [" + stepPerformer.getStepsPerformed() + "]");
    return new StateUpdate(IntegrationDeploymentState.Pending, stepPerformer.getStepsPerformed());
}
Also used : Integration(io.syndesis.common.model.integration.Integration) DeploymentData(io.syndesis.server.openshift.DeploymentData) StateUpdate(io.syndesis.server.controller.StateUpdate) IOException(java.io.IOException) SyndesisServerException(io.syndesis.common.util.SyndesisServerException)

Example 57 with Integration

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

the class ProjectGenerator method generate.

@Override
@SuppressWarnings("resource")
public InputStream generate(final Integration integrationDefinition) throws IOException {
    final Integration integration = sanitize(integrationDefinition, resourceManager);
    final PipedInputStream is = new PipedInputStream();
    final ExecutorService executor = Executors.newSingleThreadExecutor();
    final PipedOutputStream os = new PipedOutputStream(is);
    executor.execute(generateAddProjectTarEntries(integration, os));
    return is;
}
Also used : Integration(io.syndesis.common.model.integration.Integration) ExecutorService(java.util.concurrent.ExecutorService) PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream)

Aggregations

Integration (io.syndesis.common.model.integration.Integration)57 Test (org.junit.Test)19 Step (io.syndesis.common.model.integration.Step)17 List (java.util.List)16 Connection (io.syndesis.common.model.connection.Connection)15 Connector (io.syndesis.common.model.connection.Connector)11 DataManager (io.syndesis.server.dao.manager.DataManager)11 IOException (java.io.IOException)11 Set (java.util.Set)10 InputStream (java.io.InputStream)9 ArrayList (java.util.ArrayList)9 Collectors (java.util.stream.Collectors)9 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)8 IntegrationDeploymentState (io.syndesis.common.model.integration.IntegrationDeploymentState)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 IntegrationProjectGenerator (io.syndesis.integration.api.IntegrationProjectGenerator)7 Map (java.util.Map)7 Action (io.syndesis.common.model.action.Action)6 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)6 StepKind (io.syndesis.common.model.integration.StepKind)6