|
@@ -40,10 +40,7 @@ import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.DateTimeParseException;
|
|
import java.time.format.DateTimeParseException;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
|
|
-import java.util.concurrent.CompletionException;
|
|
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -189,7 +186,7 @@ public class StateEstimationServiceImpl implements StateEstimationService {
|
|
|
List<String> pointTime = Lists.newArrayList();
|
|
List<String> pointTime = Lists.newArrayList();
|
|
|
for (CompletableFuture<StateEstimation> f : futures) {
|
|
for (CompletableFuture<StateEstimation> f : futures) {
|
|
|
// 任一批失败 -> 抛 CompletionException -> 整体失败
|
|
// 任一批失败 -> 抛 CompletionException -> 整体失败
|
|
|
- StateEstimation part = f.join();
|
|
|
|
|
|
|
+ StateEstimation part = f.get(15,TimeUnit.SECONDS);
|
|
|
if (pointTime.isEmpty()) {
|
|
if (pointTime.isEmpty()) {
|
|
|
pointTime = part.getPointTime();
|
|
pointTime = part.getPointTime();
|
|
|
}
|
|
}
|
|
@@ -200,11 +197,12 @@ public class StateEstimationServiceImpl implements StateEstimationService {
|
|
|
return mergedList;
|
|
return mergedList;
|
|
|
} catch (CompletionException e) {
|
|
} catch (CompletionException e) {
|
|
|
// 取消尚未完成的批次, 减少无效远程调用
|
|
// 取消尚未完成的批次, 减少无效远程调用
|
|
|
- for (CompletableFuture<?> f : futures) {
|
|
|
|
|
- f.cancel(true);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ futures.forEach(f -> f.cancel(true));
|
|
|
log.error("[SE] 查询状估失败: {}", e.getMessage(), e);
|
|
log.error("[SE] 查询状估失败: {}", e.getMessage(), e);
|
|
|
ExceptionCast.cast("调用状估接口失败");
|
|
ExceptionCast.cast("调用状估接口失败");
|
|
|
|
|
+ } catch (ExecutionException | InterruptedException | TimeoutException e) {
|
|
|
|
|
+ futures.forEach(f -> f.cancel(true));
|
|
|
|
|
+ ExceptionCast.cast("调用状估接口失败");
|
|
|
}
|
|
}
|
|
|
return mergedList;
|
|
return mergedList;
|
|
|
}
|
|
}
|