Skip to content

Commit 17b62f7

Browse files
committed
Move the IExecutorProperties class to the common module.
1 parent c0b1bb6 commit 17b62f7

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package cn.hippo4j.config.springboot.starter.config;
18+
package cn.hippo4j.common.api;
1919

2020
import lombok.AllArgsConstructor;
2121
import lombok.Data;
@@ -27,7 +27,7 @@
2727
@Data
2828
@NoArgsConstructor
2929
@AllArgsConstructor
30-
public class DynamicThreadPoolNotifyProperties {
30+
public class ExecutorNotifyProperties {
3131

3232
/**
3333
* Thread pool run alarm interval. unit: s
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package cn.hippo4j.config.springboot.starter.config;
18+
package cn.hippo4j.common.api;
1919

2020
/**
2121
* Interface for thread pool configuration.
@@ -45,5 +45,5 @@ public interface IExecutorProperties {
4545
/**
4646
* Notify configs
4747
*/
48-
DynamicThreadPoolNotifyProperties getNotify();
48+
ExecutorNotifyProperties getNotify();
4949
}

hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/ExecutorProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package cn.hippo4j.config.springboot.starter.config;
1919

20+
import cn.hippo4j.common.api.ExecutorNotifyProperties;
21+
import cn.hippo4j.common.api.IExecutorProperties;
2022
import lombok.AllArgsConstructor;
2123
import lombok.Builder;
2224
import lombok.Data;
@@ -101,7 +103,7 @@ public class ExecutorProperties implements IExecutorProperties {
101103
/**
102104
* Notify
103105
*/
104-
private DynamicThreadPoolNotifyProperties notify;
106+
private ExecutorNotifyProperties notify;
105107

106108
/**
107109
* Nodes, application startup is not affect, change properties is effect

hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/config/WebExecutorProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package cn.hippo4j.config.springboot.starter.config;
1919

20+
import cn.hippo4j.common.api.ExecutorNotifyProperties;
21+
import cn.hippo4j.common.api.IExecutorProperties;
2022
import lombok.Data;
2123

2224
/**
@@ -58,5 +60,5 @@ public class WebExecutorProperties implements IExecutorProperties {
5860
/**
5961
* Notify config
6062
*/
61-
private DynamicThreadPoolNotifyProperties notify;
63+
private ExecutorNotifyProperties notify;
6264
}

hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/notify/ConfigModeNotifyConfigBuilder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
package cn.hippo4j.config.springboot.starter.notify;
1919

2020
import cn.hippo4j.adapter.web.WebThreadPoolService;
21+
import cn.hippo4j.common.api.ExecutorNotifyProperties;
22+
import cn.hippo4j.common.api.IExecutorProperties;
2123
import cn.hippo4j.common.toolkit.CollectionUtil;
2224
import cn.hippo4j.common.toolkit.StringUtil;
2325
import cn.hippo4j.config.springboot.starter.config.*;
@@ -128,19 +130,19 @@ public void initCacheAndLock(Map<String, List<NotifyConfigDTO>> buildSingleNotif
128130

129131
private int buildInterval(IExecutorProperties executorProperties) {
130132
return Optional.ofNullable(executorProperties.getNotify())
131-
.map(DynamicThreadPoolNotifyProperties::getInterval)
133+
.map(ExecutorNotifyProperties::getInterval)
132134
.orElse(Optional.ofNullable(configProperties.getDefaultExecutor())
133135
.map(ExecutorProperties::getNotify)
134-
.map(DynamicThreadPoolNotifyProperties::getInterval)
136+
.map(ExecutorNotifyProperties::getInterval)
135137
.orElse(5));
136138
}
137139

138140
private String buildReceive(IExecutorProperties executorProperties) {
139141
return Optional.ofNullable(executorProperties.getNotify())
140-
.map(DynamicThreadPoolNotifyProperties::getReceives)
142+
.map(ExecutorNotifyProperties::getReceives)
141143
.orElse(Optional.ofNullable(configProperties.getDefaultExecutor())
142144
.map(ExecutorProperties::getNotify)
143-
.map(DynamicThreadPoolNotifyProperties::getReceives).orElse(""));
145+
.map(ExecutorNotifyProperties::getReceives).orElse(""));
144146
}
145147

146148
private String getToken(NotifyPlatformProperties platformProperties) {

hippo4j-spring-boot/hippo4j-config-spring-boot-starter/src/main/java/cn/hippo4j/config/springboot/starter/support/DynamicThreadPoolPostProcessor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import cn.hippo4j.common.toolkit.ReflectUtil;
2424
import cn.hippo4j.common.toolkit.StringUtil;
2525
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;
26-
import cn.hippo4j.config.springboot.starter.config.DynamicThreadPoolNotifyProperties;
26+
import cn.hippo4j.common.api.ExecutorNotifyProperties;
2727
import cn.hippo4j.config.springboot.starter.config.ExecutorProperties;
2828
import cn.hippo4j.core.executor.DynamicThreadPool;
2929
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
@@ -229,19 +229,19 @@ private ExecutorProperties buildExecutorProperties(ExecutorProperties executorPr
229229
* @return thread-pool notify alarm
230230
*/
231231
private ThreadPoolNotifyAlarm buildThreadPoolNotifyAlarm(ExecutorProperties executorProperties) {
232-
DynamicThreadPoolNotifyProperties notify = Optional.ofNullable(executorProperties).map(ExecutorProperties::getNotify).orElse(null);
232+
ExecutorNotifyProperties notify = Optional.ofNullable(executorProperties).map(ExecutorProperties::getNotify).orElse(null);
233233
boolean isAlarm = Optional.ofNullable(executorProperties.getAlarm())
234234
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getAlarm).orElse(true));
235235
int activeAlarm = Optional.ofNullable(executorProperties.getActiveAlarm())
236236
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getActiveAlarm).orElse(80));
237237
int capacityAlarm = Optional.ofNullable(executorProperties.getCapacityAlarm())
238238
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getCapacityAlarm).orElse(80));
239239
int interval = Optional.ofNullable(notify)
240-
.map(DynamicThreadPoolNotifyProperties::getInterval)
241-
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getNotify).map(DynamicThreadPoolNotifyProperties::getInterval).orElse(5));
240+
.map(ExecutorNotifyProperties::getInterval)
241+
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getNotify).map(ExecutorNotifyProperties::getInterval).orElse(5));
242242
String receive = Optional.ofNullable(notify)
243-
.map(DynamicThreadPoolNotifyProperties::getReceives)
244-
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getNotify).map(DynamicThreadPoolNotifyProperties::getReceives).orElse(""));
243+
.map(ExecutorNotifyProperties::getReceives)
244+
.orElseGet(() -> Optional.ofNullable(configProperties.getDefaultExecutor()).map(ExecutorProperties::getNotify).map(ExecutorNotifyProperties::getReceives).orElse(""));
245245
ThreadPoolNotifyAlarm threadPoolNotifyAlarm = new ThreadPoolNotifyAlarm(isAlarm, activeAlarm, capacityAlarm);
246246
threadPoolNotifyAlarm.setInterval(interval);
247247
threadPoolNotifyAlarm.setReceives(receive);

0 commit comments

Comments
 (0)