diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java index 5a21ca6f..8656c5ce 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/core/ClientWorker.java @@ -30,7 +30,6 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.DisposableBean; import org.springframework.util.StringUtils; - import java.net.URLDecoder; import java.util.ArrayList; import java.util.Collections; @@ -43,8 +42,21 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; - -import static cn.hippo4j.common.constant.Constants.*; +import static cn.hippo4j.common.constant.Constants.CONFIG_LONG_POLL_TIMEOUT; +import static cn.hippo4j.common.constant.Constants.GROUP_KEY_DELIMITER_TRANSLATION; +import static cn.hippo4j.common.constant.Constants.WORD_SEPARATOR; +import static cn.hippo4j.common.constant.Constants.LINE_SEPARATOR; +import static cn.hippo4j.common.constant.Constants.PROBE_MODIFY_REQUEST; +import static cn.hippo4j.common.constant.Constants.WEIGHT_CONFIGS; +import static cn.hippo4j.common.constant.Constants.LONG_PULLING_TIMEOUT; +import static cn.hippo4j.common.constant.Constants.LONG_PULLING_CLIENT_IDENTIFICATION; +import static cn.hippo4j.common.constant.Constants.LONG_PULLING_TIMEOUT_NO_HANGUP; +import static cn.hippo4j.common.constant.Constants.CLIENT_VERSION; +import static cn.hippo4j.common.constant.Constants.LISTENER_PATH; +import static cn.hippo4j.common.constant.Constants.INITIAL_CAPACITY; +import static cn.hippo4j.common.constant.Constants.DATA_GROUP_TENANT_SIZE; +import static cn.hippo4j.common.constant.Constants.CONFIG_CONTROLLER_PATH; +import static cn.hippo4j.common.constant.Constants.NULL; /** * Client worker. @@ -65,6 +77,8 @@ public class ClientWorker implements DisposableBean { private final CountDownLatch cacheCondition = new CountDownLatch(1); private final ConcurrentHashMap cacheMap = new ConcurrentHashMap<>(16); + private final long defaultTimedOut = 3000L; + @SuppressWarnings("all") public ClientWorker(HttpAgent httpAgent, String identify, @@ -138,7 +152,7 @@ public class ClientWorker implements DisposableBean { String itemId = keys[1]; String namespace = keys[2]; try { - String content = getServerConfig(namespace, itemId, tpId, HTTP_EXECUTE_TIMEOUT); + String content = getServerConfig(namespace, itemId, tpId, defaultTimedOut); CacheData cacheData = cacheMap.get(tpId); String poolContent = ContentUtil.getPoolContent(JSONUtil.parseObject(content, ThreadPoolParameterInfo.class)); cacheData.setContent(poolContent); @@ -265,7 +279,7 @@ public class ClientWorker implements DisposableBean { if (lastCacheData == null) { String serverConfig; try { - serverConfig = getServerConfig(namespace, itemId, threadPoolId, HTTP_EXECUTE_TIMEOUT); + serverConfig = getServerConfig(namespace, itemId, threadPoolId, defaultTimedOut); ThreadPoolParameterInfo poolInfo = JSONUtil.parseObject(serverConfig, ThreadPoolParameterInfo.class); cacheData.setContent(ContentUtil.getPoolContent(poolInfo)); } catch (Exception ex) { diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/AbstractHealthCheck.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/AbstractHealthCheck.java index fc2cb69c..246f80ad 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/AbstractHealthCheck.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/remote/AbstractHealthCheck.java @@ -31,8 +31,10 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; - -import static cn.hippo4j.common.constant.Constants.*; +import static cn.hippo4j.common.constant.Constants.MAX_CHECK_FAILURE_COUNT; +import static cn.hippo4j.common.constant.Constants.SECONDS_IN_MILLISECONDS; +import static cn.hippo4j.common.constant.Constants.HEALTH_CHECK_INTERVAL; +import static cn.hippo4j.common.constant.Constants.FAILURE_SLEEP_INTERVAL; /** * Abstract health check. diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java index 00a1dd67..c3bd82e1 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/DynamicThreadPoolPostProcessor.java @@ -53,8 +53,14 @@ import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; - -import static cn.hippo4j.common.constant.Constants.*; +import static cn.hippo4j.common.constant.Constants.INITIAL_CAPACITY; +import static cn.hippo4j.common.constant.Constants.TP_ID; +import static cn.hippo4j.common.constant.Constants.ITEM_ID; +import static cn.hippo4j.common.constant.Constants.NAMESPACE; +import static cn.hippo4j.common.constant.Constants.ACTIVE_ALARM; +import static cn.hippo4j.common.constant.Constants.CAPACITY_ALARM; +import static cn.hippo4j.common.constant.Constants.EXECUTE_TIME_OUT; +import static cn.hippo4j.common.constant.Constants.HTTP_EXECUTE_TIMEOUT; /** * Dynamic thread-pool post processor. @@ -127,7 +133,7 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor { protected ThreadPoolExecutor fillPoolAndRegister(DynamicThreadPoolWrapper dynamicThreadPoolWrapper) { String threadPoolId = dynamicThreadPoolWrapper.getThreadPoolId(); ThreadPoolExecutor executor = dynamicThreadPoolWrapper.getExecutor(); - Map queryStrMap = new HashMap(INITIAL_CAPACITY); + Map queryStrMap = new HashMap<>(INITIAL_CAPACITY); queryStrMap.put(TP_ID, threadPoolId); queryStrMap.put(ITEM_ID, properties.getItemId()); queryStrMap.put(NAMESPACE, properties.getNamespace());