protected PropertiesDiff getResourceAndVersionDifference( SpringCloudDeployerApplicationManifest existingApplicationManifest, SpringCloudDeployerApplicationManifest replacingApplicationManifest) { Map<String, String> existingResourceAndVersionMap = new HashMap<>(); existingResourceAndVersionMap.put("resource", existingApplicationManifest.getSpec().getResource().trim()); existingResourceAndVersionMap.put("version", existingApplicationManifest.getSpec().getVersion().trim()); Map<String, String> replacingResourceAndVersionMap = new HashMap<>(); replacingResourceAndVersionMap.put("resource", replacingApplicationManifest.getSpec().getResource().trim()); replacingResourceAndVersionMap.put("version", replacingApplicationManifest.getSpec().getVersion().trim()); return PropertiesDiff.builder().left(existingResourceAndVersionMap).right(replacingResourceAndVersionMap).build(); }
protected PropertiesDiff getResourceAndVersionDifference( SpringCloudDeployerApplicationManifest existingApplicationManifest, SpringCloudDeployerApplicationManifest replacingApplicationManifest) { Map<String, String> existingResourceAndVersionMap = new HashMap<>(); existingResourceAndVersionMap.put("resource", existingApplicationManifest.getSpec().getResource().trim()); existingResourceAndVersionMap.put("version", existingApplicationManifest.getSpec().getVersion().trim()); Map<String, String> replacingResourceAndVersionMap = new HashMap<>(); replacingResourceAndVersionMap.put("resource", replacingApplicationManifest.getSpec().getResource().trim()); replacingResourceAndVersionMap.put("version", replacingApplicationManifest.getSpec().getVersion().trim()); return PropertiesDiff.builder().left(existingResourceAndVersionMap).right(replacingResourceAndVersionMap).build(); }
protected PropertiesDiff getDeploymentPropertiesDifference( SpringCloudDeployerApplicationManifest existingApplicationManifest, SpringCloudDeployerApplicationManifest replacingApplicationManifest) { Map<String, String> existingDeploymentProperties = Optional .ofNullable(existingApplicationManifest.getSpec().getDeploymentProperties()).orElse(new HashMap<>()); Map<String, String> replacingDeploymentProperties = Optional .ofNullable(replacingApplicationManifest.getSpec().getDeploymentProperties()).orElse(new HashMap<>()); // exclude deployer count from computing the difference existingDeploymentProperties.remove(DefaultReleaseManager.SPRING_CLOUD_DEPLOYER_COUNT); replacingDeploymentProperties.remove(DefaultReleaseManager.SPRING_CLOUD_DEPLOYER_COUNT); return PropertiesDiff.builder().left(existingDeploymentProperties).right(replacingDeploymentProperties).build(); } }
protected PropertiesDiff getDeploymentPropertiesDifference( SpringCloudDeployerApplicationManifest existingApplicationManifest, SpringCloudDeployerApplicationManifest replacingApplicationManifest) { Map<String, String> existingDeploymentProperties = Optional .ofNullable(existingApplicationManifest.getSpec().getDeploymentProperties()).orElse(new HashMap<>()); Map<String, String> replacingDeploymentProperties = Optional .ofNullable(replacingApplicationManifest.getSpec().getDeploymentProperties()).orElse(new HashMap<>()); // exclude deployer count from computing the difference existingDeploymentProperties.remove(DefaultReleaseManager.SPRING_CLOUD_DEPLOYER_COUNT); replacingDeploymentProperties.remove(DefaultReleaseManager.SPRING_CLOUD_DEPLOYER_COUNT); return PropertiesDiff.builder().left(existingDeploymentProperties).right(replacingDeploymentProperties).build(); } }
protected PropertiesDiff getApplicationPropertiesDifference( SpringCloudDeployerApplicationManifest existingApplicationManifest, SpringCloudDeployerApplicationManifest replacingApplicationManifest) { Map<String, String> existingApplicationProperties = Optional .ofNullable(existingApplicationManifest.getSpec().getApplicationProperties()).orElse(new HashMap<>()); Map<String, String> replacingApplicationProperties = Optional .ofNullable(replacingApplicationManifest.getSpec().getApplicationProperties()).orElse(new HashMap<>()); return PropertiesDiff.builder().left(existingApplicationProperties).right(replacingApplicationProperties).build(); }
protected PropertiesDiff getApplicationPropertiesDifference( SpringCloudDeployerApplicationManifest existingApplicationManifest, SpringCloudDeployerApplicationManifest replacingApplicationManifest) { Map<String, String> existingApplicationProperties = Optional .ofNullable(existingApplicationManifest.getSpec().getApplicationProperties()).orElse(new HashMap<>()); Map<String, String> replacingApplicationProperties = Optional .ofNullable(replacingApplicationManifest.getSpec().getApplicationProperties()).orElse(new HashMap<>()); return PropertiesDiff.builder().left(existingApplicationProperties).right(replacingApplicationProperties).build(); }
private void replacingResourceExistsAssertion( SpringCloudDeployerApplicationManifest matchingReplacingApplicationManifest) { String resourceName = matchingReplacingApplicationManifest.getSpec().getResource(); String resourceVersion = matchingReplacingApplicationManifest.getSpec().getVersion(); try { Resource resource = delegatingResourceLoader.getResource( AppDeploymentRequestFactory.getResourceLocation(resourceName, resourceVersion)); } catch (Exception e) { throw new SkipperException( "Could not find Resource in replacing release name [" + resourceName + "], version [" + resourceVersion + "].", e); } }
private void replacingResourceExistsAssertion( SpringCloudDeployerApplicationManifest matchingReplacingApplicationManifest) { String resourceName = matchingReplacingApplicationManifest.getSpec().getResource(); String resourceVersion = matchingReplacingApplicationManifest.getSpec().getVersion(); try { Resource resource = delegatingResourceLoader.getResource( AppDeploymentRequestFactory.getResourceLocation(resourceName, resourceVersion)); } catch (Exception e) { throw new SkipperException( "Could not find Resource in replacing release name [" + resourceName + "], version [" + resourceVersion + "].", e); } }
@Override public StreamDeployment getStreamInfo(String streamName) { try { String manifest = this.manifest(streamName); List<SpringCloudDeployerApplicationManifest> appManifests = new SpringCloudDeployerApplicationManifestReader().read(manifest); Map<String, Map<String, String>> streamPropertiesMap = new HashMap<>(); for (SpringCloudDeployerApplicationManifest applicationManifest : appManifests) { Map<String, String> versionAndDeploymentProperties = new HashMap<>(); SpringCloudDeployerApplicationSpec spec = applicationManifest.getSpec(); String applicationName = applicationManifest.getApplicationName(); versionAndDeploymentProperties.putAll(spec.getDeploymentProperties()); versionAndDeploymentProperties.put(SkipperStream.SKIPPER_SPEC_RESOURCE, spec.getResource()); versionAndDeploymentProperties.put(SkipperStream.SKIPPER_SPEC_VERSION, spec.getVersion()); streamPropertiesMap.put(applicationName, versionAndDeploymentProperties); } return new StreamDeployment(streamName, new JSONObject(streamPropertiesMap).toString()); } catch (ReleaseNotFoundException e) { return new StreamDeployment(streamName); } }
@Override public StreamDeployment getStreamInfo(String streamName) { try { String manifest = this.manifest(streamName); List<SpringCloudDeployerApplicationManifest> appManifests = new SpringCloudDeployerApplicationManifestReader().read(manifest); Map<String, Map<String, String>> streamPropertiesMap = new HashMap<>(); for (SpringCloudDeployerApplicationManifest applicationManifest : appManifests) { Map<String, String> versionAndDeploymentProperties = new HashMap<>(); SpringCloudDeployerApplicationSpec spec = applicationManifest.getSpec(); String applicationName = applicationManifest.getApplicationName(); versionAndDeploymentProperties.putAll(spec.getDeploymentProperties()); versionAndDeploymentProperties.put(SkipperStream.SKIPPER_SPEC_RESOURCE, spec.getResource()); versionAndDeploymentProperties.put(SkipperStream.SKIPPER_SPEC_VERSION, spec.getVersion()); streamPropertiesMap.put(applicationName, versionAndDeploymentProperties); } return new StreamDeployment(streamName, new JSONObject(streamPropertiesMap).toString()); } catch (ReleaseNotFoundException e) { return new StreamDeployment(streamName); } }
private void updateStreamDefinitionFromReleaseManifest(String streamName, String releaseManifest) { List<SpringCloudDeployerApplicationManifest> appManifests = new SpringCloudDeployerApplicationManifestReader() .read(releaseManifest); Map<String, SpringCloudDeployerApplicationManifest> appManifestMap = new HashMap<>(); for (SpringCloudDeployerApplicationManifest am : appManifests) { String name = am.getSpec().getApplicationProperties().get(DataFlowPropertyKeys.STREAM_APP_LABEL); appManifestMap.put(name, am); } StreamDefinition streamDefinition = this.streamDefinitionRepository.findById(streamName) .orElseThrow(() -> new NoSuchStreamDefinitionException(streamName)); LinkedList<StreamAppDefinition> updatedStreamAppDefinitions = new LinkedList<>(); for (StreamAppDefinition appDefinition : streamDefinition.getAppDefinitions()) { StreamAppDefinition.Builder appDefinitionBuilder = StreamAppDefinition.Builder.from(appDefinition); SpringCloudDeployerApplicationManifest applicationManifest = appManifestMap.get(appDefinition.getName()); // overrides app definition properties with those from the release manifest appDefinitionBuilder.setProperties(applicationManifest.getSpec().getApplicationProperties()); updatedStreamAppDefinitions.addLast(appDefinitionBuilder.build(streamDefinition.getName())); } String dslText = new StreamDefinitionToDslConverter().toDsl(updatedStreamAppDefinitions); StreamDefinition updatedStreamDefinition = new StreamDefinition(streamName, dslText); logger.debug("Updated StreamDefinition: " + updatedStreamDefinition); // TODO consider adding an explicit UPDATE method to the streamDefRepository // Note: Not transactional and can lead to loosing the stream definition this.streamDefinitionRepository.delete(updatedStreamDefinition); this.streamDefinitionRepository.save(updatedStreamDefinition); this.auditRecordService.populateAndSaveAuditRecord( AuditOperationType.STREAM, AuditActionType.UPDATE, streamName, this.auditServiceUtils.convertStreamDefinitionToAuditData(streamDefinition)); }
private void updateStreamDefinitionFromReleaseManifest(String streamName, String releaseManifest) { List<SpringCloudDeployerApplicationManifest> appManifests = new SpringCloudDeployerApplicationManifestReader() .read(releaseManifest); Map<String, SpringCloudDeployerApplicationManifest> appManifestMap = new HashMap<>(); for (SpringCloudDeployerApplicationManifest am : appManifests) { String name = am.getSpec().getApplicationProperties().get(DataFlowPropertyKeys.STREAM_APP_LABEL); appManifestMap.put(name, am); } StreamDefinition streamDefinition = this.streamDefinitionRepository.findOne(streamName); LinkedList<StreamAppDefinition> updatedStreamAppDefinitions = new LinkedList<>(); for (StreamAppDefinition appDefinition : streamDefinition.getAppDefinitions()) { StreamAppDefinition.Builder appDefinitionBuilder = StreamAppDefinition.Builder.from(appDefinition); SpringCloudDeployerApplicationManifest applicationManifest = appManifestMap.get(appDefinition.getName()); // overrides app definition properties with those from the release manifest appDefinitionBuilder.setProperties(applicationManifest.getSpec().getApplicationProperties()); updatedStreamAppDefinitions.addLast(appDefinitionBuilder.build(streamDefinition.getName())); } String dslText = new StreamDefinitionToDslConverter().toDsl(updatedStreamAppDefinitions); StreamDefinition updatedStreamDefinition = new StreamDefinition(streamName, dslText); logger.debug("Updated StreamDefinition: " + updatedStreamDefinition); // TODO consider adding an explicit UPDATE method to the streamDefRepository // Note: Not transactional and can lead to loosing the stream definition this.streamDefinitionRepository.delete(updatedStreamDefinition); this.streamDefinitionRepository.save(updatedStreamDefinition); this.auditRecordService.populateAndSaveAuditRecord( AuditOperationType.STREAM, AuditActionType.UPDATE, streamName, this.auditServiceUtils.convertStreamDefinitionToAuditData(streamDefinition)); }
SpringCloudDeployerApplicationSpec spec = applicationSpec.getSpec(); Map<String, String> applicationProperties = new TreeMap<>(); if (spec.getApplicationProperties() != null) {
SpringCloudDeployerApplicationSpec spec = applicationSpec.getSpec(); Map<String, String> applicationProperties = new TreeMap<>(); if (spec.getApplicationProperties() != null) {