|
|
@@ -310,24 +310,23 @@ public class ComputerUtil {
|
|
|
/**
|
|
|
* 循环检测算法是否计算成功
|
|
|
* @param uploadJsonPath uploadjson路径
|
|
|
- * @param maxCheckTimes 循环次数
|
|
|
+ * @param maxCheckTimes 最大检查次数
|
|
|
* @param waitTime 每次检测间隔时间,毫秒
|
|
|
- * @return boolean
|
|
|
- * @throws Exception
|
|
|
+ * @return 文件是否存在
|
|
|
+ * @throws InterruptedException
|
|
|
*/
|
|
|
- public static boolean checkComputeCompleted(String uploadJsonPath, int maxCheckTimes, long waitTime) throws Exception{
|
|
|
- int checkTimes = 1;
|
|
|
- boolean exist = false;
|
|
|
- do {
|
|
|
- if(new File(uploadJsonPath).exists()){
|
|
|
- exist = true;
|
|
|
- break;
|
|
|
+ public static boolean checkComputeCompleted(String uploadJsonPath, int maxCheckTimes, long waitTime) throws InterruptedException {
|
|
|
+ File file = new File(uploadJsonPath);
|
|
|
+ for (int i = 0; i < maxCheckTimes; i++) {
|
|
|
+ if (file.exists()) {
|
|
|
+ return true;
|
|
|
}
|
|
|
- Thread.sleep(waitTime);
|
|
|
- ++checkTimes;
|
|
|
- }while (checkTimes <= maxCheckTimes);
|
|
|
-
|
|
|
- return exist;
|
|
|
+ if (i < maxCheckTimes - 1) {
|
|
|
+ Thread.sleep(waitTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.warn("检测超时,路径: {}, 检查次数: {}", uploadJsonPath, maxCheckTimes);
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|