下载调整
This commit is contained in:
parent
704e9eb9a0
commit
7d71478baf
@ -275,6 +275,12 @@ public class WvpService {
|
||||
JsonResponse<String> addDownloadTask2MediaServer = wvpProxyClient.addDownloadTask2MediaServer(token, mediaServerId, new AddDownloadTaskReq(app, stream));
|
||||
String taskId = addDownloadTask2MediaServer.getData();
|
||||
Retryer<JsonResponse<String>> mediaServerRetryer = RetryUtil.<String>getDefaultRetryerBuilder("从 mediaServer 获取视频")
|
||||
// 重试间隔
|
||||
.withWaitStrategy(WaitStrategies.fixedWait(RetryUtil.DEFAULT_RETRY_INTERVAL, TimeUnit.SECONDS))
|
||||
// 重试次数
|
||||
.withStopStrategy(StopStrategies.stopAfterAttempt(RetryUtil.DEFAULT_RETRY_TIME))
|
||||
.retryIfResult(RetryUtil.defaultRetryIf())
|
||||
.withRetryListener(RetryUtil.defaultRetryListener("从 mediaServer 获取视频"))
|
||||
.withStopStrategy(StopStrategies.stopAfterAttempt(10))
|
||||
.build();
|
||||
return mediaServerRetryer.call(() -> {
|
||||
|
@ -57,18 +57,19 @@ public class RetryUtil {
|
||||
return RetryerBuilder.<JsonResponse<T>>newBuilder()
|
||||
// 异常就重试
|
||||
.retryIfException()
|
||||
.retryIfRuntimeException()
|
||||
.retryIfRuntimeException();
|
||||
}
|
||||
|
||||
|
||||
public static <T> Retryer<JsonResponse<T>> getDefaultRetryer(String name) {
|
||||
return RetryUtil.<T>getDefaultRetryerBuilder(name)
|
||||
// 重试间隔
|
||||
.withWaitStrategy(WaitStrategies.fixedWait(DEFAULT_RETRY_INTERVAL, TimeUnit.SECONDS))
|
||||
// 重试次数
|
||||
.withStopStrategy(StopStrategies.stopAfterAttempt(DEFAULT_RETRY_TIME))
|
||||
.retryIfResult(defaultRetryIf())
|
||||
.withRetryListener(defaultRetryListener(name));
|
||||
}
|
||||
|
||||
|
||||
public static <T> Retryer<JsonResponse<T>> getDefaultRetryer(String name) {
|
||||
return RetryUtil.<T>getDefaultRetryerBuilder(name).build();
|
||||
.withRetryListener(defaultRetryListener(name))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static RetryerBuilder<JsonResponse<?>> getDefaultGenericRetryerBuilder(String name, int retryTime, long retryInterval, TimeUnit retryTimeUnit,RetryListener retryListener) {
|
||||
|
Loading…
Reference in New Issue
Block a user