Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dromara/dynamic-tp
Browse files Browse the repository at this point in the history
  • Loading branch information
yanhom1314 committed Jan 24, 2024
2 parents 19feee1 + 9669ec6 commit 7ac3a74
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.0.0
**/
@Getter
@AllArgsConstructor
public enum ConfigFileTypeEnum {

/**
Expand All @@ -40,10 +42,6 @@ public enum ConfigFileTypeEnum {

private final String value;

ConfigFileTypeEnum(String value) {
this.value = value;
}

public static ConfigFileTypeEnum of(String value) {
for (ConfigFileTypeEnum typeEnum : ConfigFileTypeEnum.values()) {
if (typeEnum.value.equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.0.0
**/
@Getter
@AllArgsConstructor
public enum NotifyItemEnum {

/**
Expand Down Expand Up @@ -63,11 +65,6 @@ public enum NotifyItemEnum {

private final String unit;

NotifyItemEnum(String value, String unit) {
this.value = value;
this.unit = unit;
}

public static NotifyItemEnum of(String value) {
for (NotifyItemEnum notifyItem : NotifyItemEnum.values()) {
if (notifyItem.value.equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import org.dromara.dynamictp.common.ex.DtpException;
import org.dromara.dynamictp.common.queue.MemorySafeLinkedBlockingQueue;
import org.dromara.dynamictp.common.queue.VariableLinkedBlockingQueue;
Expand All @@ -43,6 +44,7 @@
**/
@Slf4j
@Getter
@AllArgsConstructor
public enum QueueTypeEnum {

/**
Expand All @@ -66,13 +68,9 @@ public enum QueueTypeEnum {

MEMORY_SAFE_LINKED_BLOCKING_QUEUE(9, "MemorySafeLinkedBlockingQueue");

private final Integer code;
private final String name;
private final int code;

QueueTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
private final String name;

public static BlockingQueue<Runnable> buildLbq(String name, int capacity) {
return buildLbq(name, capacity, false, 256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.common.em;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -28,6 +29,7 @@
**/
@Slf4j
@Getter
@AllArgsConstructor
public enum RejectedTypeEnum {

/**
Expand All @@ -43,7 +45,4 @@ public enum RejectedTypeEnum {

private final String name;

RejectedTypeEnum(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@

package org.dromara.dynamictp.core.aware;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
* AwareType Enum
*
* @author kyao
* @since 1.1.4
*/
@Getter
@AllArgsConstructor
public enum AwareTypeEnum {

/**
Expand All @@ -44,16 +49,4 @@ public enum AwareTypeEnum {

private final String name;

AwareTypeEnum(int order, String name) {
this.order = order;
this.name = name;
}

public int getOrder() {
return order;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.core.executor;

import lombok.AllArgsConstructor;
import org.dromara.dynamictp.core.executor.eager.EagerDtpExecutor;
import lombok.Getter;
import org.dromara.dynamictp.core.executor.priority.PriorityDtpExecutor;
Expand All @@ -28,6 +29,7 @@
* @since 1.0.4
**/
@Getter
@AllArgsConstructor
public enum ExecutorType {

/**
Expand Down Expand Up @@ -59,11 +61,6 @@ public enum ExecutorType {

private final Class<?> clazz;

ExecutorType(String name, Class<?> clazz) {
this.name = name;
this.clazz = clazz;
}

public static Class<?> getClass(String name) {
for (ExecutorType type : ExecutorType.values()) {
if (type.name.equals(name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import static org.dromara.dynamictp.common.constant.DynamicTpConst.SCHEDULE_NOTIFY_ITEMS;
Expand All @@ -51,13 +52,26 @@ public class DtpMonitor extends OnceApplicationContextEventListener {

private final DtpProperties dtpProperties;

private ScheduledFuture<?> monitorFuture;

private int monitorInterval;

public DtpMonitor(DtpProperties dtpProperties) {
this.dtpProperties = dtpProperties;
}

@Override
protected void onContextRefreshedEvent(ContextRefreshedEvent event) {
MONITOR_EXECUTOR.scheduleWithFixedDelay(this::run,
protected synchronized void onContextRefreshedEvent(ContextRefreshedEvent event) {
// if monitorInterval is same as before, do nothing.
if (monitorInterval == dtpProperties.getMonitorInterval()) {
return;
}
// cancel old monitor task.
if (monitorFuture != null) {
monitorFuture.cancel(true);
}
monitorInterval = dtpProperties.getMonitorInterval();
monitorFuture = MONITOR_EXECUTOR.scheduleWithFixedDelay(this::run,
0, dtpProperties.getMonitorInterval(), TimeUnit.SECONDS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.extension.limiter.redis.em;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.0.8
**/
@Getter
@AllArgsConstructor
public enum RateLimitEnum {

/**
Expand All @@ -37,16 +39,4 @@ public enum RateLimitEnum {

private final String scriptName;

RateLimitEnum(final String keyName, final String scriptName) {
this.keyName = keyName;
this.scriptName = scriptName;
}

public String getKeyName() {
return this.keyName;
}

public String getScriptName() {
return this.scriptName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.dromara.dynamictp.starter.adapter.webserver.undertow;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
Expand All @@ -26,6 +27,7 @@
* @since 1.1.3
*/
@Getter
@AllArgsConstructor
public enum UndertowTaskPoolEnum {

/**
Expand All @@ -46,14 +48,10 @@ public enum UndertowTaskPoolEnum {
/**
* ExecutorServiceTaskPool
*/
EXECUTOR_SERVICE_TASK_POOL("ExecutorServiceTaskPool", "delegate"),;
EXECUTOR_SERVICE_TASK_POOL("ExecutorServiceTaskPool", "delegate");

private final String className;

private final String internalExecutor;

UndertowTaskPoolEnum(String className, String internalExecutor) {
this.className = className;
this.internalExecutor = internalExecutor;
}
}

0 comments on commit 7ac3a74

Please sign in to comment.