@Override public String toString() { return "StreamAppDefinition [streamName=" + streamName + ", name=" + this.appDefinition.getName() + ", type=" + getApplicationType()+", registeredAppName=" + getRegisteredAppName() + ", properties=" + this.appDefinition.getProperties() + "]"; }
/** * Construct a {@code DataFlowAppDefinition}. * * @param registeredAppName name of application in registry * @param label label used for application * @param properties app properties; may be {@code null} */ protected DataFlowAppDefinition(String registeredAppName, String label, Map<String, String> properties) { Assert.notNull(registeredAppName, "registeredAppName must not be null"); Assert.notNull(label, "label must not be null"); this.registeredAppName = registeredAppName; this.appDefinition = new AppDefinition(label, properties); }
@Test public void testSimpleLaunch() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
/** * Return the name from the {@link AppDefinition}. * * @return the name from the {@link AppDefinition} */ public String getName() { return this.appDefinition.getName(); }
/** * Gets the app definition properties. These properties are passed into a running app. * * @return the unmodifiable map of app properties */ public Map<String, String> getProperties() { return this.appDefinition.getProperties(); }
+ request.getDefinition().toString()); appDeploymentRequests.add(request);
@Test public void testErrorExit() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "1"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.failed))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
/** * Return the name from the {@link AppDefinition}. * * @return the name from the {@link AppDefinition} */ public String getName() { return this.appDefinition.getName(); }
/** * Gets the app definition properties. These properties are passed into a running app. * * @return the unmodifiable map of app properties */ public Map<String, String> getProperties() { return this.appDefinition.getProperties(); }
+ request.getDefinition().toString()); appDeploymentRequests.add(request);
@Test public void testSimpleLaunch() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
protected Map<String, String> getProperties(AppDeploymentRequest request) { Map<String, String> properties = new LinkedHashMap<>( request.getDefinition().getProperties()); String group = request.getDeploymentProperties() .get(AppDeployer.GROUP_PROPERTY_KEY); if (group == null) { group = "deployer"; } String deploymentId = String.format("%s.%s", group, request.getDefinition().getName()); properties.put(JMX_DEFAULT_DOMAIN_KEY, deploymentId); properties.put("endpoints.shutdown.enabled", "true"); properties.put("endpoints.jmx.unique-names", "true"); if (group != null) { properties.put("spring.cloud.application.group", group); } return properties; }
public static String forAppDeploymentRequest(String streamName, AppDefinition appDefinition) { Assert.notNull(streamName, "streamName must not be null"); Assert.notNull(appDefinition, "appDefinition must not be null"); return String.format("%s.%s", streamName, appDefinition.getName()); }
/** * Construct a {@code DataFlowAppDefinition}. * * @param registeredAppName name of application in registry * @param label label used for application * @param applicationType the application type if already determined * @param properties app properties; may be {@code null} */ protected DataFlowAppDefinition(String registeredAppName, String label, ApplicationType applicationType, Map<String, String> properties) { Assert.notNull(registeredAppName, "registeredAppName must not be null"); Assert.notNull(applicationType, "applicationType must not be null"); Assert.notNull(label, "label must not be null"); this.registeredAppName = registeredAppName; this.applicationType = applicationType; this.appDefinition = new AppDefinition(label, properties); }
private Map<String, String> getSanitizedApplicationProperties(String deploymentId, AppDeploymentRequest request) { Map<String, String> applicationProperties = new HashMap<>(request.getDefinition().getProperties()); // Remove server.port as CF assigns a port for us, and we don't want to override that Optional.ofNullable(applicationProperties.remove("server.port")) .ifPresent(port -> logger.warn("Ignoring 'server.port={}' for app {}, as Cloud Foundry will assign a local dynamic port. Route to the app will use port 80.", port, deploymentId)); return applicationProperties; }
@Test public void testErrorExit() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "1"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.failed))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
public Map<String, Object> convertScheduleRequestToAuditData(ScheduleRequest scheduleRequest) { Assert.notNull(scheduleRequest, "scheduleRequest must not be null"); Assert.hasText(scheduleRequest.getScheduleName(), "The scheduleName of the scheduleRequest must not be null or empty"); Assert.notNull(scheduleRequest.getDefinition(), "The task definition of the scheduleRequest must not be null"); final Map<String, Object> auditedData = new HashMap<>(3); auditedData.put(TASK_DEFINITION_NAME, scheduleRequest.getDefinition().getName()); if (scheduleRequest.getDefinition().getProperties() != null) { auditedData.put(TASK_DEFINITION_PROPERTIES, argumentSanitizer.sanitizeProperties(scheduleRequest.getDefinition().getProperties())); } if (scheduleRequest.getDeploymentProperties() != null) { auditedData.put(DEPLOYMENT_PROPERTIES, argumentSanitizer.sanitizeProperties(scheduleRequest.getDeploymentProperties())); } if (scheduleRequest.getCommandlineArguments() != null) { auditedData.put(COMMANDLINE_ARGUMENTS, argumentSanitizer.sanitizeArguments(scheduleRequest.getCommandlineArguments())); } return auditedData; } }
protected String createDeploymentId(AppDeploymentRequest request) { String groupId = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY); String deploymentId; if (groupId == null) { deploymentId = String.format("%s", request.getDefinition().getName()); } else { deploymentId = String.format("%s-%s", groupId, request.getDefinition().getName()); } // Kubernetes does not allow . in the name and does not allow uppercase in the name return deploymentId.replace('.', '-').toLowerCase(); }
/** * Return a new app definition where definition-time and deploy-time properties have been * merged and short form parameters have been expanded to their long form (amongst the * whitelisted supported properties of the app) if applicable. */ /* default */ AppDefinition mergeAndExpandAppProperties(StreamAppDefinition original, Resource metadataResource, Map<String, String> appDeployTimeProperties) { Map<String, String> merged = new HashMap<>(original.getProperties()); merged.putAll(appDeployTimeProperties); merged = this.whitelistProperties.qualifyProperties(merged, metadataResource); merged.putIfAbsent(StreamPropertyKeys.METRICS_PROPERTIES, "spring.application.name,spring.application.index," + "spring.cloud.application.*,spring.cloud.dataflow.*"); merged.putIfAbsent(StreamPropertyKeys.METRICS_TRIGGER_INCLUDES, "integration**"); return new AppDefinition(original.getName(), merged); }
protected int configureExternalPort(final AppDeploymentRequest request) { int externalPort = 8080; Map<String, String> parameters = request.getDefinition().getProperties(); if (parameters.containsKey(SERVER_PORT_KEY)) { externalPort = Integer.valueOf(parameters.get(SERVER_PORT_KEY)); } return externalPort; }