@Override public DispatchLayer<?> createDispatchLayer(URI uri) { DispatchLayer<?> dispatchLayer = null; if (parallelizeLayer.equals(uri)) { dispatchLayer = new Parallelize(); } else if (errorBounceLayer.equals(uri)) { dispatchLayer = new ErrorBounce(); } else if (failoverLayer.equals(uri)) { dispatchLayer = new Failover(); } else if (retryLayer.equals(uri)) { dispatchLayer = new Retry(); } else if (invokeLayer.equals(uri)) { dispatchLayer = new Invoke(); } else if (loopLayer.equals(uri)) { dispatchLayer = new Loop(); } else if (intermediateProvenanceLayer.equals(uri)) { dispatchLayer = new IntermediateProvenance(); } else if (stopLayer.equals(uri)) { dispatchLayer = new Stop(); } return dispatchLayer; }
textArea.setEditable(false); String text = ""; RetryConfig config = retryLayer.getConfiguration(); int maxRetries = config.getMaxRetries(); if (maxRetries < 1) {
public void actionPerformed(ActionEvent e) { String title = "Retries for service " + retryLayer.getProcessor().getLocalName(); final JDialog dialog = new HelpEnabledDialog(owner, title, true); RetryConfigurationPanel retryConfigurationPanel = new RetryConfigurationPanel(retryLayer.getConfiguration()); dialog.add(retryConfigurationPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); JButton helpButton = new JButton(helpAction); buttonPanel.add(helpButton); JButton okButton = new JButton(new OKAction(dialog, retryConfigurationPanel)); buttonPanel.add(okButton); JButton resetButton = new JButton(new ResetAction( retryConfigurationPanel)); buttonPanel.add(resetButton); JButton cancelButton = new JButton(new CancelAction(dialog)); buttonPanel.add(cancelButton); dialog.add(buttonPanel, BorderLayout.SOUTH); dialog.pack(); dialog.setLocationRelativeTo(null); dialog.setVisible(true); }
@Override public String getViewTitle() { return "Retry of " + retryLayer.getProcessor().getLocalName(); }
public DefaultDispatchStackEdit(Processor processor) { super(processor); DispatchStackImpl stack = ((ProcessorImpl)processor).getDispatchStack(); // Top level parallelise layer int layer = 0; List<Edit<?>> edits = new ArrayList<Edit<?>>(); edits.add(new AddDispatchLayerEdit(stack, new Parallelize(MAX_JOBS), layer++)); edits.add(new AddDispatchLayerEdit(stack, new ErrorBounce(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Failover(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Retry(MAX_RETRIES, INITIAL_DELAY, MAX_DELAY, BACKOFF_FACTOR), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Invoke(), layer++)); compoundEdit=new CompoundEdit(edits); }
if (processor.getLocalName().equals("processor_a")) { assertEquals(1, ((Parallelize) dispatchLayers.get(0)) .getConfiguration().getMaximumJobs()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxDelay()); assertEquals(1, ((Retry) dispatchLayers.get(3)) .getConfiguration().getBackoffFactor(), 0); } else if (processor.getLocalName().equals("processor_b")) { assertEquals(4, ((Parallelize) dispatchLayers.get(0)) .getConfiguration().getMaximumJobs()); assertEquals(2, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(1000, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); assertEquals(2250, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxDelay()); assertEquals(1.5, ((Retry) dispatchLayers.get(3)) .getConfiguration().getBackoffFactor(), 0);
public DefaultDispatchStackEdit(Processor processor) { super(processor); DispatchStackImpl stack = ((ProcessorImpl)processor).getDispatchStack(); // Top level parallelise layer int layer = 0; List<Edit<?>> edits = new ArrayList<Edit<?>>(); edits.add(new AddDispatchLayerEdit(stack, new Parallelize(MAX_JOBS), layer++)); edits.add(new AddDispatchLayerEdit(stack, new ErrorBounce(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Failover(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Retry(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Stop(), layer++)); edits.add(new AddDispatchLayerEdit(stack, new Invoke(), layer++)); compoundEdit=new CompoundEdit(edits); }
if (processor.getLocalName().equals("processor_a")) { assertEquals(1, ((Parallelize) dispatchLayers.get(0)) .getConfiguration().getMaximumJobs()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxDelay()); assertEquals(1, ((Retry) dispatchLayers.get(3)) .getConfiguration().getBackoffFactor(), 0); } else if (processor.getLocalName().equals("processor_b")) { assertEquals(4, ((Parallelize) dispatchLayers.get(0)) .getConfiguration().getMaximumJobs()); assertEquals(2, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(1000, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); assertEquals(2250, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxDelay()); assertEquals(1.5, ((Retry) dispatchLayers.get(3)) .getConfiguration().getBackoffFactor(), 0);
new AddDispatchLayerEdit(stack, new ErrorBounce(), layer++).doEdit(); new AddDispatchLayerEdit(stack, new Failover(), layer++).doEdit(); new AddDispatchLayerEdit(stack, new Retry(MAX_RETRIES, INITIAL_DELAY, MAX_DELAY, BACKOFF_FACTOR), layer++).doEdit(); new AddDispatchLayerEdit(stack, new Invoke(), layer++).doEdit();
if (processor.getLocalName().equals("processor_a")) { assertEquals(1, ((Parallelize) dispatchLayers.get(0)) .getConfiguration().getMaximumJobs()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxDelay()); assertEquals(1, ((Retry) dispatchLayers.get(3)) .getConfiguration().getBackoffFactor(), 0); } else if (processor.getLocalName().equals("processor_b")) { assertEquals(4, ((Parallelize) dispatchLayers.get(0)) .getConfiguration().getMaximumJobs()); assertEquals(2, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(1000, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); assertEquals(2250, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxDelay()); assertEquals(1.5, ((Retry) dispatchLayers.get(3)) .getConfiguration().getBackoffFactor(), 0);
private void addDispatchLayers( org.embl.ebi.escience.scufl.Processor t1Processor, DispatchStack dispatchStack) throws EditException { int maxJobs = t1Processor.getWorkers(); int maxRetries = t1Processor.getRetries(); float backoffFactor = (float) t1Processor.getBackoff(); int initialDelay = t1Processor.getRetryDelay(); int maxDelay = (int) (initialDelay * (Math.pow(backoffFactor, maxRetries))); DispatchLayer<?> parallelize = new Parallelize(maxJobs); DispatchLayer<?> errorBounce = new ErrorBounce(); DispatchLayer<?> failover = new Failover(); DispatchLayer<?> retry = new Retry(maxRetries, initialDelay, maxDelay, backoffFactor); DispatchLayer<?> invoke = new Invoke(); int layer = 0; edits.getAddDispatchLayerEdit(dispatchStack, parallelize, layer++).doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, errorBounce, layer++).doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, failover, layer++).doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, retry, layer++).doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, invoke, layer++).doEdit(); }
private void addDispatchLayers( org.embl.ebi.escience.scufl.Processor t1Processor, DispatchStack dispatchStack) throws EditException { int maxJobs = t1Processor.getWorkers(); int maxRetries = t1Processor.getRetries(); float backoffFactor = (float) t1Processor.getBackoff(); int initialDelay = t1Processor.getRetryDelay(); int maxDelay = (int) (initialDelay * (Math.pow(backoffFactor, maxRetries))); DispatchLayer<?> parallelize = new Parallelize(maxJobs); DispatchLayer<?> errorBounce = new ErrorBounce(); DispatchLayer<?> failover = new Failover(); DispatchLayer<?> retry = new Retry(maxRetries, initialDelay, maxDelay, backoffFactor); DispatchLayer<?> invoke = new Invoke(); int layer = 0; edits.getAddDispatchLayerEdit(dispatchStack, parallelize, layer++) .doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, errorBounce, layer++) .doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, failover, layer++) .doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, retry, layer++).doEdit(); edits.getAddDispatchLayerEdit(dispatchStack, invoke, layer++).doEdit(); }
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))); }