Browse Source

/*ivs重试机制细节和日志调整*/

master
htjcAdmin 5 months ago
parent
commit
681760abce
2 changed files with 13 additions and 8 deletions
  1. +7
    -4
      inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java
  2. +6
    -4
      inspect-ivs/src/main/java/com/inspect/ivs/service/IvsResourceRetryableDelegate.java

+ 7
- 4
inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsDeviceController.java View File

@ -351,14 +351,17 @@ public class IvsDeviceController {
return ResponseEntity.ok().body(new InputStreamResource(ivsResourceRetryableDelegate.generateErrorImage()));
}
// 上面刚刚向摄像机发送了拍照指令, 需要给摄像机留出拍照时间
delayBeforeGetPicture();
IvsPlatformSnapshotView snapShotView;
try {
snapShotView = ivsResourceRetryableDelegate.getSnapshotListRetryable(
new IvsChanSnapVo(ivsDevChanSnapVo.getCameraCode(),
ivsDevChanSnapVo.getDomainCode(),
ivsSnapshotView.getTaskID()));
IvsChanSnapVo ivsChanSnapVo = new IvsChanSnapVo();
ivsChanSnapVo.setUUID(uuid);
ivsChanSnapVo.setCameraCode(ivsDevChanSnapVo.getCameraCode());
ivsChanSnapVo.setDomainCode(ivsDevChanSnapVo.getDomainCode());
ivsChanSnapVo.setTaskID(ivsSnapshotView.getTaskID());
snapShotView = ivsResourceRetryableDelegate.getSnapshotListRetryable(ivsChanSnapVo);
} catch (IOException e) {
log.info("snapShotView {}", e.getMessage() + " final fail");
return ResponseEntity.ok().body(new InputStreamResource(ivsResourceRetryableDelegate.generateErrorImage()));


+ 6
- 4
inspect-ivs/src/main/java/com/inspect/ivs/service/IvsResourceRetryableDelegate.java View File

@ -35,7 +35,9 @@ import java.util.UUID;
public class IvsResourceRetryableDelegate {
private static final Logger log = LoggerFactory.getLogger(IvsResourceRetryableDelegate.class);
private static final int RETRYABLE_MAX = 10;
private static final int RETRYABLE_MIN = 10;
private static final int RETRYABLE_MAX = 20;
@Resource
private IvsCommonService ivsCommonService;
@ -55,7 +57,7 @@ public class IvsResourceRetryableDelegate {
log.info("URI_PLATFORM_SNAPSHOT SUCCESS retryCount: {}, UUID: {}", retryCount, ivsDevChanSnapVo.getUUID());
} catch (Exception e) {
log.info("URI_PLATFORM_SNAPSHOT FAIL retryCount: {}, UUID: {}", retryCount, ivsDevChanSnapVo.getUUID());
throw new IOException("URI_PLATFORM_SNAPSHOT FAIL UUID: " + ivsDevChanSnapVo.getUUID());
throw new IOException("URI_PLATFORM_SNAPSHOT FAIL UUID: " + ivsDevChanSnapVo.getUUID() + ", retryCount: " + retryCount);
}
return ivsSnapshotView;
@ -70,7 +72,7 @@ public class IvsResourceRetryableDelegate {
@Retryable(
value = IOException.class,
maxAttempts = RETRYABLE_MAX,
maxAttempts = RETRYABLE_MIN,
backoff = @Backoff(delay = 2000)) // 每次重试间隔 2
public IvsPlatformSnapshotView getSnapshotListRetryable(final IvsChanSnapVo ivsChanSnapVo) throws IOException {
int retryCount = RetrySynchronizationManager.getContext() != null
@ -98,7 +100,7 @@ public class IvsResourceRetryableDelegate {
@Retryable(
value = IOException.class,
maxAttempts = RETRYABLE_MAX,
maxAttempts = RETRYABLE_MIN,
backoff = @Backoff(delay = 2000)) // 每次重试间隔 2
public ResponseEntity<InputStreamResource> downloadPictureRetryable(String uuid, String pictureUrl) throws IOException {
int retryCount = RetrySynchronizationManager.getContext() != null


Loading…
Cancel
Save