You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by cs...@apache.org on 2015/09/11 00:00:33 UTC
incubator-apex-core git commit: APEX-111 #resolve show-logical-plan
command should check the first arg whether it's an app package before
counting arguments
Repository: incubator-apex-core
Updated Branches:
refs/heads/devel-3 9d83a4445 -> 6c2425948
APEX-111 #resolve show-logical-plan command should check the first arg whether it's an app package before counting arguments
Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/commit/6c242594
Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/6c242594
Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/6c242594
Branch: refs/heads/devel-3
Commit: 6c2425948a50a6c76a93e359356cbb387155ed22
Parents: 9d83a44
Author: David Yan <da...@datatorrent.com>
Authored: Thu Sep 10 14:03:34 2015 -0700
Committer: Chandni Singh <cs...@apache.org>
Committed: Thu Sep 10 15:00:23 2015 -0700
----------------------------------------------------------------------
.../java/com/datatorrent/stram/cli/DTCli.java | 143 +++++++++----------
1 file changed, 68 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/6c242594/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java
----------------------------------------------------------------------
diff --git a/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java b/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java
index 53ad0ca..6ac1b9d 100644
--- a/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java
+++ b/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java
@@ -2777,95 +2777,88 @@ public class DTCli
}
}
- if (commandLineInfo.args.length >= 2) {
- String jarfile = expandFileName(commandLineInfo.args[0], true);
- AppPackage ap = null;
+ if (commandLineInfo.args.length > 0) {
+ String filename = expandFileName(commandLineInfo.args[0], true);
+
// see if the first argument is actually an app package
try {
- ap = new AppPackage(new File(jarfile));
- }
- catch (Exception ex) {
- // fall through
- }
- if (ap != null) {
+ AppPackage ap = new AppPackage(new File(filename));
+ ap.close();
new ShowLogicalPlanAppPackageCommand().execute(args, reader);
return;
+ } catch (Exception ex) {
+ // fall through
}
- String appName = commandLineInfo.args[1];
- StramAppLauncher submitApp = getStramAppLauncher(jarfile, config, commandLineInfo.ignorePom);
- submitApp.loadDependencies();
- List<AppFactory> matchingAppFactories = getMatchingAppFactories(submitApp, appName, commandLineInfo.exactMatch);
- if (matchingAppFactories == null || matchingAppFactories.isEmpty()) {
- throw new CliException("No application in jar file matches '" + appName + "'");
- }
- else if (matchingAppFactories.size() > 1) {
- throw new CliException("More than one application in jar file match '" + appName + "'");
- }
- else {
- Map<String, Object> map = new HashMap<String, Object>();
- PrintStream originalStream = System.out;
- AppFactory appFactory = matchingAppFactories.get(0);
- try {
- if (raw) {
- PrintStream dummyStream = new PrintStream(new OutputStream()
- {
- @Override
- public void write(int b)
+
+ if (commandLineInfo.args.length >= 2) {
+ String appName = commandLineInfo.args[1];
+ StramAppLauncher submitApp = getStramAppLauncher(filename, config, commandLineInfo.ignorePom);
+ submitApp.loadDependencies();
+ List<AppFactory> matchingAppFactories = getMatchingAppFactories(submitApp, appName, commandLineInfo.exactMatch);
+ if (matchingAppFactories == null || matchingAppFactories.isEmpty()) {
+ throw new CliException("No application in jar file matches '" + appName + "'");
+ } else if (matchingAppFactories.size() > 1) {
+ throw new CliException("More than one application in jar file match '" + appName + "'");
+ } else {
+ Map<String, Object> map = new HashMap<String, Object>();
+ PrintStream originalStream = System.out;
+ AppFactory appFactory = matchingAppFactories.get(0);
+ try {
+ if (raw) {
+ PrintStream dummyStream = new PrintStream(new OutputStream()
{
- // no-op
- }
+ @Override
+ public void write(int b)
+ {
+ // no-op
+ }
- });
- System.setOut(dummyStream);
+ });
+ System.setOut(dummyStream);
+ }
+ LogicalPlan logicalPlan = appFactory.createApp(submitApp.getLogicalPlanConfiguration());
+ map.put("applicationName", appFactory.getName());
+ map.put("logicalPlan", LogicalPlanSerializer.convertToMap(logicalPlan));
+ } finally {
+ if (raw) {
+ System.setOut(originalStream);
+ }
}
+ printJson(map);
+ }
+ } else {
+ if (filename.endsWith(".json")) {
+ File file = new File(filename);
+ StramAppLauncher submitApp = new StramAppLauncher(file.getName(), config);
+ AppFactory appFactory = new StramAppLauncher.JsonFileAppFactory(file);
LogicalPlan logicalPlan = appFactory.createApp(submitApp.getLogicalPlanConfiguration());
+ Map<String, Object> map = new HashMap<String, Object>();
map.put("applicationName", appFactory.getName());
map.put("logicalPlan", LogicalPlanSerializer.convertToMap(logicalPlan));
- }
- finally {
- if (raw) {
- System.setOut(originalStream);
+ printJson(map);
+ } else if (filename.endsWith(".properties")) {
+ File file = new File(filename);
+ StramAppLauncher submitApp = new StramAppLauncher(file.getName(), config);
+ AppFactory appFactory = new StramAppLauncher.PropertyFileAppFactory(file);
+ LogicalPlan logicalPlan = appFactory.createApp(submitApp.getLogicalPlanConfiguration());
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("applicationName", appFactory.getName());
+ map.put("logicalPlan", LogicalPlanSerializer.convertToMap(logicalPlan));
+ printJson(map);
+ } else {
+ StramAppLauncher submitApp = getStramAppLauncher(filename, config, commandLineInfo.ignorePom);
+ submitApp.loadDependencies();
+ List<Map<String, Object>> appList = new ArrayList<Map<String, Object>>();
+ List<AppFactory> appFactoryList = submitApp.getBundledTopologies();
+ for (AppFactory appFactory : appFactoryList) {
+ Map<String, Object> m = new HashMap<String, Object>();
+ m.put("name", appFactory.getName());
+ appList.add(m);
}
+ printJson(appList, "applications");
}
- printJson(map);
}
- }
- else if (commandLineInfo.args.length == 1) {
- String filename = expandFileName(commandLineInfo.args[0], true);
- if (filename.endsWith(".json")) {
- File file = new File(filename);
- StramAppLauncher submitApp = new StramAppLauncher(file.getName(), config);
- AppFactory appFactory = new StramAppLauncher.JsonFileAppFactory(file);
- LogicalPlan logicalPlan = appFactory.createApp(submitApp.getLogicalPlanConfiguration());
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("applicationName", appFactory.getName());
- map.put("logicalPlan", LogicalPlanSerializer.convertToMap(logicalPlan));
- printJson(map);
- }
- else if (filename.endsWith(".properties")) {
- File file = new File(filename);
- StramAppLauncher submitApp = new StramAppLauncher(file.getName(), config);
- AppFactory appFactory = new StramAppLauncher.PropertyFileAppFactory(file);
- LogicalPlan logicalPlan = appFactory.createApp(submitApp.getLogicalPlanConfiguration());
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("applicationName", appFactory.getName());
- map.put("logicalPlan", LogicalPlanSerializer.convertToMap(logicalPlan));
- printJson(map);
- }
- else {
- StramAppLauncher submitApp = getStramAppLauncher(filename, config, commandLineInfo.ignorePom);
- submitApp.loadDependencies();
- List<Map<String, Object>> appList = new ArrayList<Map<String, Object>>();
- List<AppFactory> appFactoryList = submitApp.getBundledTopologies();
- for (AppFactory appFactory : appFactoryList) {
- Map<String, Object> m = new HashMap<String, Object>();
- m.put("name", appFactory.getName());
- appList.add(m);
- }
- printJson(appList, "applications");
- }
- }
- else {
+ } else {
if (currentApp == null) {
throw new CliException("No application selected");
}