Make sure dataflow server uses h2 launched by spring cloud
If user runs `spring cloud dataflow h2` you'd expect the database to be used by dataflow. It's tricky to achieve, and impossible with an in-memory data store (because of the way dataflow is set up currently). This was achieved by adding a feature: each deployable can specify "enabled" (in addition to existing "disabled" feature) properties: i.e. environemnt properties that are applied to all other apps as long as this one is running. Another change here is to pass the "PATH" env var from the deployer down to deployed apps. This affects dataflow in particular because it likes to launch other apps, and it will pick the wrong Java version (for instance) if the path is not preserved.
This commit is contained in:
@@ -142,6 +142,11 @@ public class DeployerProperties {
|
||||
* E.g. when eureka is disabled you might want "eureka.client.enabled=false".
|
||||
*/
|
||||
private Map<String, String> disabled = new LinkedHashMap<>();
|
||||
/**
|
||||
* A map of "positive" properties that apply to all apps when this one is enabled.
|
||||
* E.g. when h2 is disabled you might want the JDBC URL to be used everywhere.
|
||||
*/
|
||||
private Map<String, String> enabled = new LinkedHashMap<>();
|
||||
/**
|
||||
* A list of java options to pass to the jvm command (e.g. java).
|
||||
* E.g. -Dmy.prop=myval
|
||||
@@ -213,6 +218,14 @@ public class DeployerProperties {
|
||||
this.javaOptions = javaOptions;
|
||||
}
|
||||
|
||||
public Map<String, String> getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(Map<String, String> enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Deployable{");
|
||||
@@ -222,6 +235,7 @@ public class DeployerProperties {
|
||||
sb.append(", waitUntilStarted=").append(this.waitUntilStarted);
|
||||
sb.append(", order=").append(this.order);
|
||||
sb.append(", disabled=").append(this.disabled);
|
||||
sb.append(", enabled=").append(this.disabled);
|
||||
sb.append(", javaOptions=").append(this.javaOptions);
|
||||
sb.append(", message=").append(this.message);
|
||||
sb.append('}');
|
||||
|
||||
@@ -304,6 +304,11 @@ public class DeployerThread extends Thread {
|
||||
appDefProps.putAll(other.getDisabled());
|
||||
}
|
||||
}
|
||||
for (Deployable other : properties.getDeployables().values()) {
|
||||
if (shouldDeploy(other.getName(), properties)) {
|
||||
appDefProps.putAll(other.getEnabled());
|
||||
}
|
||||
}
|
||||
Map<String, String> map = extractProperties("/" + deployable.getName() + ".yml");
|
||||
for (String key : map.keySet()) {
|
||||
appDefProps.put(key, map.get(key));
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
dt:
|
||||
pre: maven://org.springframework.cloud.launcher:spring-cloud-launcher-
|
||||
ver: ${launcher.version}
|
||||
|
||||
deployer:
|
||||
local:
|
||||
envVarsToInherit:
|
||||
- TMP
|
||||
- LANG
|
||||
- LANGUAGE
|
||||
- LC_.*
|
||||
- PATH
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
maven:
|
||||
@@ -33,6 +43,8 @@ spring:
|
||||
message: Connect on jdbc:h2:tcp://localhost:9096/./target/test, web console at http://localhost:9095
|
||||
waitUntilStarted: true
|
||||
order: -50
|
||||
enabled:
|
||||
spring.datasource.url: jdbc:h2:tcp://localhost:9096/./target/test
|
||||
hystrixdashboard:
|
||||
coordinates: ${dt.pre}hystrixdashboard:${dt.ver}
|
||||
port: 7979
|
||||
|
||||
Reference in New Issue
Block a user