private String getLabel(Integration integration) { return String.format("Integration [%s]", Names.sanitize(integration.getName())); }
@Override public String getName() { return getTarget().getName(); }
private String getLabel(IntegrationDeployment integrationDeployment) { return String.format("Integration [%s]", Names.sanitize(integrationDeployment.getSpec().getName())); }
private IntegrationDeploymentState determineState(IntegrationDeployment integrationDeployment) { 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.exists(integrationDeployment.getSpec().getName()) || !openShiftService.isScaled(integrationDeployment.getSpec().getName(), 1, labels)) { return IntegrationDeploymentState.Unpublished; } else { return IntegrationDeploymentState.Published; } }
public boolean isRunning(IntegrationDeployment integrationDeployment) { 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())); return openShiftService().isScaled(integrationDeployment.getSpec().getName(), 1, labels); }
@Override public StateUpdate execute(IntegrationDeployment integrationDeployment) { Map<String, String> stepsDone = new HashMap<>(integrationDeployment.getStepsDone()); stepsDone.remove("deploy"); //we are literally undoing this step. 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())); List<DeploymentConfig> deployments = openShiftService().getDeploymentsByLabel(labels); Boolean isDeployed = !deployments.stream().filter(d -> d.getSpec().getReplicas() != 0).collect(Collectors.toList()).isEmpty(); if (isDeployed) { try { LOG.info("Undeploying integration deployment:{} version:{}", integrationDeployment.getSpec().getName(), integrationDeployment.getVersion()); openShiftService().scale(integrationDeployment.getSpec().getName(), labels, 0, 1, TimeUnit.MINUTES); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return new StateUpdate(currentState, stepsDone); } } Boolean isUndeployed = !deployments.stream().filter(d -> d.getStatus().getAvailableReplicas() == 0).collect(Collectors.toList()).isEmpty(); if(isUndeployed){ currentState = IntegrationDeploymentState.Unpublished; } return new StateUpdate(currentState, stepsDone); }
private boolean isReady(IntegrationDeployment integrationDeployment) { return openShiftService().isDeploymentReady(integrationDeployment.getSpec().getName()); }
private void updateIntegrationEndpoint(IntegrationDeployment deployment) { if (deployment.getId().isPresent()) { IntegrationEndpoint endpoint = dataManager.fetch(IntegrationEndpoint.class, deployment.getId().get()); boolean endpointPresent = endpoint != null; Optional<String> host = openShiftService.getExposedHost(deployment.getSpec().getName()); Optional<IntegrationEndpoint> expectedEndpoint = expectedEndpoint(deployment, host); // Synchronize internal model if (!endpointPresent && expectedEndpoint.isPresent()) { LOG.info("Adding endpoint {} to integration deployment {}", expectedEndpoint.get(), deployment.getId().get()); dataManager.create(expectedEndpoint.get()); } else if (endpointPresent && expectedEndpoint.isPresent()) { if (!endpoint.equals(expectedEndpoint.get())) { LOG.info("Updating endpoint for deployment {} to {}", deployment.getId().get(), expectedEndpoint.get()); dataManager.update(expectedEndpoint.get()); } } else if (endpointPresent) { LOG.info("Deleting endpoint for deployment {}", deployment.getId().get()); dataManager.delete(IntegrationEndpoint.class, deployment.getId().get()); } } }
private boolean isBuildStarted(IntegrationDeployment integrationDeployment) { return openShiftService().isBuildStarted(integrationDeployment.getSpec().getName()); }
private boolean isBuildFailed(IntegrationDeployment integrationDeployment) { return openShiftService().isBuildFailed(integrationDeployment.getSpec().getName()); }
private String deploy(IntegrationDeployment integration, DeploymentData data) throws IOException { logInfo(integration, "Starting deployment"); String revision = openShiftService().deploy(integration.getSpec().getName(), data); logInfo(integration, "Deployment done"); return revision; }
private String build(IntegrationDeployment integration, DeploymentData data) throws IOException { InputStream tarInputStream = createProjectFiles(integration.getSpec()); logInfo(integration, "Created project files and starting build"); try { return openShiftService().build(integration.getSpec().getName(), data, tarInputStream); } catch (InterruptedException e) { throw SyndesisServerException.launderThrowable(e); } }
private DeploymentData createDeploymentData(Integration integration, IntegrationDeployment integrationDeployment) { Properties applicationProperties = projectGenerator.generateApplicationProperties(integration); String username = integrationDeployment.getUserId().orElseThrow(() -> new IllegalStateException("Couldn't find the user of the integration")); String integrationId = integrationDeployment.getIntegrationId().orElseThrow(() -> new IllegalStateException("IntegrationDeployment should have an integrationId")); String version = Integer.toString(integrationDeployment.getVersion()); final Builder deploymentDataBuilder = DeploymentData.builder() .withVersion(integrationDeployment.getVersion()) .addLabel(OpenShiftService.INTEGRATION_ID_LABEL, Labels.validate(integrationId)) .addLabel(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version) .addLabel(OpenShiftService.USERNAME_LABEL, Labels.sanitize(username)) .addAnnotation(OpenShiftService.INTEGRATION_NAME_ANNOTATION, integration.getName()) .addAnnotation(OpenShiftService.INTEGRATION_ID_LABEL, integrationId) .addAnnotation(OpenShiftService.DEPLOYMENT_VERSION_LABEL, version) .addSecretEntry("application.properties", propsToString(applicationProperties)); integration.getConfiguredProperties().forEach((k, v) -> deploymentDataBuilder.addProperty(k, v)); DeploymentData data = deploymentDataBuilder.build(); if (this.customizers != null && !this.customizers.isEmpty()) { for (DeploymentDataCustomizer customizer : customizers) { data = customizer.customize(data, integrationDeployment); } } return data; }
EquivContext context = identifier(parentContext, another.getName(), another.getClass()); context.setFail(ONE_NULL, NULL, NOT_NULL); return false; EquivContext context = identifier(parentContext, one.getName(), one.getClass()); if (another == null) { context.setFail(ANOTHER_NULL, NOT_NULL, NULL); pair(one.getTags(), another.getTags(), "tags"), pair(one.getDescription(), another.getDescription(), "description"), pair(one.getName(), another.getName(), "name"));