/** * 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); } }
/** * 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); } }
/** * 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); } }
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); } } }
private void addIterationNode(MutableTreeNode node, IterationStrategyImpl t2IterationStrategy, AbstractIterationStrategyNode 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); } } }
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 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; }
public void testMutipleData() throws MalformedIdentifierException { NamedInputPortNode nipn1 = new NamedInputPortNode("a", 0); NamedInputPortNode nipn2 = new NamedInputPortNode("b", 0); DotProduct dp = new DotProduct(); nipn1.setParent(dp); nipn2.setParent(dp); DiagnosticIterationStrategyNode disn = new DiagnosticIterationStrategyNode(); dp.setParent(disn); IterationStrategyImpl is = new IterationStrategyImpl(); is.addInput(nipn1); is.addInput(nipn2); String owningProcess = "Process1"; for (int i = 0; i < 4; i++) { EntityListIdentifier dataReference = new EntityListIdentifier("urn:t2data:list://foo.bar/alist"+i+"/1"); is.receiveData("a", owningProcess, new int[]{i}, dataReference, context); } is.receiveCompletion("a", owningProcess, new int[]{}, context); for (int i = 0; i < 4; i++) { EntityListIdentifier dataReference = new EntityListIdentifier("urn:t2data:list://foo.bar/blist"+i+"/1"); is.receiveData("b", owningProcess, new int[]{i}, dataReference, context); } is.receiveCompletion("b", owningProcess, new int[]{}, context); assertTrue(disn.jobsReceived("Process1")==4); System.out.println(disn); }
public void testBasic() { NamedInputPortNode nipn = new NamedInputPortNode("Input", 0); DiagnosticIterationStrategyNode disn = new DiagnosticIterationStrategyNode(); nipn.setParent(disn); IterationStrategyImpl is = new IterationStrategyImpl(); is.addInput(nipn); try { is.receiveData("Input", "Process1", new int[]{}, nextID(), context); } catch (WorkflowStructureException e) { fail("Should be able to find input named 'Input' in this test case"); } assertTrue(disn.jobsReceived("Process1") == 1); }
public void testBasic() { NamedInputPortNode nipn1 = new NamedInputPortNode("Input1", 0); NamedInputPortNode nipn2 = new NamedInputPortNode("Input2", 0); DotProduct dp = new DotProduct(); nipn1.setParent(dp); nipn2.setParent(dp); DiagnosticIterationStrategyNode disn = new DiagnosticIterationStrategyNode(); dp.setParent(disn); IterationStrategyImpl is = new IterationStrategyImpl(); is.addInput(nipn1); is.addInput(nipn2); try { is.receiveData("Input1", "Process1", new int[] {0}, nextID(), context); is.receiveCompletion("Input1", "Process1", new int[]{}, context); assertTrue(disn.jobsReceived("Process1") == 0); is.receiveData("Input2", "Process1", new int[] {0}, nextID(), context); is.receiveCompletion("Input2", "Process1", new int[]{}, context); assertTrue(disn.jobsReceived("Process1") == 1); System.out.println(disn); } catch (WorkflowStructureException e) { fail("Unknown structure exception"); } }
public void testMultipleProcess() { NamedInputPortNode nipn1 = new NamedInputPortNode("Input1", 0); NamedInputPortNode nipn2 = new NamedInputPortNode("Input2", 0); DotProduct dp = new DotProduct(); nipn1.setParent(dp); nipn2.setParent(dp); DiagnosticIterationStrategyNode disn = new DiagnosticIterationStrategyNode(); dp.setParent(disn); IterationStrategyImpl is = new IterationStrategyImpl(); is.addInput(nipn1); is.addInput(nipn2); try { is.receiveData("Input1", "Process1", new int[] {}, nextID(), context); assertTrue(disn.jobsReceived("Process1") == 0); is.receiveCompletion("Input1", "Process1", new int[]{}, context); is.receiveData("Input2", "Process2", new int[] {}, nextID(), context); assertTrue(disn.jobsReceived("Process1") == 0); is.receiveData("Input2", "Process1", new int[] {}, nextID(), context); assertTrue(disn.jobsReceived("Process1") == 1); is.receiveCompletion("Input2", "Process1", new int[]{}, context); System.out.println(disn); } catch (WorkflowStructureException e) { fail("Unknown structure exception"); } }
public void testMultipleProcesses() { NamedInputPortNode nipn = new NamedInputPortNode("Input", 0); DiagnosticIterationStrategyNode disn = new DiagnosticIterationStrategyNode(); nipn.setParent(disn); IterationStrategyImpl is = new IterationStrategyImpl(); is.addInput(nipn); try { is.receiveData("Input", "Process1", new int[]{0}, nextID(), context); is.receiveData("Input", "Process1", new int[]{1}, nextID(), context); is.receiveData("Input", "Process2", new int[]{}, nextID(), context); } catch (WorkflowStructureException e) { fail("Should be able to find input named 'Input' in this test case"); } assertTrue(disn.jobsReceived("Process1") == 2); assertTrue(disn.jobsReceived("Process2") == 1); }