本文整理匯總了Java中org.springframework.retry.backoff.BackOffContext類的典型用法代碼示例。如果您正苦於以下問題:Java BackOffContext類的具體用法?Java BackOffContext怎麽用?Java BackOffContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BackOffContext類屬於org.springframework.retry.backoff包,在下文中一共展示了BackOffContext類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import org.springframework.retry.backoff.BackOffContext; //導入依賴的package包/類
@Override
public BackOffContext start(RetryContext retryContext) {
return new BackOffContext() {
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
};
}
示例2: testBackOffPolicyIsExponential
import org.springframework.retry.backoff.BackOffContext; //導入依賴的package包/類
@Test
public void testBackOffPolicyIsExponential()
{
List<Long> sleeps = newArrayList();
ExponentialBackOffPolicy fakeBackOff = this.backOffPolicy.withSleeper(sleeps::add);
BackOffContext context = fakeBackOff.start(null);
for (int i = 0; i < 11; i++)
{
fakeBackOff.backOff(context);
}
assertEquals(sleeps,
Arrays.asList(1000L, 2000L, 4000L, 8000L, 16000L, 32000L, 64000L, 128000L, 256000L, 300000L, 300000L));
}
示例3: backOff
import org.springframework.retry.backoff.BackOffContext; //導入依賴的package包/類
@Override
public void backOff(BackOffContext backOffContext) throws BackOffInterruptedException {
backoffAttempts++;
}
示例4: start
import org.springframework.retry.backoff.BackOffContext; //導入依賴的package包/類
@Override
public BackOffContext start(RetryContext retryContext) {
return null;
}
示例5: backOff
import org.springframework.retry.backoff.BackOffContext; //導入依賴的package包/類
@Override
public void backOff(BackOffContext backOffContext) throws BackOffInterruptedException {
count++;
}