Abstract infrastructure modules and refactor existing modules (#1305)

pull/1306/head
magestack 1 year ago committed by GitHub
parent 7cb3387822
commit 06c6c06768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,7 +19,6 @@ package cn.hippo4j.agent.core.registry;
import cn.hippo4j.agent.core.logging.api.ILog;
import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.common.config.ExecutorProperties;
import lombok.Data;
import java.util.Properties;

@ -19,7 +19,6 @@ package cn.hippo4j.agent.core.registry;
import cn.hippo4j.agent.core.logging.api.ILog;
import cn.hippo4j.agent.core.logging.api.LogManager;
import cn.hippo4j.common.config.ExecutorProperties;
import java.util.Map;
import java.util.Optional;

@ -24,8 +24,8 @@ import cn.hippo4j.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInt
import cn.hippo4j.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import cn.hippo4j.agent.plugin.spring.boot.v1.DynamicThreadPoolChangeHandlerSpring1x;
import cn.hippo4j.agent.plugin.spring.common.support.SpringPropertiesLoader;
import cn.hippo4j.agent.plugin.spring.common.support.IDynamicThreadPoolChangeHandlerSpring;
import cn.hippo4j.agent.plugin.spring.common.support.SpringThreadPoolRegisterSupport;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ConfigurableApplicationContext;
@ -54,9 +54,8 @@ public class EventPublishingFinishedInterceptor implements InstanceMethodsAround
return ret;
}
SpringPropertiesLoader.loadSpringProperties(context.getEnvironment());
IDynamicThreadPoolChangeHandlerSpring handlerSpring1x = new DynamicThreadPoolChangeHandlerSpring1x(context);
handlerSpring1x.registerApolloConfigHandler();
ThreadPoolDynamicRefresh dynamicRefreshSpring1x = new DynamicThreadPoolChangeHandlerSpring1x(context);
dynamicRefreshSpring1x.registerListener();
return ret;
}

@ -24,8 +24,8 @@ import cn.hippo4j.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInt
import cn.hippo4j.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import cn.hippo4j.agent.plugin.spring.boot.v2.DynamicThreadPoolChangeHandlerSpring2x;
import cn.hippo4j.agent.plugin.spring.common.support.SpringPropertiesLoader;
import cn.hippo4j.agent.plugin.spring.common.support.IDynamicThreadPoolChangeHandlerSpring;
import cn.hippo4j.agent.plugin.spring.common.support.SpringThreadPoolRegisterSupport;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import org.springframework.context.ConfigurableApplicationContext;
import java.lang.reflect.Method;
@ -51,8 +51,8 @@ public class EventPublishingStartedInterceptor implements InstanceMethodsAroundI
return ret;
}
SpringPropertiesLoader.loadSpringProperties(context.getEnvironment());
IDynamicThreadPoolChangeHandlerSpring handler = new DynamicThreadPoolChangeHandlerSpring2x(context);
handler.registerApolloConfigHandler();
ThreadPoolDynamicRefresh dynamicRefresh = new DynamicThreadPoolChangeHandlerSpring2x(context);
dynamicRefresh.registerListener();
return ret;
}

@ -41,6 +41,13 @@
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-dynamic-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

@ -21,7 +21,7 @@ import cn.hippo4j.agent.core.registry.AgentThreadPoolExecutorHolder;
import cn.hippo4j.agent.core.registry.AgentThreadPoolInstanceRegistry;
import cn.hippo4j.agent.core.util.ThreadPoolPropertyKey;
import cn.hippo4j.agent.plugin.spring.common.conf.SpringBootConfig;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue;
@ -32,6 +32,7 @@ import cn.hippo4j.config.springboot.starter.parser.ConfigFileTypeEnum;
import cn.hippo4j.config.springboot.starter.parser.ConfigParserHandler;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigFile;
import com.ctrip.framework.apollo.ConfigService;
@ -59,7 +60,7 @@ import static cn.hippo4j.common.constant.ChangeThreadPoolConstants.CHANGE_THREAD
/**
* Abstract dynamic thread poo change handler spring
*/
public abstract class AbstractDynamicThreadPoolChangeHandlerSpring implements IDynamicThreadPoolChangeHandlerSpring {
public abstract class AbstractDynamicThreadPoolChangeHandlerSpring implements ThreadPoolDynamicRefresh {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractDynamicThreadPoolChangeHandlerSpring.class);
@ -69,7 +70,7 @@ public abstract class AbstractDynamicThreadPoolChangeHandlerSpring implements ID
this.applicationContext = context;
}
public void registerApolloConfigHandler() {
public void registerListener() {
List<String> apolloNamespaces = SpringBootConfig.Spring.Dynamic.Thread_Pool.Apollo.NAMESPACE;
String namespace = apolloNamespaces.get(0);

@ -1,27 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.agent.plugin.spring.common.support;
/**
* IDynamic thread pool change handler spring
*/
public interface IDynamicThreadPoolChangeHandlerSpring {
void registerApolloConfigHandler();
}

@ -16,7 +16,6 @@ git add -A
git commit -m "auto commit"
# github
git branch -m master main
GIT_SSH_COMMAND="ssh -i ~/.ssh/hippo4j" git remote add origin git@github.com:hippo4j/hippo4j.github.io.git
GIT_SSH_COMMAND="ssh -i ~/.ssh/hippo4j" git push -u origin main -f

21313
docs/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -18,8 +18,8 @@
package cn.hippo4j.example.core;
import cn.hippo4j.core.executor.ExtensibleThreadPoolExecutor;
import cn.hippo4j.core.plugin.impl.TaskTimeRecordPlugin;
import cn.hippo4j.core.plugin.manager.DefaultThreadPoolPluginManager;
import cn.hippo4j.core.executor.plugin.impl.TaskTimeRecordPlugin;
import cn.hippo4j.core.executor.plugin.manager.DefaultThreadPoolPluginManager;
import lombok.SneakyThrows;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
@ -44,7 +44,7 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* benchmark test for {@link cn.hippo4j.core.plugin.impl.TaskTimeRecordPlugin}
* benchmark test for {@link TaskTimeRecordPlugin}
*/
@BenchmarkMode(Mode.All)
@OutputTimeUnit(TimeUnit.MILLISECONDS)

@ -17,7 +17,7 @@
package cn.hippo4j.common.api;
import cn.hippo4j.common.config.ExecutorNotifyProperties;
import cn.hippo4j.common.model.executor.ExecutorNotifyProperties;
/**
* Interface for thread pool configuration.

@ -15,7 +15,9 @@
* limitations under the License.
*/
package cn.hippo4j.common.design.builder;
package cn.hippo4j.common.executor;
import cn.hippo4j.common.extension.design.Builder;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

@ -173,7 +173,6 @@ public enum BlockingQueueTypeEnum {
*
* @param <T> the class of the objects in the BlockingQueue
* @return a BlockingQueue view of the specified T
* @throws NotSupportedException
*/
abstract <T> BlockingQueue<T> of();

@ -1,37 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.common.executor.support;
import cn.hippo4j.common.web.exception.AbstractException;
/**
* This exception is thrown when a context implementation does not support the operation being invoked.
*/
public class NotSupportedException extends AbstractException {
/**
* Constructs a new not supported exception with the specified detail message and
* cause.
*
* @param message the detail message (which is saved for later retrieval
* by the {@link #getMessage()} method).
*/
public NotSupportedException(String message) {
super(message, null, null);
}
}

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.design.observer;
package cn.hippo4j.common.extension.design;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.StringUtil;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.design.builder;
package cn.hippo4j.common.extension.design;
import java.io.Serializable;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.design.observer;
package cn.hippo4j.common.extension.design;
/**
* Observer.

@ -15,12 +15,17 @@
* limitations under the License.
*/
package cn.hippo4j.common.design.observer;
package cn.hippo4j.common.extension.design;
/**
* Message notifying observer.
*/
public interface ObserverMessage<T> {
/**
* Message method definition
*
* @return Different message formats
*/
T message();
}

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.enums;
package cn.hippo4j.common.extension.enums;
/**
* Del enum.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.enums;
package cn.hippo4j.common.extension.enums;
import java.util.Objects;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.enums;
package cn.hippo4j.common.extension.enums;
/**
* Enumeration of thread pool audit status.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.enums;
package cn.hippo4j.common.extension.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.function;
package cn.hippo4j.common.extension.function;
/**
* Matcher.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.function;
package cn.hippo4j.common.extension.function;
/**
* No args consumer.

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.web.base;
package cn.hippo4j.common.model;
import lombok.Data;
import lombok.experimental.Accessors;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.config;
package cn.hippo4j.common.model.executor;
import lombok.AllArgsConstructor;
import lombok.Data;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.config;
package cn.hippo4j.common.model.executor;
import cn.hippo4j.common.api.IExecutorProperties;
import lombok.AllArgsConstructor;

@ -30,17 +30,17 @@ import java.util.List;
public abstract class AbstractMessage<T extends Message> implements Message {
/**
* groupKey: tenant + item + tpId + identify
* GroupKey: tenant + item + threadPoolId + identify
*/
private String groupKey;
/**
* messageTypeEnum
* Message type enum
*/
private MessageTypeEnum messageType;
/**
* message
* Message
*/
private List<T> messages;
}

@ -17,7 +17,7 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.function.Matcher;
import cn.hippo4j.common.extension.function.Matcher;
import java.lang.reflect.Array;

@ -17,7 +17,6 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.web.exception.IllegalException;
import com.github.dozermapper.core.DozerBeanMapperBuilder;
import com.github.dozermapper.core.Mapper;
import lombok.AccessLevel;
@ -93,7 +92,7 @@ public class BeanUtil {
T newInstance = clazz.newInstance();
return mapToBean(map, newInstance, toCamelCase);
} catch (InstantiationException | IllegalAccessException e) {
throw new IllegalException("do not create instance for " + clazz.getName(), e);
throw new RuntimeException("do not create instance for " + clazz.getName(), e);
}
}
@ -139,7 +138,7 @@ public class BeanUtil {
PropertyDescriptor descriptor = new PropertyDescriptor(propertiesName, o);
return descriptor.getReadMethod();
} catch (IntrospectionException e) {
throw new IllegalException("not find getter for" + propertiesName + "in" + o.getName(), e);
throw new RuntimeException("not find getter for" + propertiesName + "in" + o.getName(), e);
}
}
@ -158,7 +157,7 @@ public class BeanUtil {
PropertyDescriptor descriptor = new PropertyDescriptor(propertiesName, o);
return descriptor.getWriteMethod();
} catch (IntrospectionException e) {
throw new IllegalException("not find setter for" + propertiesName + "in" + o.getName(), e);
throw new RuntimeException("not find setter for" + propertiesName + "in" + o.getName(), e);
}
}
}

@ -17,7 +17,7 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.function.NoArgsConsumer;
import cn.hippo4j.common.extension.function.NoArgsConsumer;
/**
* Condition util.

@ -17,7 +17,6 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.web.exception.IllegalException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@ -63,7 +62,7 @@ public class ReflectUtil {
result = field.get(obj);
} catch (IllegalAccessException e) {
String exceptionMsg = String.format("IllegalAccess for %s.%s", field.getDeclaringClass(), field.getName());
throw new IllegalException(exceptionMsg, e);
throw new RuntimeException(exceptionMsg, e);
}
return result;
}
@ -117,7 +116,7 @@ public class ReflectUtil {
return field.getName();
}
public static void setFieldValue(Object obj, String fieldName, Object value) throws IllegalException {
public static void setFieldValue(Object obj, String fieldName, Object value) throws RuntimeException {
Assert.notNull(obj);
Assert.notBlank(fieldName);
final Field field = getField((obj instanceof Class) ? (Class<?>) obj : obj.getClass(), fieldName);
@ -125,7 +124,7 @@ public class ReflectUtil {
setFieldValue(obj, field, value);
}
public static void setFieldValue(Object obj, Field field, Object value) throws IllegalException {
public static void setFieldValue(Object obj, Field field, Object value) throws RuntimeException {
Assert.notNull(field, "Field in [" + obj + "] not exist !");
final Class<?> fieldType = field.getType();
if (null != value) {
@ -142,7 +141,7 @@ public class ReflectUtil {
try {
field.set(obj instanceof Class ? null : obj, value);
} catch (IllegalAccessException e) {
throw new IllegalException("IllegalAccess for " + obj + "." + field.getName(), e);
throw new RuntimeException("IllegalAccess for " + obj + "." + field.getName(), e);
}
}
@ -183,7 +182,7 @@ public class ReflectUtil {
return clazz.getMethod(methodName, arguments);
}
} catch (NoSuchMethodException e) {
throw new IllegalException(e);
throw new RuntimeException(e);
}
return null;
}
@ -247,12 +246,12 @@ public class ReflectUtil {
try {
Method method = ReflectUtil.getMethodByName(obj.getClass(), methodName);
if (method == null) {
throw new IllegalException(methodName + "method not exists");
throw new RuntimeException(methodName + "method not exists");
}
ReflectUtil.setAccessible(method);
return (T) method.invoke(obj, arguments);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalException(e);
throw new RuntimeException(e);
}
}
@ -269,7 +268,7 @@ public class ReflectUtil {
try {
return (T) method.invoke(obj, arguments);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new IllegalException(e);
throw new RuntimeException(e);
}
}
@ -283,7 +282,7 @@ public class ReflectUtil {
try {
return cls.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new IllegalException(e);
throw new RuntimeException(e);
}
}

@ -26,7 +26,6 @@ import cn.hippo4j.common.toolkit.IoUtil;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.common.toolkit.logtracing.LogMessage;
import cn.hippo4j.common.web.exception.ServiceException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
@ -262,7 +261,7 @@ public class HttpUtil {
.kv("method", method)
.kv("json", json)
.kv2String("headers", JSONUtil.toJSONString(headers)));
throw new ServiceException("Invalid http json body, please check it again.");
throw new RuntimeException("Invalid http json body, please check it again.");
}
return execute(url, method, json, headers);
}
@ -319,7 +318,7 @@ public class HttpUtil {
JdkHttpClientResponse response = new JdkHttpClientResponse(connection);
if (!HttpResponseCode.isOk(response.getStatusCode())) {
String msg = String.format("HttpPost response code error. [code] %s [url] %s [body] %s", response.getStatusCode(), connection.getURL(), response.getBodyString());
throw new ServiceException(msg);
throw new RuntimeException(msg);
}
return response;
} catch (Throwable ex) {

@ -17,7 +17,6 @@
package cn.hippo4j.common.executor;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.toolkit.MapUtil;
import cn.hippo4j.common.toolkit.ReflectUtil;
import org.junit.Assert;

@ -17,6 +17,7 @@
package cn.hippo4j.common.function;
import cn.hippo4j.common.extension.function.Matcher;
import cn.hippo4j.common.toolkit.Assert;
import org.junit.Test;

@ -17,6 +17,7 @@
package cn.hippo4j.common.function;
import cn.hippo4j.common.extension.function.NoArgsConsumer;
import cn.hippo4j.common.toolkit.Assert;
import org.junit.jupiter.api.Test;

@ -17,7 +17,7 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.function.Matcher;
import cn.hippo4j.common.extension.function.Matcher;
import org.junit.Test;
import org.springframework.util.StringUtils;

@ -17,7 +17,7 @@
package cn.hippo4j.common.toolkit;
import cn.hippo4j.common.function.NoArgsConsumer;
import cn.hippo4j.common.extension.function.NoArgsConsumer;
import org.junit.Test;
import java.util.concurrent.atomic.AtomicBoolean;

@ -1,21 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.hippo4j.common.web;
public final class ResultsTest {
}

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-kernel-dynamic</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-threadpool-dynamic-api</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-infra-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.common.api;
package cn.hippo4j.threadpool.dynamic.api;
import java.util.Map;
@ -25,17 +25,24 @@ import java.util.Map;
public interface ThreadPoolDynamicRefresh {
/**
* Dynamic refresh.
* Register configuration center event listener.
*/
default void registerListener() {
}
/**
* Dynamic refresh of configuration center data changes.
*
* @param content
* @param content changed data
*/
void dynamicRefresh(String content);
default void dynamicRefresh(String content) {
}
/**
* Dynamic refresh.
*
* @param content
* @param newValueChangeMap
* @param content changed data
* @param newValueChangeMap new value change map
*/
default void dynamicRefresh(String content, Map<String, Object> newValueChangeMap) {
}

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-kernel-dynamic</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-threadpool-dynamic-core</artifactId>
</project>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-dynamic-mode</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-threadpool-dynamic-mode-config</artifactId>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-kernel-dynamic</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-threadpool-dynamic-mode</artifactId>
<packaging>pom</packaging>
<modules>
<module>config</module>
<module>server</module>
</modules>
</project>

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-dynamic-mode</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-threadpool-dynamic-mode-server</artifactId>
</project>

@ -10,4 +10,11 @@
</parent>
<artifactId>hippo4j-threadpool-kernel-dynamic</artifactId>
<packaging>pom</packaging>
<modules>
<module>api</module>
<module>core</module>
<module>mode</module>
</modules>
</project>

@ -128,5 +128,10 @@
<artifactId>hippo4j-spring-boot-starter-monitor-micrometer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-dynamic-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -17,7 +17,7 @@
package cn.hippo4j.config.springboot.starter.config;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.config.springboot.starter.parser.ConfigFileTypeEnum;
import cn.hippo4j.core.config.BootstrapPropertiesInterface;
import lombok.Getter;

@ -32,7 +32,7 @@ import cn.hippo4j.config.springboot.starter.support.DynamicThreadPoolConfigServi
import cn.hippo4j.config.springboot.starter.support.DynamicThreadPoolPostProcessor;
import cn.hippo4j.core.config.UtilAutoConfiguration;
import cn.hippo4j.core.enable.MarkerConfiguration;
import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler;
import cn.hippo4j.core.executor.handler.DynamicThreadPoolBannerHandler;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.AlarmControlHandler;

@ -17,7 +17,7 @@
package cn.hippo4j.config.springboot.starter.config;
import cn.hippo4j.common.config.ExecutorNotifyProperties;
import cn.hippo4j.common.model.executor.ExecutorNotifyProperties;
import cn.hippo4j.common.api.IExecutorProperties;
import lombok.Data;

@ -26,7 +26,7 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import cn.hippo4j.common.extension.spi.ServiceLoaderRegistry;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;

@ -19,8 +19,8 @@ package cn.hippo4j.config.springboot.starter.notify;
import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.common.api.IExecutorProperties;
import cn.hippo4j.common.config.ExecutorNotifyProperties;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorNotifyProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;

@ -17,13 +17,13 @@
package cn.hippo4j.config.springboot.starter.refresher;
import cn.hippo4j.common.api.ThreadPoolDynamicRefresh;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.config.springboot.starter.parser.ConfigParserHandler;
import cn.hippo4j.config.springboot.starter.refresher.event.Hippo4jConfigDynamicRefreshEvent;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.ApplicationArguments;
@ -40,7 +40,6 @@ import java.util.concurrent.ExecutorService;
public abstract class AbstractConfigThreadPoolDynamicRefresh implements ThreadPoolDynamicRefresh, InitializingBean, ApplicationRunner {
private final BootstrapConfigPropertiesBinderAdapt bootstrapConfigPropertiesBinderAdapt;
protected BootstrapConfigProperties bootstrapConfigProperties;
protected final ExecutorService dynamicRefreshExecutorService = ThreadPoolBuilder.builder().singlePool("client.dynamic.refresh").build();
@ -50,11 +49,6 @@ public abstract class AbstractConfigThreadPoolDynamicRefresh implements ThreadPo
bootstrapConfigPropertiesBinderAdapt = ApplicationContextHolder.getBean(BootstrapConfigPropertiesBinderAdapt.class);
}
/**
* Init register listener.
*/
protected abstract void initRegisterListener();
@Override
public void dynamicRefresh(String configContent) {
dynamicRefresh(configContent, null);
@ -81,7 +75,7 @@ public abstract class AbstractConfigThreadPoolDynamicRefresh implements ThreadPo
@Override
public void afterPropertiesSet() {
try {
initRegisterListener();
registerListener();
} catch (Exception ex) {
log.error("Hippo4j failed to initialize register listener.", ex);
}

@ -42,7 +42,7 @@ public class ApolloRefresherHandler extends AbstractConfigThreadPoolDynamicRefre
private String namespace;
@Override
public void initRegisterListener() {
public void registerListener() {
String[] apolloNamespaces = this.namespace.split(",");
this.namespace = apolloNamespaces[0];
Config config = ConfigService.getConfig(String.format("%s.%s", namespace, bootstrapConfigProperties.getConfigFileType().getValue()));

@ -75,7 +75,7 @@ public class ConsulRefresherHandler extends AbstractConfigThreadPoolDynamicRefre
}
@Override
protected void initRegisterListener() {
public void registerListener() {
// The listener has been registered by annotation.
}
}

@ -58,7 +58,7 @@ public class EtcdRefresherHandler extends AbstractConfigThreadPoolDynamicRefresh
@SneakyThrows(value = {InterruptedException.class, ExecutionException.class})
@Override
public void initRegisterListener() {
public void registerListener() {
Map<String, String> etcd = bootstrapConfigProperties.getEtcd();
String key = etcd.get(KEY);
Charset charset = StringUtil.isBlank(etcd.get(CHARSET)) ? StandardCharsets.UTF_8 : Charset.forName(etcd.get(CHARSET));

@ -46,7 +46,7 @@ public class NacosCloudRefresherHandler extends AbstractConfigThreadPoolDynamicR
@SneakyThrows(NacosException.class)
@Override
public void initRegisterListener() {
public void registerListener() {
Map<String, String> nacosConfig = bootstrapConfigProperties.getNacos();
configService.addListener(nacosConfig.get(DATA_ID),
nacosConfig.get(GROUP), new Listener() {

@ -46,7 +46,7 @@ public class NacosRefresherHandler extends AbstractConfigThreadPoolDynamicRefres
@SneakyThrows(NacosException.class)
@Override
public void initRegisterListener() {
public void registerListener() {
Map<String, String> nacosConfig = bootstrapConfigProperties.getNacos();
configService.addListener(nacosConfig.get(DATA_ID), nacosConfig.get(GROUP),

@ -54,7 +54,7 @@ public class PolarisRefresherHandler extends AbstractConfigThreadPoolDynamicRefr
private String fileName;
@Override
public void initRegisterListener() {
public void registerListener() {
ConfigKVFile configFile = getConfigKVFile();
configFile.addChangeListener((ConfigKVFileChangeListener) event -> {
String content = configFile.getContent();

@ -56,7 +56,7 @@ public class ZookeeperRefresherHandler extends AbstractConfigThreadPoolDynamicRe
private static final int MAX_RETRIES = 3;
@Override
public void initRegisterListener() {
public void registerListener() {
Map<String, String> zkConfigs = bootstrapConfigProperties.getZookeeper();
curatorFramework = CuratorFrameworkFactory.newClient(zkConfigs.get(ZK_CONNECT_STR),
new ExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_RETRIES));

@ -24,7 +24,7 @@ import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.ThreadPoolExecutorUtil;
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.config.springboot.starter.notify.ConfigModeNotifyConfigBuilder;
import cn.hippo4j.config.springboot.starter.support.GlobalCoreThreadPoolManage;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;

@ -19,7 +19,7 @@ package cn.hippo4j.config.springboot.starter.refresher.event;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.config.springboot.starter.notify.ConfigModeNotifyConfigBuilder;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;

@ -17,7 +17,7 @@
package cn.hippo4j.config.springboot.starter.refresher.event;
import cn.hippo4j.common.function.Matcher;
import cn.hippo4j.common.extension.function.Matcher;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

@ -23,7 +23,7 @@ import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterParameter;
import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterWrapper;
import cn.hippo4j.common.model.register.notify.DynamicThreadPoolRegisterCoreNotifyParameter;
import cn.hippo4j.common.toolkit.BooleanUtil;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.executor.support.service.AbstractDynamicThreadPoolService;

@ -24,8 +24,8 @@ import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.toolkit.ReflectUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.config.springboot.starter.config.BootstrapConfigProperties;
import cn.hippo4j.common.config.ExecutorNotifyProperties;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorNotifyProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import cn.hippo4j.core.executor.DynamicThreadPool;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;

@ -17,7 +17,7 @@
package cn.hippo4j.config.springboot.starter.support;
import cn.hippo4j.common.config.ExecutorProperties;
import cn.hippo4j.common.model.executor.ExecutorProperties;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@ -76,5 +76,10 @@
<artifactId>hippo4j-threadpool-monitor-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-threadpool-dynamic-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -22,14 +22,13 @@ import cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose;
import cn.hippo4j.common.api.ThreadDetailState;
import cn.hippo4j.core.api.ThreadPoolCheckAlarm;
import cn.hippo4j.common.api.ThreadPoolConfigChange;
import cn.hippo4j.common.api.ThreadPoolDynamicRefresh;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.core.config.UtilAutoConfiguration;
import cn.hippo4j.core.enable.MarkerConfiguration;
import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler;
import cn.hippo4j.core.executor.support.service.DynamicThreadPoolService;
import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler;
import cn.hippo4j.core.executor.handler.DynamicThreadPoolBannerHandler;
import cn.hippo4j.core.toolkit.IdentifyUtil;
import cn.hippo4j.core.toolkit.inet.InetUtils;
import cn.hippo4j.message.api.NotifyConfigBuilder;
@ -63,6 +62,7 @@ import cn.hippo4j.springboot.starter.support.AdaptedThreadPoolDestroyPostProcess
import cn.hippo4j.springboot.starter.support.DynamicThreadPoolConfigService;
import cn.hippo4j.springboot.starter.support.DynamicThreadPoolPostProcessor;
import cn.hippo4j.springboot.starter.support.ThreadPoolPluginRegisterPostProcessor;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;

@ -20,11 +20,10 @@ package cn.hippo4j.springboot.starter.controller;
import cn.hippo4j.adapter.base.ThreadPoolAdapter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterParameter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterState;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.core.api.ClientNetworkService;
import cn.hippo4j.common.extension.spi.ServiceLoaderRegistry;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results;
import cn.hippo4j.core.toolkit.IdentifyUtil;
import cn.hippo4j.core.toolkit.inet.InetUtils;
import cn.hippo4j.springboot.starter.toolkit.CloudCommonIdUtil;
@ -70,7 +69,7 @@ public class ThreadPoolAdapterController {
threadPoolState.setIdentify(IdentifyUtil.getIdentify());
return threadPoolState;
}).orElse(null);
return Results.success(result);
return new Result<ThreadPoolAdapterState>().setCode(Result.SUCCESS_CODE).setData(result);
}
@PostMapping("/adapter/thread-pool/update")
@ -79,6 +78,6 @@ public class ThreadPoolAdapterController {
requestParameter.getMark(), requestParameter.getThreadPoolKey(), requestParameter.getCorePoolSize(), requestParameter.getMaximumPoolSize());
ThreadPoolAdapter threadPoolAdapter = THREAD_POOL_ADAPTER_BEAN_CONTAINER.get(requestParameter.getMark());
Optional.ofNullable(threadPoolAdapter).ifPresent(each -> each.updateThreadPool(requestParameter));
return Results.success();
return new Result<Void>().setCode(Result.SUCCESS_CODE);
}
}

@ -19,11 +19,10 @@ package cn.hippo4j.springboot.starter.controller;
import cn.hippo4j.adapter.web.WebThreadPoolHandlerChoose;
import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
@ -48,20 +47,19 @@ public class WebThreadPoolController {
public Result<ThreadPoolBaseInfo> getPoolBaseState(@RequestParam(value = "mark") String mark) {
WebThreadPoolService webThreadPoolService = webThreadPoolServiceChoose.choose();
if (webThreadPoolService != null && webThreadPoolService.getClass().getSimpleName().contains(mark)) {
return Results.success(webThreadPoolService.simpleInfo());
return new Result<ThreadPoolBaseInfo>().setCode(Result.SUCCESS_CODE).setData(webThreadPoolService.simpleInfo());
}
return Results.success(null);
return new Result<ThreadPoolBaseInfo>().setCode(Result.SUCCESS_CODE);
}
@GetMapping("/web/run/state")
public Result<ThreadPoolRunStateInfo> getPoolRunState() {
ThreadPoolRunStateInfo result = webThreadPoolServiceChoose.choose().getWebRunStateInfo();
return Results.success(result);
return new Result<ThreadPoolRunStateInfo>().setCode(Result.SUCCESS_CODE).setData(webThreadPoolServiceChoose.choose().getWebRunStateInfo());
}
@PostMapping("/web/update/pool")
public Result<Void> updateWebThreadPool(@RequestBody ThreadPoolParameterInfo threadPoolParameterInfo) {
webThreadPoolServiceChoose.choose().updateWebThreadPool(threadPoolParameterInfo);
return Results.success();
return new Result<Void>().setCode(Result.SUCCESS_CODE);
}
}

@ -18,10 +18,9 @@
package cn.hippo4j.springboot.starter.controller;
import cn.hippo4j.common.api.ThreadDetailState;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.common.model.ThreadPoolRunStateInfo;
import cn.hippo4j.common.model.ThreadDetailStateInfo;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results;
import cn.hippo4j.core.executor.state.ThreadPoolRunStateHandler;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.CrossOrigin;
@ -44,13 +43,11 @@ public class WebThreadPoolRunStateController {
@GetMapping("/run/state/{threadPoolId}")
public Result<ThreadPoolRunStateInfo> getPoolRunState(@PathVariable("threadPoolId") String threadPoolId) {
ThreadPoolRunStateInfo result = threadPoolRunStateHandler.getPoolRunState(threadPoolId);
return Results.success(result);
return new Result<ThreadPoolRunStateInfo>().setCode(Result.SUCCESS_CODE).setData(threadPoolRunStateHandler.getPoolRunState(threadPoolId));
}
@GetMapping("/run/thread/state/{threadPoolId}")
public Result<List<ThreadDetailStateInfo>> getThreadStateDetail(@PathVariable("threadPoolId") String threadPoolId) {
List<ThreadDetailStateInfo> result = threadDetailState.getThreadDetailStateInfo(threadPoolId);
return Results.success(result);
return new Result<List<ThreadDetailStateInfo>>().setCode(Result.SUCCESS_CODE).setData(threadDetailState.getThreadDetailStateInfo(threadPoolId));
}
}

@ -17,19 +17,20 @@
package cn.hippo4j.springboot.starter.core;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import cn.hippo4j.common.toolkit.ContentUtil;
import cn.hippo4j.common.toolkit.GroupKey;
import cn.hippo4j.common.toolkit.IdUtil;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.springboot.starter.remote.HttpAgent;
import cn.hippo4j.springboot.starter.remote.ServerHealthCheck;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.util.StringUtils;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collections;
@ -42,6 +43,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import static cn.hippo4j.common.constant.Constants.CONFIG_LONG_POLL_TIMEOUT;
import static cn.hippo4j.common.constant.Constants.GROUP_KEY_DELIMITER_TRANSLATION;
import static cn.hippo4j.common.constant.Constants.WORD_SEPARATOR;

@ -18,13 +18,11 @@
package cn.hippo4j.springboot.starter.core;
import cn.hippo4j.common.api.ClientCloseHookExecute;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.model.InstanceInfo;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.base.Results;
import cn.hippo4j.common.web.exception.ErrorCodeEnum;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import cn.hippo4j.springboot.starter.remote.HttpAgent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.DisposableBean;
@ -48,10 +46,12 @@ public class DiscoveryClient implements DisposableBean {
private final ClientShutdown hippo4jClientShutdown;
private volatile long lastSuccessfulHeartbeatTimestamp = -1;
private final int delayTime = 30;
private static final String PREFIX = "DiscoveryClient_";
private final String appPathIdentifier;
private final int delayTime = 30;
private final String SERVICE_ERROR_CODE = "3";
private final String SERVICE_NOT_FOUND_CODE = "404";
public DiscoveryClient(HttpAgent httpAgent, InstanceInfo instanceInfo, ClientShutdown hippo4jClientShutdown) {
this.httpAgent = httpAgent;
@ -77,7 +77,7 @@ public class DiscoveryClient implements DisposableBean {
try {
registerResult = httpAgent.httpPostByDiscovery(urlPath, instanceInfo);
} catch (Exception ex) {
registerResult = Results.failure(ErrorCodeEnum.SERVICE_ERROR);
registerResult = new Result<Void>().setCode(SERVICE_ERROR_CODE);
log.error("{}{} - registration failed: {}", PREFIX, appPathIdentifier, ex.getMessage());
}
if (log.isInfoEnabled()) {
@ -145,7 +145,7 @@ public class DiscoveryClient implements DisposableBean {
.setLastDirtyTimestamp(instanceInfo.getLastDirtyTimestamp().toString())
.setStatus(instanceInfo.getStatus().toString());
renewResult = httpAgent.httpPostByDiscovery(BASE_PATH + "/apps/renew", instanceRenew);
if (Objects.equals(ErrorCodeEnum.NOT_FOUND.getCode(), renewResult.getCode())) {
if (Objects.equals(SERVICE_NOT_FOUND_CODE, renewResult.getCode())) {
long timestamp = instanceInfo.setIsDirtyWithTime();
boolean success = register();
// TODO Abstract server registration logic

@ -17,10 +17,10 @@
package cn.hippo4j.springboot.starter.core;
import cn.hippo4j.common.api.ThreadPoolDynamicRefresh;
import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.core.executor.support.ThreadPoolBuilder;
import cn.hippo4j.springboot.starter.config.BootstrapProperties;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;

@ -18,8 +18,7 @@
package cn.hippo4j.springboot.starter.core;
import cn.hippo4j.common.api.ThreadPoolConfigChange;
import cn.hippo4j.common.api.ThreadPoolDynamicRefresh;
import cn.hippo4j.common.enums.EnableEnum;
import cn.hippo4j.common.extension.enums.EnableEnum;
import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.executor.support.ResizableCapacityLinkedBlockingQueue;
@ -30,6 +29,7 @@ import cn.hippo4j.common.toolkit.ThreadPoolExecutorUtil;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.message.request.ChangeParameterNotifyRequest;
import cn.hippo4j.threadpool.dynamic.api.ThreadPoolDynamicRefresh;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@ -21,9 +21,9 @@ import cn.hippo4j.adapter.base.ThreadPoolAdapter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterCacheConfig;
import cn.hippo4j.adapter.base.ThreadPoolAdapterRegisterAction;
import cn.hippo4j.adapter.base.ThreadPoolAdapterState;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.core.toolkit.IdentifyUtil;
import cn.hippo4j.core.toolkit.inet.InetUtils;
import cn.hippo4j.springboot.starter.config.BootstrapProperties;

@ -18,7 +18,7 @@
package cn.hippo4j.springboot.starter.monitor;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import cn.hippo4j.common.monitor.Message;
import cn.hippo4j.common.extension.spi.ServiceLoaderRegistry;
import cn.hippo4j.common.toolkit.CollectionUtil;

@ -17,10 +17,10 @@
package cn.hippo4j.springboot.starter.notify;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.GroupKey;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.dto.NotifyConfigDTO;

@ -20,7 +20,7 @@ package cn.hippo4j.springboot.starter.remote;
import cn.hippo4j.common.toolkit.ThreadUtil;
import cn.hippo4j.springboot.starter.event.ApplicationRefreshedEvent;
import cn.hippo4j.springboot.starter.core.ShutdownExecuteException;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;

@ -17,7 +17,7 @@
package cn.hippo4j.springboot.starter.remote;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.model.Result;
import java.util.Map;

@ -17,7 +17,7 @@
package cn.hippo4j.springboot.starter.remote;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.model.Result;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@ -17,12 +17,12 @@
package cn.hippo4j.springboot.starter.remote;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.common.toolkit.http.HttpUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.springboot.starter.config.BootstrapProperties;
import cn.hippo4j.springboot.starter.security.SecurityProxy;

@ -18,11 +18,11 @@
package cn.hippo4j.springboot.starter.security;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.common.model.TokenInfo;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.common.toolkit.http.HttpUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.springboot.starter.config.BootstrapProperties;
import lombok.extern.slf4j.Slf4j;

@ -17,6 +17,7 @@
package cn.hippo4j.springboot.starter.support;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterParameter;
import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterWrapper;
@ -24,8 +25,6 @@ import cn.hippo4j.common.toolkit.Assert;
import cn.hippo4j.common.toolkit.BooleanUtil;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.common.web.exception.ServiceException;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
import cn.hippo4j.core.executor.manage.GlobalThreadPoolManage;
import cn.hippo4j.core.executor.support.service.AbstractDynamicThreadPoolService;
@ -55,13 +54,9 @@ import static cn.hippo4j.common.constant.Constants.REGISTER_DYNAMIC_THREAD_POOL_
public class DynamicThreadPoolConfigService extends AbstractDynamicThreadPoolService {
private final HttpAgent httpAgent;
private final BootstrapProperties properties;
private final ServerModeNotifyConfigBuilder serverModeNotifyConfigBuilder;
private final Hippo4jBaseSendMessageService hippo4jBaseSendMessageService;
private final DynamicThreadPoolSubscribeConfig dynamicThreadPoolSubscribeConfig;
@Override
@ -80,7 +75,7 @@ public class DynamicThreadPoolConfigService extends AbstractDynamicThreadPoolSer
failDynamicThreadPoolRegisterWrapper(registerWrapper);
Result registerResult = httpAgent.httpPost(REGISTER_DYNAMIC_THREAD_POOL_PATH, registerWrapper);
if (registerResult == null || !registerResult.isSuccess()) {
throw new ServiceException("Dynamic thread pool registration returns error."
throw new RuntimeException("Dynamic thread pool registration returns error."
+ Optional.ofNullable(registerResult).map(Result::getMessage).orElse(""));
}
} catch (Throwable ex) {

@ -17,9 +17,10 @@
package cn.hippo4j.springboot.starter.support;
import cn.hippo4j.common.model.Result;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.enums.EnableEnum;
import cn.hippo4j.common.extension.enums.EnableEnum;
import cn.hippo4j.common.executor.support.BlockingQueueTypeEnum;
import cn.hippo4j.common.executor.support.RejectedPolicyTypeEnum;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;
@ -28,7 +29,6 @@ import cn.hippo4j.common.model.register.DynamicThreadPoolRegisterWrapper;
import cn.hippo4j.common.toolkit.BooleanUtil;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.common.toolkit.ReflectUtil;
import cn.hippo4j.common.web.base.Result;
import cn.hippo4j.core.executor.DynamicThreadPool;
import cn.hippo4j.core.executor.DynamicThreadPoolExecutor;
import cn.hippo4j.core.executor.DynamicThreadPoolWrapper;
@ -53,6 +53,7 @@ import java.util.Optional;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static cn.hippo4j.common.constant.Constants.INITIAL_CAPACITY;
import static cn.hippo4j.common.constant.Constants.TP_ID;
import static cn.hippo4j.common.constant.Constants.ITEM_ID;
@ -70,9 +71,7 @@ import static cn.hippo4j.common.constant.Constants.HTTP_EXECUTE_TIMEOUT;
public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
private final BootstrapProperties properties;
private final HttpAgent httpAgent;
private final DynamicThreadPoolSubscribeConfig dynamicThreadPoolSubscribeConfig;
@Override

@ -18,11 +18,11 @@
package cn.hippo4j.springboot.starter.support;
import cn.hippo4j.common.toolkit.Assert;
import cn.hippo4j.core.plugin.ThreadPoolPlugin;
import cn.hippo4j.core.plugin.manager.DefaultGlobalThreadPoolPluginManager;
import cn.hippo4j.core.plugin.manager.GlobalThreadPoolPluginManager;
import cn.hippo4j.core.plugin.manager.ThreadPoolPluginRegistrar;
import cn.hippo4j.core.plugin.manager.ThreadPoolPluginSupport;
import cn.hippo4j.core.executor.plugin.ThreadPoolPlugin;
import cn.hippo4j.core.executor.plugin.manager.DefaultGlobalThreadPoolPluginManager;
import cn.hippo4j.core.executor.plugin.manager.GlobalThreadPoolPluginManager;
import cn.hippo4j.core.executor.plugin.manager.ThreadPoolPluginRegistrar;
import cn.hippo4j.core.executor.plugin.manager.ThreadPoolPluginSupport;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.autoproxy.AutoProxyUtils;
import org.springframework.beans.BeansException;
@ -59,7 +59,7 @@ import java.util.Objects;
public class ThreadPoolPluginRegisterPostProcessor extends DefaultGlobalThreadPoolPluginManager implements BeanPostProcessor, ApplicationContextAware {
/**
* application context
* Application context
*/
private ConfigurableListableBeanFactory beanFactory;

@ -17,7 +17,7 @@
package cn.hippo4j.adapter.hystrix;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import cn.hippo4j.common.executor.ThreadFactoryBuilder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@ -17,7 +17,7 @@
package cn.hippo4j.adapter.web;
import cn.hippo4j.common.enums.WebContainerEnum;
import cn.hippo4j.common.extension.enums.WebContainerEnum;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -17,7 +17,7 @@
package cn.hippo4j.adapter.web;
import cn.hippo4j.common.enums.WebContainerEnum;
import cn.hippo4j.common.extension.enums.WebContainerEnum;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -18,7 +18,6 @@
package cn.hippo4j.adapter.web;
import cn.hippo4j.core.config.ApplicationContextHolder;
import cn.hippo4j.common.web.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
/**
@ -37,7 +36,7 @@ public class WebThreadPoolHandlerChoose {
try {
webThreadPoolService = ApplicationContextHolder.getBean(WebThreadPoolService.class);
} catch (Exception ex) {
throw new ServiceException("Web thread pool service bean not found.", ex);
throw new RuntimeException("Web thread pool service bean not found.", ex);
}
return webThreadPoolService;
}

@ -17,7 +17,7 @@
package cn.hippo4j.adapter.web;
import cn.hippo4j.common.enums.WebContainerEnum;
import cn.hippo4j.common.extension.enums.WebContainerEnum;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -19,7 +19,7 @@ package cn.hippo4j.adapter.web.jetty;
import cn.hippo4j.adapter.web.IWebThreadPoolHandlerSupport;
import cn.hippo4j.common.constant.ChangeThreadPoolConstants;
import cn.hippo4j.common.enums.WebContainerEnum;
import cn.hippo4j.common.extension.enums.WebContainerEnum;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -19,7 +19,7 @@ package cn.hippo4j.adapter.web.tomcat;
import cn.hippo4j.adapter.web.IWebThreadPoolHandlerSupport;
import cn.hippo4j.common.constant.ChangeThreadPoolConstants;
import cn.hippo4j.common.enums.WebContainerEnum;
import cn.hippo4j.common.extension.enums.WebContainerEnum;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -19,7 +19,7 @@ package cn.hippo4j.adapter.web.undertow;
import cn.hippo4j.adapter.web.IWebThreadPoolHandlerSupport;
import cn.hippo4j.common.constant.ChangeThreadPoolConstants;
import cn.hippo4j.common.enums.WebContainerEnum;
import cn.hippo4j.common.extension.enums.WebContainerEnum;
import cn.hippo4j.common.model.ThreadPoolBaseInfo;
import cn.hippo4j.common.model.ThreadPoolParameter;
import cn.hippo4j.common.model.ThreadPoolParameterInfo;

@ -18,12 +18,12 @@
package cn.hippo4j.core.executor;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.core.plugin.impl.TaskDecoratorPlugin;
import cn.hippo4j.core.plugin.impl.TaskRejectCountRecordPlugin;
import cn.hippo4j.core.plugin.impl.TaskTimeoutNotifyAlarmPlugin;
import cn.hippo4j.core.plugin.impl.ThreadPoolExecutorShutdownPlugin;
import cn.hippo4j.core.plugin.manager.DefaultThreadPoolPluginManager;
import cn.hippo4j.core.plugin.manager.DefaultThreadPoolPluginRegistrar;
import cn.hippo4j.core.executor.plugin.impl.TaskDecoratorPlugin;
import cn.hippo4j.core.executor.plugin.impl.TaskRejectCountRecordPlugin;
import cn.hippo4j.core.executor.plugin.impl.TaskTimeoutNotifyAlarmPlugin;
import cn.hippo4j.core.executor.plugin.impl.ThreadPoolExecutorShutdownPlugin;
import cn.hippo4j.core.executor.plugin.manager.DefaultThreadPoolPluginManager;
import cn.hippo4j.core.executor.plugin.manager.DefaultThreadPoolPluginRegistrar;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

@ -17,7 +17,7 @@
package cn.hippo4j.core.executor;
import cn.hippo4j.core.provider.CommonDynamicThreadPoolProviderFactory;
import cn.hippo4j.core.executor.provider.CommonDynamicThreadPoolProviderFactory;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@ -17,13 +17,13 @@
package cn.hippo4j.core.executor;
import cn.hippo4j.core.plugin.ExecuteAwarePlugin;
import cn.hippo4j.core.plugin.RejectedAwarePlugin;
import cn.hippo4j.core.plugin.ShutdownAwarePlugin;
import cn.hippo4j.core.plugin.TaskAwarePlugin;
import cn.hippo4j.core.plugin.ThreadPoolPlugin;
import cn.hippo4j.core.plugin.manager.ThreadPoolPluginManager;
import cn.hippo4j.core.plugin.manager.ThreadPoolPluginSupport;
import cn.hippo4j.core.executor.plugin.ExecuteAwarePlugin;
import cn.hippo4j.core.executor.plugin.RejectedAwarePlugin;
import cn.hippo4j.core.executor.plugin.ShutdownAwarePlugin;
import cn.hippo4j.core.executor.plugin.TaskAwarePlugin;
import cn.hippo4j.core.executor.plugin.ThreadPoolPlugin;
import cn.hippo4j.core.executor.plugin.manager.ThreadPoolPluginManager;
import cn.hippo4j.core.executor.plugin.manager.ThreadPoolPluginSupport;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.core.handler;
package cn.hippo4j.core.executor.handler;
import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.core.config.BootstrapPropertiesInterface;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.core.plugin;
package cn.hippo4j.core.executor.plugin;
import java.util.concurrent.ThreadPoolExecutor;

@ -15,7 +15,7 @@
* limitations under the License.
*/
package cn.hippo4j.core.plugin;
package cn.hippo4j.core.executor.plugin;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save