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