From 5d4885ae9545b093a8a999998003aae0f879701c Mon Sep 17 00:00:00 2001 From: "chen.ma" Date: Sat, 20 Nov 2021 12:50:40 +0800 Subject: [PATCH] =?UTF-8?q?SynchronousQueue=E3=80=81LinkedTransferQueue=20?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=98=9F=E5=88=97=E5=A4=A7=E5=B0=8F=200.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/biz/impl/ConfigServiceImpl.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 5b4b3f9e..4f05f7dc 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,10 +17,15 @@ 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.concurrent.LinkedTransferQueue; +import java.util.concurrent.SynchronousQueue; + /** * Config service impl. * @@ -100,6 +105,7 @@ 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)); @@ -111,4 +117,17 @@ public class ConfigServiceImpl implements ConfigService { } } + /** + * 根据队列类型获取队列大小. + *

+ * 不支持设置队列大小 {@link SynchronousQueue} {@link LinkedTransferQueue} + * + * @param config + * @return + */ + private Integer getQueueCapacityByType(ConfigAllInfo config) { + List noCapacityBlockingQueues = Lists.newArrayList(4, 5); + return noCapacityBlockingQueues.contains(config.getQueueType()) ? 0 : config.getCapacity(); + } + }