Repository: incubator-apex-core Updated Branches: refs/heads/release-3.3 d5315edec -> c96ed4d6b
APEXCORE-376 corrected processing of logical plan output in dtcli for dump-properties-file command 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/c96ed4d6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/tree/c96ed4d6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-core/diff/c96ed4d6 Branch: refs/heads/release-3.3 Commit: c96ed4d6bddc692d29574502c78cb538857edd5d Parents: d5315ed Author: David Yan <[email protected]> Authored: Fri Mar 4 10:57:21 2016 -0800 Committer: David Yan <[email protected]> Committed: Fri Mar 4 11:19:24 2016 -0800 ---------------------------------------------------------------------- .../java/com/datatorrent/stram/cli/DTCli.java | 2 +- .../stram/codec/LogicalPlanSerializer.java | 31 ++++++++------------ 2 files changed, 13 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/c96ed4d6/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 e5e3027..09812e6 100644 --- a/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java +++ b/engine/src/main/java/com/datatorrent/stram/cli/DTCli.java @@ -613,7 +613,7 @@ public class DTCli null, "Begin Macro Definition ($1...$9 to access parameters and type 'end' to end the definition)")); globalCommands.put("dump-properties-file", new CommandSpec(new DumpPropertiesFileCommand(), - new Arg[]{new FileArg("out-file"), new FileArg("jar-file"), new Arg("class-name")}, + new Arg[]{new FileArg("out-file"), new FileArg("jar-file"), new Arg("app-name")}, null, "Dump the properties file of an app class")); globalCommands.put("get-app-info", new CommandSpec(new GetAppInfoCommand(), http://git-wip-us.apache.org/repos/asf/incubator-apex-core/blob/c96ed4d6/engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java ---------------------------------------------------------------------- diff --git a/engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java b/engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java index 7b61d5b..088ccd1 100644 --- a/engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java +++ b/engine/src/main/java/com/datatorrent/stram/codec/LogicalPlanSerializer.java @@ -265,19 +265,16 @@ public class LogicalPlanSerializer extends JsonSerializer<LogicalPlan> public static PropertiesConfiguration convertToProperties(JSONObject json) throws JSONException { PropertiesConfiguration props = new PropertiesConfiguration(); - JSONObject allOperators = json.getJSONObject("operators"); - JSONObject allStreams = json.getJSONObject("streams"); - - @SuppressWarnings("unchecked") - Iterator<String> operatorIter = allOperators.keys(); - while (operatorIter.hasNext()) { - String operatorName = operatorIter.next(); - JSONObject operatorDetail = allOperators.getJSONObject(operatorName); + JSONArray allOperators = json.getJSONArray("operators"); + JSONArray allStreams = json.getJSONArray("streams"); + + for (int j = 0; j < allOperators.length(); j++) { + JSONObject operatorDetail = allOperators.getJSONObject(j); + String operatorName = operatorDetail.getString("name"); String operatorKey = LogicalPlanConfiguration.OPERATOR_PREFIX + operatorName; props.setProperty(operatorKey + ".classname", operatorDetail.getString("class")); JSONObject properties = operatorDetail.optJSONObject("properties"); if (properties != null) { - @SuppressWarnings("unchecked") Iterator<String> iter2 = properties.keys(); while (iter2.hasNext()) { String propertyName = iter2.next(); @@ -292,8 +289,7 @@ public class LogicalPlanSerializer extends JsonSerializer<LogicalPlan> value += list.get(i).toString(); } props.setProperty(operatorKey + "." + propertyName, value); - } - else { + } else { props.setProperty(operatorKey + "." + propertyName, properties.get(propertyName)); } } @@ -301,11 +297,9 @@ public class LogicalPlanSerializer extends JsonSerializer<LogicalPlan> } } - @SuppressWarnings("unchecked") - Iterator<String> streamIter = allStreams.keys(); - while (streamIter.hasNext()) { - String streamName = streamIter.next(); - JSONObject streamDetail = allStreams.getJSONObject(streamName); + for (int j = 0; j < allStreams.length(); j++) { + JSONObject streamDetail = allStreams.getJSONObject(j); + String streamName = streamDetail.getString("name"); String streamKey = LogicalPlanConfiguration.STREAM_PREFIX + streamName; JSONObject sourceDetail = streamDetail.getJSONObject("source"); JSONArray sinksList = streamDetail.getJSONArray("sinks"); @@ -319,7 +313,7 @@ public class LogicalPlanSerializer extends JsonSerializer<LogicalPlan> sinksValue += sinksList.getJSONObject(i).getString("operatorName") + "." + sinksList.getJSONObject(i).getString("portName"); } props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_SINKS, sinksValue); - String locality = streamDetail.optString("locality"); + String locality = streamDetail.optString("locality", null); if (locality != null) { props.setProperty(streamKey + "." + LogicalPlanConfiguration.STREAM_LOCALITY, Locality.valueOf(locality)); } @@ -336,8 +330,7 @@ public class LogicalPlanSerializer extends JsonSerializer<LogicalPlan> } @Override - public void serialize(LogicalPlan dag, JsonGenerator jg, SerializerProvider sp) throws IOException, - JsonProcessingException + public void serialize(LogicalPlan dag, JsonGenerator jg, SerializerProvider sp) throws IOException { jg.writeObject(convertToMap(dag, false)); }
