use of com.datatorrent.stram.api.ContainerEvent.NodeActivationEvent in project apex-core by apache.
the class StreamingContainer method setupNode.
private void setupNode(OperatorDeployInfo ndi) {
failedNodes.remove(ndi.id);
final Node<?> node = nodes.get(ndi.id);
node.setup(node.context);
/* setup context for all the input ports */
LinkedHashMap<String, PortContextPair<InputPort<?>>> inputPorts = node.getPortMappingDescriptor().inputPorts;
LinkedHashMap<String, PortContextPair<InputPort<?>>> newInputPorts = new LinkedHashMap<>(inputPorts.size());
for (OperatorDeployInfo.InputDeployInfo idi : ndi.inputs) {
InputPort<?> port = inputPorts.get(idi.portName).component;
PortContext context = new PortContext(idi.contextAttributes, node.context);
newInputPorts.put(idi.portName, new PortContextPair<InputPort<?>>(port, context));
port.setup(context);
}
inputPorts.putAll(newInputPorts);
/* setup context for all the output ports */
LinkedHashMap<String, PortContextPair<OutputPort<?>>> outputPorts = node.getPortMappingDescriptor().outputPorts;
LinkedHashMap<String, PortContextPair<OutputPort<?>>> newOutputPorts = new LinkedHashMap<>(outputPorts.size());
for (OperatorDeployInfo.OutputDeployInfo odi : ndi.outputs) {
OutputPort<?> port = outputPorts.get(odi.portName).component;
PortContext context = new PortContext(odi.contextAttributes, node.context);
newOutputPorts.put(odi.portName, new PortContextPair<OutputPort<?>>(port, context));
port.setup(context);
}
outputPorts.putAll(newOutputPorts);
logger.debug("activating {} in container {}", node, containerId);
/* This introduces need for synchronization on processNodeRequest which was solved by adding deleted field in StramToNodeRequest */
processNodeRequests(false);
node.activate();
eventBus.publish(new NodeActivationEvent(node));
}
Aggregations