Repository: apex-core Updated Branches: refs/heads/master 3024b06e1 -> 408cd967a
APEXCORE-592 Returning description field in defaultProperties during apex cli call get-app-package-info Project: http://git-wip-us.apache.org/repos/asf/apex-core/repo Commit: http://git-wip-us.apache.org/repos/asf/apex-core/commit/408cd967 Tree: http://git-wip-us.apache.org/repos/asf/apex-core/tree/408cd967 Diff: http://git-wip-us.apache.org/repos/asf/apex-core/diff/408cd967 Branch: refs/heads/master Commit: 408cd967a98506317e94821df5143a7800f0eb7d Parents: 3024b06 Author: ajaygit158 <[email protected]> Authored: Mon Dec 19 16:13:55 2016 +0530 Committer: ajaygit158 <[email protected]> Committed: Thu Mar 16 07:50:42 2017 +0530 ---------------------------------------------------------------------- .../java/com/datatorrent/stram/cli/ApexCli.java | 8 ++--- .../datatorrent/stram/client/AppPackage.java | 35 +++++++++++++++++--- .../stram/client/DTConfiguration.java | 2 +- .../stram/client/AppPackageTest.java | 5 +-- .../META-INF/properties-MyFirstApplication.xml | 1 + 5 files changed, 39 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/apex-core/blob/408cd967/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java b/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java index 28ac3df..e95a391 100644 --- a/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java +++ b/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java @@ -98,6 +98,7 @@ import com.datatorrent.api.StreamingApplication; import com.datatorrent.stram.StramUtils; import com.datatorrent.stram.client.AppPackage; import com.datatorrent.stram.client.AppPackage.AppInfo; +import com.datatorrent.stram.client.AppPackage.PropertyInfo; import com.datatorrent.stram.client.ConfigPackage; import com.datatorrent.stram.client.DTConfiguration; import com.datatorrent.stram.client.DTConfiguration.Scope; @@ -3480,7 +3481,6 @@ public class ApexCli printJson(apInfo); } } - } private void checkConfigPackageCompatible(AppPackage ap, ConfigPackage cp) @@ -3728,11 +3728,11 @@ public class ApexCli break; } } - Map<String, String> defaultProperties = selectedApp == null ? ap.getDefaultProperties() : selectedApp.defaultProperties; + Map<String, PropertyInfo> defaultProperties = selectedApp == null ? ap.getDefaultProperties() : selectedApp.defaultProperties; Set<String> requiredProperties = new TreeSet<>(selectedApp == null ? ap.getRequiredProperties() : selectedApp.requiredProperties); - for (Map.Entry<String, String> entry : defaultProperties.entrySet()) { - launchProperties.set(entry.getKey(), entry.getValue(), Scope.TRANSIENT, null); + for (Map.Entry<String, PropertyInfo> entry : defaultProperties.entrySet()) { + launchProperties.set(entry.getKey(), entry.getValue().getValue(), Scope.TRANSIENT, entry.getValue().getDescription()); requiredProperties.remove(entry.getKey()); } http://git-wip-us.apache.org/repos/asf/apex-core/blob/408cd967/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java b/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java index e6b4b7f..fcb1612 100644 --- a/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java +++ b/engine/src/main/java/com/datatorrent/stram/client/AppPackage.java @@ -81,7 +81,7 @@ public class AppPackage extends JarFile private final List<String> appPropertiesFiles = new ArrayList<>(); private final Set<String> requiredProperties = new TreeSet<>(); - private final Map<String, String> defaultProperties = new TreeMap<>(); + private final Map<String, PropertyInfo> defaultProperties = new TreeMap<>(); private final Set<String> configs = new TreeSet<>(); private final File resourcesDirectory; @@ -98,7 +98,7 @@ public class AppPackage extends JarFile public String errorStackTrace; public Set<String> requiredProperties = new TreeSet<>(); - public Map<String, String> defaultProperties = new TreeMap<>(); + public Map<String, PropertyInfo> defaultProperties = new TreeMap<>(); public AppInfo(String name, String file, String type) { @@ -109,6 +109,28 @@ public class AppPackage extends JarFile } + public static class PropertyInfo + { + private final String value; + private final String description; + + public PropertyInfo(final String value, final String description) + { + this.value = value; + this.description = description; + } + + public String getValue() + { + return value; + } + + public String getDescription() + { + return description; + } + } + public AppPackage(File file) throws IOException, ZipException { this(file, false); @@ -317,7 +339,7 @@ public class AppPackage extends JarFile return Collections.unmodifiableSet(requiredProperties); } - public Map<String, String> getDefaultProperties() + public Map<String, PropertyInfo> getDefaultProperties() { return Collections.unmodifiableMap(defaultProperties); } @@ -434,11 +456,14 @@ public class AppPackage extends JarFile app.requiredProperties.add(key); } } else { + //Attribute are platform specific, ignoring description provided in properties file + String description = key.contains(".attr.") ? null : config.getDescription(key); + PropertyInfo propertyInfo = new PropertyInfo(value, description); if (app == null) { - defaultProperties.put(key, value); + defaultProperties.put(key, propertyInfo); } else { app.requiredProperties.remove(key); - app.defaultProperties.put(key, value); + app.defaultProperties.put(key, propertyInfo); } } } http://git-wip-us.apache.org/repos/asf/apex-core/blob/408cd967/engine/src/main/java/com/datatorrent/stram/client/DTConfiguration.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/client/DTConfiguration.java b/engine/src/main/java/com/datatorrent/stram/client/DTConfiguration.java index 1f19d71..5844740 100644 --- a/engine/src/main/java/com/datatorrent/stram/client/DTConfiguration.java +++ b/engine/src/main/java/com/datatorrent/stram/client/DTConfiguration.java @@ -70,7 +70,7 @@ public class DTConfiguration implements Iterable<Map.Entry<String, String>> private final Map<String, ValueEntry> map = new LinkedHashMap<>(); private static final Logger LOG = LoggerFactory.getLogger(DTConfiguration.class); - public static class ValueEntry + private static class ValueEntry { public String value; public boolean isFinal = false; http://git-wip-us.apache.org/repos/asf/apex-core/blob/408cd967/engine/src/test/java/com/datatorrent/stram/client/AppPackageTest.java ---------------------------------------------------------------------- diff --git a/engine/src/test/java/com/datatorrent/stram/client/AppPackageTest.java b/engine/src/test/java/com/datatorrent/stram/client/AppPackageTest.java index 0ea760f..9f3276d 100644 --- a/engine/src/test/java/com/datatorrent/stram/client/AppPackageTest.java +++ b/engine/src/test/java/com/datatorrent/stram/client/AppPackageTest.java @@ -125,7 +125,7 @@ public class AppPackageTest } @Test - public void testAppLevelRequiredProperties() + public void testAppLevelRequiredAndDefaultProperties() { List<AppPackage.AppInfo> applications = ap.getApplications(); for (AppPackage.AppInfo app : applications) { @@ -133,7 +133,8 @@ public class AppPackageTest String[] rp = app.requiredProperties.toArray(new String[]{}); Assert.assertEquals("dt.test.required.2", rp[0]); Assert.assertEquals("dt.test.required.3", rp[1]); - Assert.assertEquals("app-default-for-required-1", app.defaultProperties.get("dt.test.required.1")); + Assert.assertEquals("app-default-for-required-1", app.defaultProperties.get("dt.test.required.1").getValue()); + Assert.assertEquals("app-default-for-required-1-description", app.defaultProperties.get("dt.test.required.1").getDescription()); return; } } http://git-wip-us.apache.org/repos/asf/apex-core/blob/408cd967/engine/src/test/resources/testAppPackage/mydtapp/src/main/resources/META-INF/properties-MyFirstApplication.xml ---------------------------------------------------------------------- diff --git a/engine/src/test/resources/testAppPackage/mydtapp/src/main/resources/META-INF/properties-MyFirstApplication.xml b/engine/src/test/resources/testAppPackage/mydtapp/src/main/resources/META-INF/properties-MyFirstApplication.xml index 8f7e9a8..b23bd61 100644 --- a/engine/src/test/resources/testAppPackage/mydtapp/src/main/resources/META-INF/properties-MyFirstApplication.xml +++ b/engine/src/test/resources/testAppPackage/mydtapp/src/main/resources/META-INF/properties-MyFirstApplication.xml @@ -43,6 +43,7 @@ <property> <name>dt.test.required.1</name> <value>app-default-for-required-1</value> + <description>app-default-for-required-1-description</description> </property> <property> <name>dt.test.required.3</name>
