Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass full topology information to ShellSpout/ShellBolt #686

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions storm-core/src/jvm/backtype/storm/task/GeneralTopologyContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,35 @@ public Map<String, Map<String, Grouping>> getTargets(String componentId) {
public String toJSONString() {
Map obj = new HashMap();
obj.put("task->component", _taskToComponent);
// TODO: jsonify StormTopology
// at the minimum should send source info
Map bolts = _topology.get_bolts();
Map spouts = _topology.get_spouts();
for (String compId : _taskToComponent.values()) {
Map compMap = new HashMap();
if (bolts.containsKey(compId)) {
List<String> jsonSources = new ArrayList<String>();
Map<GlobalStreamId, Grouping> sources = getSources(compId);
for (GlobalStreamId sourceId : sources.keySet()) {
jsonSources.add(sourceId.get_componentId());
}
compMap.put("sources", jsonSources);
}

if (spouts.containsKey(compId) || bolts.containsKey(compId)) {
List<String> jsonTargets = new ArrayList<String>();
for (Map<String, Grouping> targets : getTargets(compId).values()) {
for (String target : targets.keySet()) {
jsonTargets.add(target);
}
}
if (!jsonTargets.isEmpty()) {
compMap.put("targets", jsonTargets);
}
}

if (!compMap.isEmpty()) {
obj.put(compId, compMap);
}
}
return JSONValue.toJSONString(obj);
}

Expand Down
1 change: 1 addition & 0 deletions storm-core/src/jvm/backtype/storm/utils/ShellProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public Number launch(Map conf, TopologyContext context) throws IOException {
setupInfo.put("pidDir", context.getPIDDir());
setupInfo.put("conf", conf);
setupInfo.put("context", context);
setupInfo.put("componentId", context.getThisComponentId());
writeMessage(setupInfo);

return (Number)readMessage().get("pid");
Expand Down
4 changes: 3 additions & 1 deletion storm-core/src/multilang/py/storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def log(msg):
def initComponent():
setupInfo = readMsg()
sendpid(setupInfo['pidDir'])
return [setupInfo['conf'], setupInfo['context']]
context = setupInfo['context']
context['componentId'] = setupInfo['conponentId']
return setupInfo['conf'], context

class Tuple(object):
def __init__(self, id, component, stream, task, values):
Expand Down