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)); }
/** * 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; }
/** * 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; }
/** * 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; }
String text = ""; RetryConfig config = retryLayer.getConfiguration(); int maxRetries = config.getMaxRetries(); if (maxRetries < 1) { text += "The service is not re-tried";
.getConfiguration().getMaximumJobs()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); .getConfiguration().getMaximumJobs()); assertEquals(2, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(1000, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay());
.getConfiguration().getMaximumJobs()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); .getConfiguration().getMaximumJobs()); assertEquals(2, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(1000, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay());
.getConfiguration().getMaximumJobs()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(0, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay()); .getConfiguration().getMaximumJobs()); assertEquals(2, ((Retry) dispatchLayers.get(3)) .getConfiguration().getMaxRetries()); assertEquals(1000, ((Retry) dispatchLayers.get(3)) .getConfiguration().getInitialDelay());