BackOff abstraction lives in util.backoff subpackage now
Issue: SPR-11746
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.util;
|
||||
package org.springframework.util.backoff;
|
||||
|
||||
/**
|
||||
* Provide a {@link BackOffExecution} that indicates the rate at which
|
||||
@@ -23,23 +23,21 @@ package org.springframework.util;
|
||||
* <p>Users of this interface are expected to use it like this:
|
||||
*
|
||||
* <pre class="code">
|
||||
* {@code
|
||||
* BackOffExecution exec = backOff.start();
|
||||
*
|
||||
* BackOffExecution exec = backOff.start();
|
||||
*
|
||||
* // In the operation recovery/retry loop:
|
||||
* long waitInterval = exec.nextBackOffMillis();
|
||||
* if (waitInterval == BackOffExecution.STOP) {
|
||||
* // do not retry operation
|
||||
* }
|
||||
* else {
|
||||
* // sleep, e.g. Thread.sleep(waitInterval)
|
||||
* // retry operation
|
||||
* }
|
||||
* // In the operation recovery/retry loop:
|
||||
* long waitInterval = exec.nextBackOffMillis();
|
||||
* if (waitInterval == BackOffExecution.STOP) {
|
||||
* // do not retry operation
|
||||
* }
|
||||
* else {
|
||||
* // sleep, e.g. Thread.sleep(waitInterval)
|
||||
* // retry operation
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* Once the underlying operation has completed successfully, the execution
|
||||
* instance can be simply discarded.
|
||||
* Once the underlying operation has completed successfully,
|
||||
* the execution instance can be simply discarded.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.util;
|
||||
package org.springframework.util.backoff;
|
||||
|
||||
/**
|
||||
* Represent a particular back-off execution.
|
||||
@@ -23,7 +23,7 @@ package org.springframework.util;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @since 4.1
|
||||
* @see org.springframework.util.BackOff
|
||||
* @see BackOff
|
||||
*/
|
||||
public interface BackOffExecution {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.util;
|
||||
package org.springframework.util.backoff;
|
||||
|
||||
/**
|
||||
* Implementation of {@link BackOff} that increases the back off period for each
|
||||
@@ -184,7 +184,7 @@ public class ExponentialBackOff implements BackOff {
|
||||
@Override
|
||||
public long nextBackOff() {
|
||||
if (currentElapsedTime >= maxElapsedTime) {
|
||||
return BackOffExecution.STOP;
|
||||
return STOP;
|
||||
}
|
||||
|
||||
long nextInterval = computeNextInterval();
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.util;
|
||||
package org.springframework.util.backoff;
|
||||
|
||||
/**
|
||||
* A simple {@link BackOff} implementation that provides a fixed interval
|
||||
@@ -102,7 +102,7 @@ public class FixedBackOff implements BackOff {
|
||||
return getInterval();
|
||||
}
|
||||
else {
|
||||
return BackOffExecution.STOP;
|
||||
return STOP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
/**
|
||||
*
|
||||
* A generic back-off abstraction.
|
||||
*
|
||||
*/
|
||||
package org.springframework.util.backoff;
|
||||
|
||||
Reference in New Issue
Block a user