/** * Try to schedule a retry, returns true if a retry is scheduled, false * if the retry count has already been reached (in which case no retry * is scheduled * * @return */ @Override public boolean handleError() { if (currentRetryCount == config.getMaxRetries()) { return false; } int delay = (int) (config.getInitialDelay() * (Math.pow(config.getBackoffFactor(), currentRetryCount))); if (delay > config.getMaxDelay()) { delay = config.getMaxDelay(); } TimerTask task = new TimerTask() { @SuppressWarnings("unchecked") @Override public void run() { currentRetryCount++; getBelow().receiveJob(jobEvent); } }; retryTimer.schedule(task, delay); return true; }
public Retry(int maxRetries, int initialDelay, int maxDelay, float backoffFactor) { super(); this.config.setMaxRetries(maxRetries); this.config.setInitialDelay(initialDelay); this.config.setMaxDelay(maxDelay); this.config.setBackoffFactor(backoffFactor); }
/** * Try to schedule a retry, returns true if a retry is scheduled, false * if the retry count has already been reached (in which case no retry * is scheduled * * @return */ @Override public boolean handleError() { if (currentRetryCount == config.getMaxRetries()) { return false; } int delay = (int) (config.getInitialDelay() * (Math.pow(config.getBackoffFactor(), currentRetryCount))); if (delay > config.getMaxDelay()) { delay = config.getMaxDelay(); } TimerTask task = new TimerTask() { @SuppressWarnings("unchecked") @Override public void run() { currentRetryCount++; getBelow().receiveJob(jobEvent); } }; retryTimer.schedule(task, delay); return true; }
public Retry(int maxRetries, int initialDelay, int maxDelay, float backoffFactor) { super(); this.config.setMaxRetries(maxRetries); this.config.setInitialDelay(initialDelay); this.config.setMaxDelay(maxDelay); this.config.setBackoffFactor(backoffFactor); }
/** * Try to schedule a retry, returns true if a retry is scheduled, false * if the retry count has already been reached (in which case no retry * is scheduled * * @return */ @Override public boolean handleError() { if (currentRetryCount == config.getMaxRetries()) { return false; } int delay = (int) (config.getInitialDelay() * (Math.pow(config.getBackoffFactor(), currentRetryCount))); if (delay > config.getMaxDelay()) { delay = config.getMaxDelay(); } TimerTask task = new TimerTask() { @Override public void run() { currentRetryCount++; getBelow().receiveJob(jobEvent); } }; retryTimer.schedule(task, delay); return true; }
public Retry(int maxRetries, int initialDelay, int maxDelay, float backoffFactor) { super(); this.config.setMaxRetries(maxRetries); this.config.setInitialDelay(initialDelay); this.config.setMaxDelay(maxDelay); this.config.setBackoffFactor(backoffFactor); }
private void readConfiguration() { int maxRetries = configuration.getMaxRetries(); if (maxRetries < MIN_RETRIES) { maxRetries = defaultConfig.getMaxRetries(); } int initialDelay = configuration.getInitialDelay(); if (initialDelay < MIN_DELAY) { initialDelay = defaultConfig.getInitialDelay(); } int maxDelay = configuration.getMaxDelay(); if (maxDelay < MIN_DELAY) { maxDelay = defaultConfig.getMaxDelay(); } if (maxDelay < initialDelay) { maxDelay = initialDelay; } float backoffFactor = configuration.getBackoffFactor(); if (backoffFactor <= 1.0) { backoffFactor = defaultConfig.getBackoffFactor(); } maxRetriesField.setText(Integer.toString(maxRetries)); initialDelayField.setText(Integer.toString(initialDelay)); maximumDelayField.setText(Integer.toString(maxDelay)); backoffFactorField.setText(Float.toString(backoffFactor)); }
public RetryConfig getConfiguration() { RetryConfig newConfig = new RetryConfig(); newConfig.setMaxRetries(Integer.parseInt(maxRetriesField.getText())); newConfig.setInitialDelay(Integer.parseInt(initialDelayField.getText())); newConfig.setMaxDelay(Integer.parseInt(maximumDelayField.getText())); newConfig.setBackoffFactor(Float.parseFloat(backoffFactorField.getText())); return newConfig; }
String text = ""; RetryConfig config = retryLayer.getConfiguration(); int maxRetries = config.getMaxRetries(); if (maxRetries < 1) { text += "The service is not re-tried"; } else if (maxRetries == 1) { text += "The service is re-tried once"; text += " after " + config.getInitialDelay() + "ms"; } else { text += "The service is re-tried " + maxRetries + " times. "; float backoffFactor = config.getBackoffFactor(); int initialDelay = config.getInitialDelay(); if (backoffFactor == 1.0) { text += "Each time after a delay of " + initialDelay + "ms."; } else { int maxDelay = config.getMaxDelay(); text += "The first delay is " + initialDelay + "ms"; int noMaxDelay = (int) (initialDelay * Math.pow(backoffFactor,maxRetries - 1));
.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);
.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);
.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);