|
@@ -22,6 +22,8 @@ import cn.com.qmth.examcloud.support.enums.ExamProperties;
|
|
|
import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
import cn.com.qmth.examcloud.support.filestorage.FileStorageUtil;
|
|
|
import cn.com.qmth.examcloud.support.helper.ExamCacheTransferHelper;
|
|
|
+import cn.com.qmth.examcloud.web.exception.SequenceLockException;
|
|
|
+import cn.com.qmth.examcloud.web.helpers.SequenceLockHelper;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -53,8 +55,8 @@ public class FaceVerifyJobHandler {
|
|
|
private ExamRecordDataService examRecordDataService;
|
|
|
|
|
|
public void run(int shardTotal, int shardIndex, String jobParam) throws Exception {
|
|
|
- int batchSize = 1000;
|
|
|
- List<Long> todoExamRecordDataIds = examCaptureQueueRepo.findQueuesGroupByExamRecordDataId(shardTotal, shardIndex, batchSize);
|
|
|
+ int batchSize = 100, maxErrorNum = 100;
|
|
|
+ List<Long> todoExamRecordDataIds = examCaptureQueueRepo.findQueuesGroupByExamRecordDataId(shardTotal, shardIndex, batchSize, maxErrorNum);
|
|
|
|
|
|
log.warn("shardTotal:{}, shardIndex:{}, todoExamRecordDataIdsSize:{}", shardTotal, shardIndex, todoExamRecordDataIds.size());
|
|
|
if (CollectionUtils.isEmpty(todoExamRecordDataIds)) {
|
|
@@ -62,7 +64,10 @@ public class FaceVerifyJobHandler {
|
|
|
}
|
|
|
|
|
|
for (Long examRecordDataId : todoExamRecordDataIds) {
|
|
|
+ final String lockKey = Constants.FACE_COMPARE_LOCK_PREFIX + examRecordDataId;
|
|
|
try {
|
|
|
+ SequenceLockHelper.getLockSimple(lockKey);
|
|
|
+
|
|
|
// 处理业务
|
|
|
this.handler(examRecordDataId);
|
|
|
} catch (Exception e) {
|
|
@@ -70,10 +75,15 @@ public class FaceVerifyJobHandler {
|
|
|
// 若线程终止,则抛出交由任务调度中心处理
|
|
|
log.warn("当前任务线程被终止!examRecordDataId:{}, error:{}", examRecordDataId, e.getMessage());
|
|
|
throw e;
|
|
|
+ } else if (e instanceof SequenceLockException) {
|
|
|
+ // 若锁问题,下次会继续执行
|
|
|
+ log.warn("当前考试记录数据获取锁失败!examRecordDataId:{}, redisKey:{}", examRecordDataId, lockKey);
|
|
|
} else {
|
|
|
// 若异常,下次会继续执行(需要排查原因)
|
|
|
log.error("当前考试记录数据处理失败!examRecordDataId:{}, error:{}", examRecordDataId, e.getMessage(), e);
|
|
|
}
|
|
|
+ } finally {
|
|
|
+ SequenceLockHelper.releaseLockSimple(lockKey);
|
|
|
}
|
|
|
}
|
|
|
}
|