From 8aab51ba5d5f2a543b14d980c5a8bf6be8c4e1b5 Mon Sep 17 00:00:00 2001 From: bryan31 Date: Thu, 18 Mar 2021 17:54:18 +0800 Subject: [PATCH] =?UTF-8?q?enhancement=20#I2NXDL=20slot=20=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E5=BA=A6=E6=8E=A7=E5=88=B6=E6=95=B0=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BA=A4=E7=94=B1=E4=B8=9A=E5=8A=A1=E7=B3=BB=E7=BB=9F=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yomahub/liteflow/entity/data/DataBus.java | 10 +++++++++- .../liteflow/springboot/LiteflowAutoConfiguration.java | 8 ++++++++ .../liteflow/springboot/LiteflowMonitorProperty.java | 8 ++++---- .../yomahub/liteflow/springboot/LiteflowProperty.java | 10 ++++++++++ .../resources/META-INF/liteflow-default.properties | 6 ++++++ .../src/main/resources/application.properties | 4 +--- 6 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/entity/data/DataBus.java b/liteflow-core/src/main/java/com/yomahub/liteflow/entity/data/DataBus.java index fbe7820b0..22ae8b6b6 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/entity/data/DataBus.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/entity/data/DataBus.java @@ -16,7 +16,7 @@ public class DataBus { private static final Logger LOG = LoggerFactory.getLogger(DataBus.class); - public static final int SLOT_SIZE = 1024; + public static int SLOT_SIZE = 1024; public static AtomicInteger OCCUPY_COUNT = new AtomicInteger(0); @@ -52,4 +52,12 @@ public class DataBus { LOG.warn("slot[{}] already has been released",slotIndex); } } + + public static int getSlotSize() { + return SLOT_SIZE; + } + + public static void setSlotSize(int slotSize) { + SLOT_SIZE = slotSize; + } } diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowAutoConfiguration.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowAutoConfiguration.java index 6342c389c..91aad0888 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowAutoConfiguration.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowAutoConfiguration.java @@ -2,6 +2,7 @@ package com.yomahub.liteflow.springboot; import com.google.common.collect.Lists; import com.yomahub.liteflow.core.FlowExecutor; +import com.yomahub.liteflow.entity.data.DataBus; import com.yomahub.liteflow.monitor.MonitorBus; import com.yomahub.liteflow.spring.ComponentScaner; import com.yomahub.liteflow.util.SpringAware; @@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import javax.swing.*; import java.util.List; @@ -17,6 +19,9 @@ import java.util.List; @Configuration @EnableConfigurationProperties({LiteflowProperty.class,LiteflowMonitorProperty.class}) @ConditionalOnProperty(prefix = "liteflow", name = "rule-source") +@PropertySource( + name = "liteflow Default Properties", + value = "classpath:/META-INF/liteflow-default.properties") public class LiteflowAutoConfiguration { @Bean @@ -30,6 +35,9 @@ public class LiteflowAutoConfiguration { List ruleList = Lists.newArrayList(property.getRuleSource().split(",")); FlowExecutor flowExecutor = new FlowExecutor(); flowExecutor.setRulePath(ruleList); + + DataBus.setSlotSize(property.getSlotSize()); + return flowExecutor; }else{ return null; diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowMonitorProperty.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowMonitorProperty.java index 282e34ec2..6f4d6f332 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowMonitorProperty.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowMonitorProperty.java @@ -5,13 +5,13 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "liteflow.monitor", ignoreUnknownFields = true) public class LiteflowMonitorProperty { - private boolean enableLog = false; + private boolean enableLog; - private int queueLimit = 200; + private int queueLimit; - private long delay = 5*60*1000; + private long delay; - private long period = 5*60*1000; + private long period; public boolean isEnableLog() { return enableLog; diff --git a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java index 993e70d2b..6668bac56 100644 --- a/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java +++ b/liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java @@ -7,6 +7,8 @@ public class LiteflowProperty { private String ruleSource; + private int slotSize; + public String getRuleSource() { return ruleSource; } @@ -14,4 +16,12 @@ public class LiteflowProperty { public void setRuleSource(String ruleSource) { this.ruleSource = ruleSource; } + + public int getSlotSize() { + return slotSize; + } + + public void setSlotSize(int slotSize) { + this.slotSize = slotSize; + } } diff --git a/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties new file mode 100644 index 000000000..befda9228 --- /dev/null +++ b/liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties @@ -0,0 +1,6 @@ +liteflow.ruleSource=config/flow.xml +liteflow.slot-size=1024 +liteflow.monitor.enable-log=false +liteflow.monitor.queue-limit=200 +liteflow.monitor.delay=300000 +liteflow.monitor.period=300000 \ No newline at end of file diff --git a/liteflow-test-springboot/src/main/resources/application.properties b/liteflow-test-springboot/src/main/resources/application.properties index 5853767d1..14993d036 100644 --- a/liteflow-test-springboot/src/main/resources/application.properties +++ b/liteflow-test-springboot/src/main/resources/application.properties @@ -1,4 +1,2 @@ liteflow.ruleSource=config/flow.xml -liteflow.monitor.enable-log=true -liteflow.monitor.delay=0 -liteflow.monitor.period=60000 \ No newline at end of file +liteflow.slot-size=2048 \ No newline at end of file