public Processor createProcessor(String name) { ProcessorImpl processor = new ProcessorImpl(); processor.setName(name); return processor; }
@Override protected List<? extends Activity<?>> getActivities() { return ProcessorImpl.this.getActivityList(); }
@Override protected void undoEditAction(ProcessorImpl processor) { processor.iterationStack .configureFromElement(previousIterationStrategyState); processor.inputPorts .remove(processor.getInputPortWithName(newPortName)); }
@Override protected void doEditAction(ProcessorImpl processor) throws EditException { oldName = processor.getLocalName(); processor.setName(newName); }
p.registerWithMonitor(owningProcess); if (p.getInputPorts().isEmpty()) { p.fire(owningProcess, context);
if (pi.getLocalName().equals(split[0])) { source = pi.getOutputPortWithName(split[1]); break; if (pi.getLocalName().equals(split[0])) { sink = pi.getInputPortWithName(split[1]); break;
@Override protected void undoEditAction(ProcessorImpl processor) { BasicEventForwardingOutputPort pop = processor.getOutputPortWithName(portName); if (pop != null) { processor.outputPorts.remove(pop); } }
@Override public String toString() { return "Processor " + getLocalName(); } }
@Test public synchronized void singleDataTokenBehaviour() throws MalformedIdentifierException, EditException, JDOMException, IOException, ActivityConfigurationException, InterruptedException { // System.out.println("Single token, 'A string'"); // Build an input data token WorkflowDataToken token = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("A string"), context); processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(250); assertEquals(1, deh.getEventCount()); }
@Before public void setup() throws Exception { merge = new MergeImpl("the merge"); ProcessorImpl p1 = new ProcessorImpl(); ProcessorImpl p2 = new ProcessorImpl(); sourcePort=new ProcessorOutputPortImpl(p1,"source_port",0,0); sinkPort=new ProcessorInputPortImpl(p2,"sink_port",0); }
/** * We've finished here, set the satisfied property on any controlled * condition objects to true and notify the targets. */ @Override protected void finishedWith(String owningProcess) { if (! controlledConditions.isEmpty()) { String enclosingProcess = owningProcess.substring(0, owningProcess.lastIndexOf(':')); for (ConditionImpl ci : controlledConditions) { ci.satisfy(enclosingProcess); ci.getTarget().getDispatchStack().satisfyConditions( enclosingProcess); } } }
public void testProcessorAsXMLRoundTrip() throws EditException, ArtifactNotFoundException, ArtifactStateException, ClassNotFoundException, InstantiationException, IllegalAccessException, JDOMException, IOException, ActivityConfigurationException { ProcessorImpl p = (ProcessorImpl)new EditsImpl().createProcessor("a_processor"); DispatchStackImpl stack = p.getDispatchStack(); new AddDispatchLayerEdit(stack, new Parallelize(), 0).doEdit(); new AddDispatchLayerEdit(stack, new Retry(2, 50, 2000, 1), 1).doEdit(); new AddDispatchLayerEdit(stack, new DummyInvokerLayer(), 2).doEdit(); new CreateProcessorInputPortEdit(p, "Input1", 1).doEdit(); new CreateProcessorInputPortEdit(p, "Input2", 0).doEdit(); Element e = p.asXML(); ProcessorImpl p2 = (ProcessorImpl)new EditsImpl().createProcessor("a_processor"); p2.configureFromElement(e); Element e2 = p2.asXML(); XMLOutputter xo = new XMLOutputter(); assertTrue(xo.outputString(e).equals(xo.outputString(e2))); }
@Override protected void undoEditAction(ProcessorImpl processor) { processor.setName(oldName); }
@Override /** * Used to construct a Job of empty lists at the appropriate depth in the * event of a completion hitting the crystalizer before it sees a child * node, i.e. the result of iterating over an empty collection structure of * some kind. */ public Job getEmptyJob(String owningProcess, int[] index, InvocationContext context) { int wrappingDepth = parent.resultWrappingDepth; if (wrappingDepth < 0) throw new RuntimeException( "Processor hasn't been configured, cannot emit empty job"); // The wrapping depth is the length of index array that would be used if // a single item of the output port type were returned. We can examine // the index array for the node we're trying to create and use this to // work out how much we need to add to the output port depth to create // empty lists of the right type given the index array. int depth = wrappingDepth - index.length; // TODO - why was this incrementing? // depth++; DataManager dManager = context.getDataManager(); Map<String, EntityIdentifier> emptyJobMap = new HashMap<String, EntityIdentifier>(); for (OutputPort op : parent.getOutputPorts()) { emptyJobMap.put(op.getName(), dManager.registerEmptyList(depth + op.getDepth())); } return new Job(owningProcess, index, emptyJobMap, context); }
p.registerWithMonitor(owningProcess); if (p.getInputPorts().isEmpty()) { p.fire(owningProcess, context);
if (pi.getLocalName().equals(split[0])) { source = pi.getOutputPortWithName(split[1]); break; if (pi.getLocalName().equals(split[0])) { sink = pi.getInputPortWithName(split[1]); break;
@Override protected void doEditAction(ProcessorImpl processor) throws EditException { oldName = processor.getLocalName(); processor.setName(newName); }
@Override protected void undoEditAction(ProcessorImpl processor) { BasicEventForwardingOutputPort pop = processor.getOutputPortWithName(port.getName()); if (pop != null) { processor.outputPorts.remove(pop); } }
@Override public String transformOwningProcess(String oldOwner) { return oldOwner + ":" + parent.getLocalName(); }
@Test public void topLevelEmptyCollection() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { // System.out.println("Top level empty list (depth 2)"); EntityIdentifier listIdentifier = dManager .registerEmptyList(2); ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(0); WorkflowDataToken token = new WorkflowDataToken("outerProcess4", new int[0], listIdentifier, context); // This is not a public API! We're using it here because we need some // way to push the configuration data into the processor that would // normally be created during the typecheck operation. In this case // we're declaring that we've given a list of lists to the processor // where it wanted a single item and that it therefore has a wrapping // level of 2 after the iteration strategy has been applied. processor.resultWrappingDepth = 2; processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(100); assertEquals(1, deh.getEventCount()); }