@Override public String toString() { return getClass().getSimpleName() + " " + getPortName() + "(" + getCardinality() + ")"; }
/** * Completion events are passed straight through the same as jobs */ public void receiveCompletion(int inputIndex, Completion completion) { pushCompletion(completion); }
/** * If this node receives a job it will always be pushed without modification * up to the parent */ public void receiveJob(int inputIndex, Job newJob) { pushJob(newJob); }
public void removeInputByName(String name) { synchronized (inputs) { NamedInputPortNode removeMe = null; for (NamedInputPortNode nipn : inputs) { if (nipn.getPortName().equals(name)) { removeMe = nipn; } } if (removeMe != null) { this.inputs.remove(removeMe); removeMe.removeFromParent(); } } }
private IterationStrategyImpl getISDot(int depthA, int depthB) { IterationStrategyImpl is1 = new IterationStrategyImpl(); NamedInputPortNode nipn1 = new NamedInputPortNode("a", depthA); NamedInputPortNode nipn2 = new NamedInputPortNode("b", depthB); is1.addInput(nipn1); is1.addInput(nipn2); DotProduct dp = new DotProduct(); nipn1.setParent(dp); nipn2.setParent(dp); dp.setParent(is1.getTerminal()); return is1; }
private static AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
void removeInputByName(String name) { synchronized (inputs) { NamedInputPortNode removeMe = null; for (NamedInputPortNode nipn : inputs) { if (nipn.getPortName().equals(name)) { removeMe = nipn; } } if (removeMe != null) { this.inputs.remove(removeMe); } } }
/** * Connect up a new named input port node to the first child of the terminal * node. If the terminal node doesn't have any children then create a new * cross product node, connect it to the terminal and connect the new input * port node to the cross product (saneish default behaviour) * * @param nipn */ public synchronized void connectDefault(NamedInputPortNode nipn) { if (terminal.getChildCount() == 0) { CrossProduct cp = new CrossProduct(); cp.setParent(terminal); nipn.setParent(cp); } else { AbstractIterationStrategyNode node = (AbstractIterationStrategyNode) (terminal .getChildAt(0)); nipn.setParent(node); } }
ReferenceService rs = e.getContext().getReferenceService(); NamedInputPortNode ipn = nodeForName(portName); int desiredDepth = ipn.getCardinality(); Iterator<ContextualizedT2Reference> ids = rs.traverseFrom( dataRef, desiredDepth);
public void receiveCompletion(String inputPortName, String owningProcess, int[] completionArray, InvocationContext context) throws WorkflowStructureException { nodeForName(inputPortName).receiveCompletion(0, new Completion(owningProcess, completionArray, context)); }
/** * Receive a single data event from an upstream process. This method is only * ever called on the first layer in the IterationStrategyStackImpl, other * layers are passed entire Job objects * * @param inputPortName * @param owningProcess * @param indexArray * @param dataReference * @throws WorkflowStructureException */ public void receiveData(String inputPortName, String owningProcess, int[] indexArray, T2Reference dataReference, InvocationContext context) throws WorkflowStructureException { Map<String, T2Reference> dataMap = new HashMap<String, T2Reference>(); dataMap.put(inputPortName, dataReference); Job newJob = new Job(owningProcess, indexArray, dataMap, context); nodeForName(inputPortName).receiveJob(0, newJob); }
private IterationStrategyImpl getISCross(int depthA, int depthB) { IterationStrategyImpl is1 = new IterationStrategyImpl(); NamedInputPortNode nipn1 = new NamedInputPortNode("a", depthA); NamedInputPortNode nipn2 = new NamedInputPortNode("b", depthB); is1.addInput(nipn1); is1.addInput(nipn2); CrossProduct cp = new CrossProduct(); nipn1.setParent(cp); nipn2.setParent(cp); cp.setParent(is1.getTerminal()); return is1; }
private AbstractIterationStrategyNode nodeForElement(Element e) { AbstractIterationStrategyNode node = null; String eName = e.getName(); if (eName.equals("dot")) { node = new DotProduct(); } else if (eName.equals("cross")) { node = new CrossProduct(); } else if (eName.equals("prefix")) { node = new PrefixDotProduct(); } else if (eName.equals("port")) { String portName = e.getAttributeValue("name"); int portDepth = Integer.parseInt(e.getAttributeValue("depth")); node = new NamedInputPortNode(portName, portDepth); addInput((NamedInputPortNode) node); } for (Object child : e.getChildren()) { Element childElement = (Element) child; nodeForElement(childElement).setParent(node); } return node; }
private NamedInputPortNode nodeForName(String portName) throws WorkflowStructureException { for (NamedInputPortNode node : inputs) { if (node.getPortName().equals(portName)) { return node; } } throw new WorkflowStructureException("No port found with name '" + portName + "'"); }
public void removeInputByName(String name) { synchronized (inputs) { NamedInputPortNode removeMe = null; for (NamedInputPortNode nipn : inputs) { if (nipn.getPortName().equals(name)) { removeMe = nipn; } } if (removeMe != null) { this.inputs.remove(removeMe); removeMe.removeFromParent(); } } }
/** * Connect up a new named input port node to the first child of the terminal * node. If the terminal node doesn't have any children then create a new * cross product node, connect it to the terminal and connect the new input * port node to the cross product (saneish default behaviour) * * @param nipn */ public synchronized void connectDefault(NamedInputPortNode nipn) { if (terminal.getChildCount() == 0) { CrossProduct cp = new CrossProduct(); cp.setParent(terminal); nipn.setParent(cp); } else { AbstractIterationStrategyNode node = (AbstractIterationStrategyNode) (terminal .getChildAt(0)); nipn.setParent(node); } }
DataManager manager = e.getContext().getDataManager(); NamedInputPortNode ipn = nodeForName(portName); int desiredDepth = ipn.getCardinality(); Iterator<ContextualizedIdentifier> ids = manager.traverse( dataRef, desiredDepth);
public void receiveCompletion(String inputPortName, String owningProcess, int[] completionArray, InvocationContext context) throws WorkflowStructureException { nodeForName(inputPortName).receiveCompletion(0, new Completion(owningProcess, completionArray, context)); }
/** * Receive a single data event from an upstream process. This method is only * ever called on the first layer in the IterationStrategyStackImpl, other * layers are passed entire Job objects * * @param inputPortName * @param owningProcess * @param indexArray * @param dataReference * @throws WorkflowStructureException */ public void receiveData(String inputPortName, String owningProcess, int[] indexArray, T2Reference dataReference, InvocationContext context) throws WorkflowStructureException { Map<String, T2Reference> dataMap = new HashMap<String, T2Reference>(); dataMap.put(inputPortName, dataReference); Job newJob = new Job(owningProcess, indexArray, dataMap, context); nodeForName(inputPortName).receiveJob(0, newJob); }
private void addIterationNode(MutableTreeNode node, IterationStrategyImpl t2IterationStrategy, IterationStrategyNode parent, Processor t2Processor) { if (node instanceof LeafNode) { String nodeName = (String) ((LeafNode) node).getUserObject(); for (InputPort ip : t2Processor.getInputPorts()) { if (ip.getName().equals(nodeName)) { NamedInputPortNode inputPortNode = new NamedInputPortNode( nodeName, ip.getDepth()); inputPortNode.setParent(parent); t2IterationStrategy.addInput(inputPortNode); break; } } } else { AbstractIterationStrategyNode strategyNode = null; if (node instanceof DotNode) { strategyNode = new DotProduct(); } else { strategyNode = new CrossProduct(); } strategyNode.setParent(parent); for (Enumeration<?> en = node.children(); en.hasMoreElements();) { addIterationNode((MutableTreeNode) en.nextElement(), t2IterationStrategy, strategyNode, t2Processor); } } }