Changed Hippo4j class and method naming

pull/1165/head
chen.ma 1 year ago
parent be636bf08a
commit 56e39abb3b

@ -31,7 +31,7 @@ public class UtilAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public InetUtils hippo4JInetUtils(InetUtilsProperties inetUtilsProperties) { public InetUtils hippo4jInetUtils(InetUtilsProperties inetUtilsProperties) {
return new InetUtils(inetUtilsProperties); return new InetUtils(inetUtilsProperties);
} }
} }

@ -41,7 +41,7 @@ import static cn.hippo4j.core.toolkit.IdentifyUtil.CLIENT_IDENTIFICATION_VALUE;
@AllArgsConstructor @AllArgsConstructor
public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime { public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime {
private final InetUtils hippo4JInetUtils; private final InetUtils hippo4jInetUtils;
private final ConfigurableEnvironment environment; private final ConfigurableEnvironment environment;
@ -56,7 +56,7 @@ public class ThreadPoolRunStateHandler extends AbstractThreadPoolRuntime {
ByteConvertUtil.getPrintSize(max)); ByteConvertUtil.getPrintSize(max));
poolRunStateInfo.setCurrentLoad(poolRunStateInfo.getCurrentLoad() + "%"); poolRunStateInfo.setCurrentLoad(poolRunStateInfo.getCurrentLoad() + "%");
poolRunStateInfo.setPeakLoad(poolRunStateInfo.getPeakLoad() + "%"); poolRunStateInfo.setPeakLoad(poolRunStateInfo.getPeakLoad() + "%");
String ipAddress = hippo4JInetUtils.findFirstNonLoopBackHostInfo().getIpAddress(); String ipAddress = hippo4jInetUtils.findFirstNonLoopBackHostInfo().getIpAddress();
poolRunStateInfo.setHost(ipAddress); poolRunStateInfo.setHost(ipAddress);
poolRunStateInfo.setMemoryProportion(memoryProportion); poolRunStateInfo.setMemoryProportion(memoryProportion);
poolRunStateInfo.setFreeMemory(ByteConvertUtil.getPrintSize(Math.subtractExact(max, used))); poolRunStateInfo.setFreeMemory(ByteConvertUtil.getPrintSize(Math.subtractExact(max, used)));

@ -34,10 +34,10 @@ public class BaseSpringApplicationRunListener implements SpringApplicationRunLis
private final String[] args; private final String[] args;
private List<Hippo4JApplicationListener> hippo4JApplicationListeners = new ArrayList(); private List<Hippo4jApplicationListener> hippo4jApplicationListeners = new ArrayList();
{ {
hippo4JApplicationListeners.add(new StartingApplicationListener()); hippo4jApplicationListeners.add(new StartingApplicationListener());
} }
public BaseSpringApplicationRunListener(SpringApplication application, String[] args) { public BaseSpringApplicationRunListener(SpringApplication application, String[] args) {
@ -47,22 +47,22 @@ public class BaseSpringApplicationRunListener implements SpringApplicationRunLis
@Override @Override
public void starting() { public void starting() {
hippo4JApplicationListeners.forEach(each -> each.starting()); hippo4jApplicationListeners.forEach(each -> each.starting());
} }
@Override @Override
public void contextPrepared(ConfigurableApplicationContext context) { public void contextPrepared(ConfigurableApplicationContext context) {
hippo4JApplicationListeners.forEach(each -> each.contextPrepared(context)); hippo4jApplicationListeners.forEach(each -> each.contextPrepared(context));
} }
@Override @Override
public void started(ConfigurableApplicationContext context) { public void started(ConfigurableApplicationContext context) {
hippo4JApplicationListeners.forEach(each -> each.started(context)); hippo4jApplicationListeners.forEach(each -> each.started(context));
} }
@Override @Override
public void failed(ConfigurableApplicationContext context, Throwable exception) { public void failed(ConfigurableApplicationContext context, Throwable exception) {
hippo4JApplicationListeners.forEach(each -> each.failed(context, exception)); hippo4jApplicationListeners.forEach(each -> each.failed(context, exception));
} }
@Override @Override

@ -22,7 +22,7 @@ import org.springframework.context.ConfigurableApplicationContext;
/** /**
* Hippo4J application listener. * Hippo4J application listener.
*/ */
public interface Hippo4JApplicationListener { public interface Hippo4jApplicationListener {
/** /**
* {@link BaseSpringApplicationRunListener#starting} * {@link BaseSpringApplicationRunListener#starting}

@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
* Starting application listener. * Starting application listener.
*/ */
@Slf4j @Slf4j
public class StartingApplicationListener implements Hippo4JApplicationListener { public class StartingApplicationListener implements Hippo4jApplicationListener {
private volatile boolean starting; private volatile boolean starting;
@ -53,7 +53,7 @@ public class StartingApplicationListener implements Hippo4JApplicationListener {
}); });
scheduledExecutorService.scheduleWithFixedDelay(() -> { scheduledExecutorService.scheduleWithFixedDelay(() -> {
if (starting) { if (starting) {
log.info("Hippo4J is starting..."); log.info("Hippo4j is starting...");
} }
}, 1, 1, TimeUnit.SECONDS); }, 1, 1, TimeUnit.SECONDS);
} }
@ -64,7 +64,7 @@ public class StartingApplicationListener implements Hippo4JApplicationListener {
starting = false; starting = false;
closeExecutor(); closeExecutor();
if (EnvUtil.getStandaloneMode()) { if (EnvUtil.getStandaloneMode()) {
log.info("Hippo4J started successfully..."); log.info("Hippo4j started successfully...");
} }
} }
@ -73,8 +73,8 @@ public class StartingApplicationListener implements Hippo4JApplicationListener {
log.error("Startup errors: {}", exception); log.error("Startup errors: {}", exception);
closeExecutor(); closeExecutor();
context.close(); context.close();
log.error("Hippo4J failed to start, please see {} for more details.", log.error("Hippo4j failed to start, please see {} for more details.",
Paths.get(EnvUtil.getHippo4JHome(), "logs/hippo4j.log")); Paths.get(EnvUtil.getHippo4jHome(), "logs/hippo4j.log"));
} }
private void closeExecutor() { private void closeExecutor() {

@ -1,6 +1,6 @@
__ __ ___ ___ __ __ __ ___ ___ __
| |--.|__|.-----..-----..-----.| | | |__| Hippo4J ${application.version} | |--.|__|.-----..-----..-----.| | | |__| Hippo4j ${application.version}
| || || _ || _ || _ || | | | | Port: ${server.port} PID: ${pid} | || || _ || _ || _ || | | | | Port: ${server.port} PID: ${pid}
|__|__||__|| __|| __||_____||____ | | | |__|__||__|| __|| __||_____||____ | | |
|__| |__| |: ||___| Site: https://hippo4j.cn |__| |__| |: ||___| Site: https://hippo4j.cn

@ -34,7 +34,7 @@ public class CommonConfig {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public ApplicationContextHolder hippo4JApplicationContextHolder() { public ApplicationContextHolder hippo4jApplicationContextHolder() {
return new ApplicationContextHolder(); return new ApplicationContextHolder();
} }

@ -40,7 +40,7 @@ public class EnvUtil {
* *
* @return * @return
*/ */
public static String getHippo4JHome() { public static String getHippo4jHome() {
if (StringUtil.isBlank(HIPPO4J_HOME_PATH)) { if (StringUtil.isBlank(HIPPO4J_HOME_PATH)) {
String hippo4jHome = System.getProperty(HIPPO4J_HOME_KEY); String hippo4jHome = System.getProperty(HIPPO4J_HOME_KEY);
if (StringUtil.isBlank(hippo4jHome)) { if (StringUtil.isBlank(hippo4jHome)) {

@ -27,9 +27,9 @@ import org.junit.Test;
public class EnvUtilTest { public class EnvUtilTest {
@Test @Test
public void getHippo4JHomeTest() { public void getHippo4jHomeTest() {
String hippo4JHome = EnvUtil.getHippo4JHome(); String hippo4jHome = EnvUtil.getHippo4jHome();
Assert.isTrue(StringUtil.isNotBlank(hippo4JHome)); Assert.isTrue(StringUtil.isNotBlank(hippo4jHome));
} }
@Test @Test

@ -19,7 +19,6 @@ package cn.hippo4j.config.springboot.starter.config;
import cn.hippo4j.adapter.web.WebThreadPoolService; import cn.hippo4j.adapter.web.WebThreadPoolService;
import cn.hippo4j.common.api.ThreadPoolCheckAlarm; import cn.hippo4j.common.api.ThreadPoolCheckAlarm;
import cn.hippo4j.common.api.ThreadPoolConfigChange;
import cn.hippo4j.common.config.ApplicationContextHolder; import cn.hippo4j.common.config.ApplicationContextHolder;
import cn.hippo4j.common.toolkit.StringUtil; import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.config.springboot.starter.monitor.ThreadPoolMonitorExecutor; import cn.hippo4j.config.springboot.starter.monitor.ThreadPoolMonitorExecutor;
@ -36,7 +35,12 @@ import cn.hippo4j.core.enable.MarkerConfiguration;
import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler; import cn.hippo4j.core.handler.DynamicThreadPoolBannerHandler;
import cn.hippo4j.message.api.NotifyConfigBuilder; import cn.hippo4j.message.api.NotifyConfigBuilder;
import cn.hippo4j.message.config.MessageConfiguration; import cn.hippo4j.message.config.MessageConfiguration;
import cn.hippo4j.message.service.*; import cn.hippo4j.message.service.AlarmControlHandler;
import cn.hippo4j.message.service.DefaultThreadPoolCheckAlarmHandler;
import cn.hippo4j.message.service.DefaultThreadPoolConfigChangeHandler;
import cn.hippo4j.message.service.Hippo4jBaseSendMessageService;
import cn.hippo4j.message.service.Hippo4jSendMessageService;
import cn.hippo4j.message.service.WebThreadPoolConfigChangeHandler;
import cn.hippo4j.springboot.starter.adapter.web.WebAdapterConfiguration; import cn.hippo4j.springboot.starter.adapter.web.WebAdapterConfiguration;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
@ -52,8 +56,6 @@ import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import java.util.Optional;
/** /**
* Dynamic thread-pool auto-configuration. * Dynamic thread-pool auto-configuration.
* *
@ -77,7 +79,7 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
public ApplicationContextHolder hippo4JApplicationContextHolder() { public ApplicationContextHolder hippo4jApplicationContextHolder() {
return new ApplicationContextHolder(); return new ApplicationContextHolder();
} }
@ -110,7 +112,7 @@ public class DynamicThreadPoolAutoConfiguration {
} }
@Bean @Bean
public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor(ApplicationContextHolder hippo4JApplicationContextHolder) { public DynamicThreadPoolPostProcessor dynamicThreadPoolPostProcessor(ApplicationContextHolder hippo4jApplicationContextHolder) {
return new DynamicThreadPoolPostProcessor(bootstrapConfigProperties); return new DynamicThreadPoolPostProcessor(bootstrapConfigProperties);
} }

@ -54,8 +54,8 @@ public class WebAdapterConfiguration {
@Bean @Bean
@SuppressWarnings("all") @SuppressWarnings("all")
public ThreadPoolRunStateHandler threadPoolRunStateHandler(InetUtils hippo4JInetUtils) { public ThreadPoolRunStateHandler threadPoolRunStateHandler(InetUtils hippo4jInetUtils) {
return new ThreadPoolRunStateHandler(hippo4JInetUtils, environment); return new ThreadPoolRunStateHandler(hippo4jInetUtils, environment);
} }
@Bean @Bean

@ -37,11 +37,11 @@ public class DiscoveryConfiguration {
private final BootstrapProperties bootstrapProperties; private final BootstrapProperties bootstrapProperties;
private final InetUtils hippo4JInetUtils; private final InetUtils hippo4jInetUtils;
@Bean @Bean
public InstanceInfo instanceConfig() { public InstanceInfo instanceConfig() {
return InstanceInfoProviderFactory.getInstance(environment, bootstrapProperties, hippo4JInetUtils); return InstanceInfoProviderFactory.getInstance(environment, bootstrapProperties, hippo4jInetUtils);
} }
@Bean @Bean
@ -50,7 +50,7 @@ public class DiscoveryConfiguration {
} }
@Bean @Bean
public DiscoveryClient hippo4JDiscoveryClient(HttpAgent httpAgent, public DiscoveryClient hippo4jDiscoveryClient(HttpAgent httpAgent,
InstanceInfo instanceInfo, InstanceInfo instanceInfo,
ClientShutdown hippo4jClientShutdown) { ClientShutdown hippo4jClientShutdown) {
return new DiscoveryClient(httpAgent, instanceInfo, hippo4jClientShutdown); return new DiscoveryClient(httpAgent, instanceInfo, hippo4jClientShutdown);

@ -106,17 +106,17 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
public ApplicationContextHolder hippo4JApplicationContextHolder() { public ApplicationContextHolder hippo4jApplicationContextHolder() {
return new ApplicationContextHolder(); return new ApplicationContextHolder();
} }
@Bean @Bean
public ClientWorker hippo4jClientWorker(HttpAgent httpAgent, public ClientWorker hippo4jClientWorker(HttpAgent httpAgent,
InetUtils hippo4JInetUtils, InetUtils hippo4jInetUtils,
ServerHealthCheck serverHealthCheck, ServerHealthCheck serverHealthCheck,
DynamicThreadPoolBannerHandler dynamicThreadPoolBannerHandlers, DynamicThreadPoolBannerHandler dynamicThreadPoolBannerHandlers,
ClientShutdown hippo4jClientShutdown) { ClientShutdown hippo4jClientShutdown) {
String identify = IdentifyUtil.generate(environment, hippo4JInetUtils); String identify = IdentifyUtil.generate(environment, hippo4jInetUtils);
return new ClientWorker(httpAgent, identify, serverHealthCheck, dynamicThreadPoolBannerHandlers.getVersion(), hippo4jClientShutdown); return new ClientWorker(httpAgent, identify, serverHealthCheck, dynamicThreadPoolBannerHandlers.getVersion(), hippo4jClientShutdown);
} }
@ -138,7 +138,7 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean @Bean
@SuppressWarnings("all") @SuppressWarnings("all")
public DynamicThreadPoolPostProcessor threadPoolBeanPostProcessor(HttpAgent httpAgent, public DynamicThreadPoolPostProcessor threadPoolBeanPostProcessor(HttpAgent httpAgent,
ApplicationContextHolder hippo4JApplicationContextHolder, ApplicationContextHolder hippo4jApplicationContextHolder,
DynamicThreadPoolSubscribeConfig dynamicThreadPoolSubscribeConfig) { DynamicThreadPoolSubscribeConfig dynamicThreadPoolSubscribeConfig) {
return new DynamicThreadPoolPostProcessor(properties, httpAgent, dynamicThreadPoolSubscribeConfig); return new DynamicThreadPoolPostProcessor(properties, httpAgent, dynamicThreadPoolSubscribeConfig);
} }
@ -182,8 +182,8 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean @Bean
@SuppressWarnings("all") @SuppressWarnings("all")
public ThreadPoolAdapterController threadPoolAdapterController(InetUtils hippo4JInetUtils) { public ThreadPoolAdapterController threadPoolAdapterController(InetUtils hippo4jInetUtils) {
return new ThreadPoolAdapterController(environment, hippo4JInetUtils); return new ThreadPoolAdapterController(environment, hippo4jInetUtils);
} }
@Bean @Bean
@ -205,8 +205,8 @@ public class DynamicThreadPoolAutoConfiguration {
@Bean @Bean
@SuppressWarnings("all") @SuppressWarnings("all")
public ThreadPoolAdapterRegister threadPoolAdapterRegister(HttpAgent httpAgent, public ThreadPoolAdapterRegister threadPoolAdapterRegister(HttpAgent httpAgent,
InetUtils hippo4JInetUtils) { InetUtils hippo4jInetUtils) {
return new ThreadPoolAdapterRegister(httpAgent, properties, environment, hippo4JInetUtils); return new ThreadPoolAdapterRegister(httpAgent, properties, environment, hippo4jInetUtils);
} }
@Bean @Bean

@ -49,7 +49,7 @@ import static cn.hippo4j.adapter.base.ThreadPoolAdapterBeanContainer.THREAD_POOL
public class ThreadPoolAdapterController { public class ThreadPoolAdapterController {
private final ConfigurableEnvironment environment; private final ConfigurableEnvironment environment;
private final InetUtils hippo4JInetUtils; private final InetUtils hippo4jInetUtils;
@GetMapping("/adapter/thread-pool/info") @GetMapping("/adapter/thread-pool/info")
public Result<ThreadPoolAdapterState> getAdapterThreadPool(ThreadPoolAdapterParameter requestParameter) { public Result<ThreadPoolAdapterState> getAdapterThreadPool(ThreadPoolAdapterParameter requestParameter) {
@ -64,7 +64,7 @@ public class ThreadPoolAdapterController {
if (customerNetwork != null) { if (customerNetwork != null) {
clientAddress = StringUtil.newBuilder(customerNetwork[0], ":", customerNetwork[1]); clientAddress = StringUtil.newBuilder(customerNetwork[0], ":", customerNetwork[1]);
} else { } else {
clientAddress = CloudCommonIdUtil.getClientIpPort(environment, hippo4JInetUtils); clientAddress = CloudCommonIdUtil.getClientIpPort(environment, hippo4jInetUtils);
} }
threadPoolState.setClientAddress(clientAddress); threadPoolState.setClientAddress(clientAddress);
threadPoolState.setIdentify(IdentifyUtil.getIdentify()); threadPoolState.setIdentify(IdentifyUtil.getIdentify());

@ -55,7 +55,7 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner, ThreadPoolA
private final ConfigurableEnvironment environment; private final ConfigurableEnvironment environment;
private final InetUtils hippo4JInetUtils; private final InetUtils hippo4jInetUtils;
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
@ -76,7 +76,7 @@ public class ThreadPoolAdapterRegister implements ApplicationRunner, ThreadPoolA
String tenantItemKey = properties.getNamespace() + IDENTIFY_SLICER_SYMBOL + properties.getItemId(); String tenantItemKey = properties.getNamespace() + IDENTIFY_SLICER_SYMBOL + properties.getItemId();
cacheConfig.setTenantItemKey(tenantItemKey); cacheConfig.setTenantItemKey(tenantItemKey);
cacheConfig.setClientIdentify(IdentifyUtil.getIdentify()); cacheConfig.setClientIdentify(IdentifyUtil.getIdentify());
String clientAddress = CloudCommonIdUtil.getClientIpPort(environment, hippo4JInetUtils); String clientAddress = CloudCommonIdUtil.getClientIpPort(environment, hippo4jInetUtils);
cacheConfig.setClientAddress(clientAddress); cacheConfig.setClientAddress(clientAddress);
cacheConfig.setThreadPoolAdapterStates(threadPoolStates); cacheConfig.setThreadPoolAdapterStates(threadPoolStates);
adapterCacheConfigList.add(cacheConfig); adapterCacheConfigList.add(cacheConfig);

Loading…
Cancel
Save