fuliqi
2025-02-14 c6976365d5bfb39a32db8b541b1fe3ceb30c7826
ycl-server/src/main/java/com/ycl/task/PlatformTask.java
@@ -44,11 +44,11 @@
    private static final String DICT_TYPE = "platform_online";
    private static final ExecutorService executorService = new ThreadPoolExecutor(8,
            24,
    private static final ExecutorService executorService = new ThreadPoolExecutor(16,
            64,
            5000,
            TimeUnit.SECONDS,
            new ArrayBlockingQueue<>(10),
            new ArrayBlockingQueue<>(1000),
            new ThreadPoolExecutor.CallerRunsPolicy()
    );
@@ -68,20 +68,19 @@
                    for (int tryTimes = 1; tryTimes < 3; tryTimes++) {
                        // 三秒未ping通重试一次,如果不行才扣分
                        reachable = InetAddress.getByName(platform.getPlatformIP()).isReachable(3000);
                        if (! reachable && tryTimes == 0) {
                            continue;
                        }
                        if (! reachable) {
                            // 如果ping不通,离线时长加5秒
                            redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + platform.getPlatformIP(), 5);
                            log.warn(platform.getPlatformName() + "平台未ping通");
                        if (reachable) {
                            break;
                        }
                    }
                    if (!reachable) {
                        // 如果ping不通,离线时长加5秒
                        redisTemplate.opsForValue().increment(REDIS_KEY_PREFIX + platform.getPlatformIP(), 5);
                        log.warn(platform.getPlatformName() + "平台未ping通");
                    }
                } catch (Exception e) {
                    log.error("检查平台连通性时发生错误", e);
                    log.error("检查平台连通性时发生d错误", e);
                }
            });
            executorService.shutdown();
        }
    }