You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2015/05/15 20:56:29 UTC
[03/12] storm git commit: Address comments for PR #525
Address comments for PR #525
- Fixed a couple style/formatting issues
- Made groupings get converted to dictionaries that contain 'type' and 'fields'
keys (where only 'type' is required).
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/c47d7d42
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/c47d7d42
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/c47d7d42
Branch: refs/heads/0.10.x-branch
Commit: c47d7d42d1a769277dfc4b6e11e5e07e3279b707
Parents: 6961be7
Author: Dan Blanchard <da...@parsely.com>
Authored: Mon Apr 20 15:52:43 2015 -0400
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Fri May 15 14:04:07 2015 -0400
----------------------------------------------------------------------
.../backtype/storm/task/TopologyContext.java | 57 ++++++++++----------
1 file changed, 29 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/c47d7d42/storm-core/src/jvm/backtype/storm/task/TopologyContext.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/task/TopologyContext.java b/storm-core/src/jvm/backtype/storm/task/TopologyContext.java
index c35d9db..8124651 100644
--- a/storm-core/src/jvm/backtype/storm/task/TopologyContext.java
+++ b/storm-core/src/jvm/backtype/storm/task/TopologyContext.java
@@ -145,25 +145,25 @@ public class TopologyContext extends WorkerTopologyContext implements IMetricsCo
return getComponentId(_taskId);
}
- /**
- * Gets the declared output fields for the specified stream id for the component
- * this task is a part of.
- */
- public Fields getThisOutputFields(String streamId) {
- return getComponentOutputFields(getThisComponentId(), streamId);
- }
-
- /**
- * Gets the declared output fields for the specified stream id for the component
- * this task is a part of.
- */
- public Map<String, List<String>> getThisOutputFieldsForStreams() {
- Map<String, List<String>> streamToFields = new HashMap<String, List<String>>();
- for (String stream : this.getThisStreams()) {
- streamToFields.put(stream, this.getThisOutputFields(stream).toList());
- }
- return streamToFields;
- }
+ /**
+ * Gets the declared output fields for the specified stream id for the
+ * component this task is a part of.
+ */
+ public Fields getThisOutputFields(String streamId) {
+ return getComponentOutputFields(getThisComponentId(), streamId);
+ }
+
+ /**
+ * Gets the declared output fields for the specified stream id for the
+ * component this task is a part of.
+ */
+ public Map<String, List<String>> getThisOutputFieldsForStreams() {
+ Map<String, List<String>> streamToFields = new HashMap<String, List<String>>();
+ for (String stream : this.getThisStreams()) {
+ streamToFields.put(stream, this.getThisOutputFields(stream).toList());
+ }
+ return streamToFields;
+ }
/**
* Gets the set of streams declared for the component of this task.
@@ -231,13 +231,14 @@ public class TopologyContext extends WorkerTopologyContext implements IMetricsCo
return _hooks;
}
- public Object groupingToJSONableObject(Grouping grouping) {
- if (grouping.is_set_fields()) {
- return grouping.get_fields();
- } else {
- return grouping.getSetField().toString();
- }
- }
+ private static Map<String, Object> groupingToJSONableMap(Grouping grouping) {
+ Map groupingMap = new HashMap<String, Object>();
+ groupingMap.put("type", grouping.getSetField().toString());
+ if (grouping.is_set_fields()) {
+ groupingMap.put("fields", grouping.get_fields());
+ }
+ return groupingMap;
+ }
@Override
public String toJSONString() {
@@ -254,7 +255,7 @@ public class TopologyContext extends WorkerTopologyContext implements IMetricsCo
for (Map.Entry<String, Map<String, Grouping>> entry : this.getThisTargets().entrySet()) {
Map stringTargetMap = new HashMap<String, Object>();
for (Map.Entry<String, Grouping> innerEntry : entry.getValue().entrySet()) {
- stringTargetMap.put(innerEntry.getKey(), groupingToJSONableObject(innerEntry.getValue()));
+ stringTargetMap.put(innerEntry.getKey(), groupingToJSONableMap(innerEntry.getValue()));
}
stringTargets.put(entry.getKey(), stringTargetMap);
}
@@ -268,7 +269,7 @@ public class TopologyContext extends WorkerTopologyContext implements IMetricsCo
stringSourceMap = new HashMap<String, Object>();
stringSources.put(gid.get_componentId(), stringSourceMap);
}
- stringSourceMap.put(gid.get_streamId(), groupingToJSONableObject(entry.getValue()));
+ stringSourceMap.put(gid.get_streamId(), groupingToJSONableMap(entry.getValue()));
}
obj.put("source->stream->grouping", stringSources);
return JSONValue.toJSONString(obj);