From f4dc54529b1a84e7f9ffbd673b308e6ba5df142d Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Sat, 27 Nov 2021 23:01:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E9=98=9F=E5=88=97=E9=85=8D=E7=BD=AE=E5=8F=98=E6=9B=B4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/biz/impl/ConfigServiceImpl.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java index 4f05f7dc..20d9f9cd 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/ConfigServiceImpl.java @@ -17,14 +17,16 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; -import com.google.common.collect.Lists; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Objects; import java.util.concurrent.LinkedTransferQueue; import java.util.concurrent.SynchronousQueue; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Config service impl. @@ -60,6 +62,7 @@ public class ConfigServiceImpl implements ConfigService { String userName = UserContext.getUserName(); ConfigServiceImpl configService = ApplicationContextHolder.getBean(this.getClass()); + configInfo.setCapacity(getQueueCapacityByType(configInfo)); try { ConditionUtil @@ -105,7 +108,6 @@ public class ConfigServiceImpl implements ConfigService { .eq(ConfigAllInfo::getTenantId, config.getTenantId()); config.setGmtCreate(null); - config.setCapacity(getQueueCapacityByType(config)); config.setContent(ContentUtil.getPoolContent(config)); config.setMd5(Md5Util.getTpContentMd5(config)); @@ -126,8 +128,20 @@ public class ConfigServiceImpl implements ConfigService { * @return */ private Integer getQueueCapacityByType(ConfigAllInfo config) { - List noCapacityBlockingQueues = Lists.newArrayList(4, 5); - return noCapacityBlockingQueues.contains(config.getQueueType()) ? 0 : config.getCapacity(); + int queueCapacity = 0; + switch (config.getQueueType()) { + case 5: + queueCapacity = Integer.MAX_VALUE; + break; + } + + List queueTypes = Stream.of(1, 2, 3, 6, 9).collect(Collectors.toList()); + boolean setDefaultFlag = queueTypes.contains(config.getQueueType()) && (config.getCapacity() == null || Objects.equals(config.getCapacity(), 0)); + if (setDefaultFlag) { + queueCapacity = 1024; + } + + return queueCapacity; } }