Code optimization and logic refactoring (#909)

* Code optimization and logic refactoring

* Code optimization and logic refactoring

* Remove useless modules and refactor code

* Remove kafka modules

* Remove kafka code
pull/911/head
马称 Ma Chen 2 years ago committed by GitHub
parent e7863ac135
commit 4757e00c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class ThreadPoolAdapterBeanContainer implements InitializingBean { public class ThreadPoolAdapterBeanContainer implements InitializingBean {
/** /**
* Store three-party thread pool framework bean instances. * Store three-party thread pool framework bean instances
*/ */
public static final Map<String, ThreadPoolAdapter> THREAD_POOL_ADAPTER_BEAN_CONTAINER = new ConcurrentHashMap<>(); public static final Map<String, ThreadPoolAdapter> THREAD_POOL_ADAPTER_BEAN_CONTAINER = new ConcurrentHashMap<>();

@ -28,7 +28,7 @@ public interface ThreadPoolAdapterRegisterAction {
/** /**
* Get thread pool adapter cache configs. * Get thread pool adapter cache configs.
* *
* @param threadPoolAdapterMap * @param threadPoolAdapterMap thread-pool adapter map
* @return List<ThreadPoolAdapterCacheConfig> * @return List<ThreadPoolAdapterCacheConfig>
*/ */
List<ThreadPoolAdapterCacheConfig> getThreadPoolAdapterCacheConfigs(Map<String, ThreadPoolAdapter> threadPoolAdapterMap); List<ThreadPoolAdapterCacheConfig> getThreadPoolAdapterCacheConfigs(Map<String, ThreadPoolAdapter> threadPoolAdapterMap);
@ -36,8 +36,7 @@ public interface ThreadPoolAdapterRegisterAction {
/** /**
* Do register. * Do register.
* *
* @param cacheConfigList * @param cacheConfigList cache config list
* @return
*/ */
void doRegister(List<ThreadPoolAdapterCacheConfig> cacheConfigList); void doRegister(List<ThreadPoolAdapterCacheConfig> cacheConfigList);
} }

@ -18,6 +18,7 @@
package cn.hippo4j.adapter.hystrix; package cn.hippo4j.adapter.hystrix;
import cn.hippo4j.common.design.builder.ThreadFactoryBuilder; import cn.hippo4j.common.design.builder.ThreadFactoryBuilder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
@ -31,6 +32,7 @@ public class ThreadPoolAdapterScheduler {
private static final int TASK_INTERVAL_SECONDS = 10; private static final int TASK_INTERVAL_SECONDS = 10;
@Getter
private final ScheduledExecutorService scheduler; private final ScheduledExecutorService scheduler;
public ThreadPoolAdapterScheduler() { public ThreadPoolAdapterScheduler() {
@ -41,10 +43,11 @@ public class ThreadPoolAdapterScheduler {
.build()); .build());
} }
public ScheduledExecutorService getScheduler() { /**
return scheduler; * Gt task interval seconds.
} *
* @return task interval seconds
*/
public int getTaskIntervalSeconds() { public int getTaskIntervalSeconds() {
return TASK_INTERVAL_SECONDS; return TASK_INTERVAL_SECONDS;
} }

@ -1,18 +0,0 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-adapter</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-adapter-kafka</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-adapter-base</artifactId>
</dependency>
</dependencies>
</project>

@ -1,52 +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.adapter.kafka;
import cn.hippo4j.adapter.base.ThreadPoolAdapter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterParameter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
/**
* Kafka thread-pool adapter.
*/
@Slf4j
public class KafkaThreadPoolAdapter implements ThreadPoolAdapter, ApplicationListener<ApplicationStartedEvent> {
@Override
public String mark() {
return "Kafka";
}
@Override
public ThreadPoolAdapterState getThreadPoolState(String identify) {
return null;
}
@Override
public boolean updateThreadPool(ThreadPoolAdapterParameter threadPoolAdapterParameter) {
return false;
}
@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
}
}

@ -105,7 +105,6 @@ public class RabbitMQThreadPoolAdapter implements ThreadPoolAdapter, Application
log.warn("Custom thread pools only support ThreadPoolExecutor"); log.warn("Custom thread pools only support ThreadPoolExecutor");
} }
} }
}); });
} }
} }

@ -1,18 +0,0 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-adapter</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-adapter-spring-cloud-stream-kafka</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-adapter-base</artifactId>
</dependency>
</dependencies>
</project>

@ -1,59 +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.adapter.springcloud.stream.kafka;
import cn.hippo4j.adapter.base.ThreadPoolAdapter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterParameter;
import cn.hippo4j.adapter.base.ThreadPoolAdapterState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import java.util.List;
/**
* Spring cloud stream kafka thread-pool adapter.
*/
@Slf4j
public class SpringCloudStreamKafkaThreadPoolAdapter implements ThreadPoolAdapter, ApplicationListener<ApplicationStartedEvent> {
@Override
public String mark() {
return "KafkaSpringCloudStream";
}
@Override
public ThreadPoolAdapterState getThreadPoolState(String identify) {
return null;
}
@Override
public List<ThreadPoolAdapterState> getThreadPoolStates() {
return null;
}
@Override
public boolean updateThreadPool(ThreadPoolAdapterParameter threadPoolAdapterParameter) {
return false;
}
@Override
public void onApplicationEvent(ApplicationStartedEvent event) {
}
}

@ -39,7 +39,7 @@ import java.util.*;
import static cn.hippo4j.common.constant.ChangeThreadPoolConstants.CHANGE_DELIMITER; import static cn.hippo4j.common.constant.ChangeThreadPoolConstants.CHANGE_DELIMITER;
/** /**
* Spring cloud stream rabbimq thread-pool adapter. * Spring cloud stream rabbit-mq thread-pool adapter.
*/ */
@Slf4j @Slf4j
public class SpringCloudStreamRabbitMQThreadPoolAdapter implements ThreadPoolAdapter, ApplicationListener<ApplicationStartedEvent> { public class SpringCloudStreamRabbitMQThreadPoolAdapter implements ThreadPoolAdapter, ApplicationListener<ApplicationStartedEvent> {

@ -34,12 +34,12 @@ import java.util.concurrent.Executor;
public abstract class AbstractWebThreadPoolService implements WebThreadPoolService, ApplicationRunner { public abstract class AbstractWebThreadPoolService implements WebThreadPoolService, ApplicationRunner {
/** /**
* Thread pool executor. * Thread pool executor
*/ */
protected volatile Executor executor; protected volatile Executor executor;
/** /**
* Get web thread pool by server. * Get web thread pool by server
* *
* @param webServer * @param webServer
* @return * @return

@ -30,7 +30,7 @@ public class WebThreadPoolHandlerChoose {
/** /**
* Choose the web thread pool service bean. * Choose the web thread pool service bean.
* *
* @return * @return web thread pool service bean
*/ */
public WebThreadPoolService choose() { public WebThreadPoolService choose() {
WebThreadPoolService webThreadPoolService; WebThreadPoolService webThreadPoolService;

@ -35,9 +35,9 @@ public class WebThreadPoolRunStateHandler extends AbstractThreadPoolRuntime {
long used = MemoryUtil.heapMemoryUsed(); long used = MemoryUtil.heapMemoryUsed();
long max = MemoryUtil.heapMemoryMax(); long max = MemoryUtil.heapMemoryMax();
String memoryProportion = StringUtil.newBuilder( String memoryProportion = StringUtil.newBuilder(
"已分配: ", "Allocation: ",
ByteConvertUtil.getPrintSize(used), ByteConvertUtil.getPrintSize(used),
" / 最大可用: ", " / Maximum available: ",
ByteConvertUtil.getPrintSize(max)); ByteConvertUtil.getPrintSize(max));
poolRunStateInfo.setCurrentLoad(poolRunStateInfo.getCurrentLoad() + "%"); poolRunStateInfo.setCurrentLoad(poolRunStateInfo.getCurrentLoad() + "%");
poolRunStateInfo.setPeakLoad(poolRunStateInfo.getPeakLoad() + "%"); poolRunStateInfo.setPeakLoad(poolRunStateInfo.getPeakLoad() + "%");

@ -14,12 +14,10 @@
<module>hippo4j-adapter-base</module> <module>hippo4j-adapter-base</module>
<module>hippo4j-adapter-dubbo</module> <module>hippo4j-adapter-dubbo</module>
<module>hippo4j-adapter-alibaba-dubbo</module> <module>hippo4j-adapter-alibaba-dubbo</module>
<module>hippo4j-adapter-kafka</module>
<module>hippo4j-adapter-rabbitmq</module> <module>hippo4j-adapter-rabbitmq</module>
<module>hippo4j-adapter-rocketmq</module> <module>hippo4j-adapter-rocketmq</module>
<module>hippo4j-adapter-hystrix</module> <module>hippo4j-adapter-hystrix</module>
<module>hippo4j-adapter-spring-cloud-stream-rocketmq</module> <module>hippo4j-adapter-spring-cloud-stream-rocketmq</module>
<module>hippo4j-adapter-spring-cloud-stream-kafka</module>
<module>hippo4j-adapter-spring-cloud-stream-rabbitmq</module> <module>hippo4j-adapter-spring-cloud-stream-rabbitmq</module>
<module>hippo4j-adapter-web</module> <module>hippo4j-adapter-web</module>
</modules> </modules>

@ -1,56 +0,0 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-example</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-spring-boot-starter-adapter-kafka-example</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-spring-boot-starter-adapter-kafka</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-example-core</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
</dependencies>
</project>

@ -1,31 +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.springboot.starter.adapter.kafka.example;
import cn.hippo4j.core.enable.EnableDynamicThreadPool;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableDynamicThreadPool
public class ServerAdapterKafkaExampleApplication {
public static void main(String[] args) {
SpringApplication.run(ServerAdapterKafkaExampleApplication.class, args);
}
}

@ -1,43 +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.springboot.starter.adapter.kafka.example.consumer;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;
import java.util.Optional;
/**
* Kafka message consumer.
*/
@Slf4j
@Component
public class KafkaMessageConsumer {
@KafkaListener(topics = "kafka_message_hippo4j", groupId = "hippo4j")
public void onMessage(ConsumerRecord<?, ?> record, Acknowledgment ack, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
Optional message = Optional.ofNullable(record.value());
message.ifPresent(each -> log.info(each.toString()));
ack.acknowledge();
}
}

@ -1,55 +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.springboot.starter.adapter.kafka.example.produce;
import cn.hippo4j.common.toolkit.IdUtil;
import cn.hippo4j.common.toolkit.JSONUtil;
import cn.hippo4j.example.core.dto.SendMessageDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Kafka message produce.
*/
@Slf4j
@Component
@RestController
@AllArgsConstructor
public class KafkaMessageProduce {
private final KafkaTemplate kafkaTemplate;
private final String TOPIC = "kafka_message_hippo4j";
@GetMapping("/message/send")
public String sendMessage(Integer count) {
for (int i = 0; i < count; i++) {
String keys = IdUtil.randomUUID();
SendMessageDTO payload = SendMessageDTO.builder()
.receiver("156011xxx91")
.uid(keys)
.build();
kafkaTemplate.send(TOPIC, JSONUtil.toJSONString(payload));
}
return "success";
}
}

@ -1,23 +0,0 @@
server.port=8092
spring.profiles.active=dev
spring.dynamic.thread-pool.server-addr=http://localhost:6691
spring.dynamic.thread-pool.namespace=prescription
spring.dynamic.thread-pool.item-id=dynamic-threadpool-example
spring.dynamic.thread-pool.username=admin
spring.dynamic.thread-pool.password=123456
spring.kafka.bootstrap-servers=127.0.0.1:9092
spring.kafka.producer.retries=0
spring.kafka.producer.batch-size=16384
spring.kafka.producer.buffer-memory=33554432
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.acks=1
spring.kafka.consumer.auto-offset-reset=latest
spring.kafka.consumer.enable-auto-commit=false
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.listener.concurrency=2
spring.kafka.listener.ack-mode=manual_immediate
spring.kafka.listener.missing-topics-fatal=false

@ -21,7 +21,6 @@
<module>hippo4j-config-nacos-spring-boot-starter-example</module> <module>hippo4j-config-nacos-spring-boot-starter-example</module>
<module>hippo4j-config-apollo-spring-boot-starter-example</module> <module>hippo4j-config-apollo-spring-boot-starter-example</module>
<module>hippo4j-config-zookeeper-spring-boot-starter-example</module> <module>hippo4j-config-zookeeper-spring-boot-starter-example</module>
<module>hippo4j-spring-boot-starter-adapter-kafka-example</module>
<module>hippo4j-spring-boot-starter-adapter-rabbitmq-example</module> <module>hippo4j-spring-boot-starter-adapter-rabbitmq-example</module>
<module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example</module> <module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example</module>
<module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example</module> <module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example</module>

@ -72,7 +72,7 @@ public abstract class AbstractRobotSendMessageHandler implements SendMessageHand
} else { } else {
replaceTxt = ""; replaceTxt = "";
} }
alarmContentTxt = StringUtil.replace(alarmContentTxt, "${timout-content}", replaceTxt); alarmContentTxt = StringUtil.replace(alarmContentTxt, "${timeout-content}", replaceTxt);
String text = String.format( String text = String.format(
alarmContentTxt, alarmContentTxt,
alarmNotifyRequest.getActive(), alarmNotifyRequest.getActive(),

@ -18,7 +18,6 @@
package cn.hippo4j.message.service; package cn.hippo4j.message.service;
import cn.hippo4j.common.constant.Constants; import cn.hippo4j.common.constant.Constants;
import cn.hippo4j.common.toolkit.IdUtil;
import cn.hippo4j.common.toolkit.StringUtil; import cn.hippo4j.common.toolkit.StringUtil;
import cn.hippo4j.message.dto.AlarmControlDTO; import cn.hippo4j.message.dto.AlarmControlDTO;
import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Cache;
@ -58,8 +57,7 @@ public class AlarmControlHandler {
try { try {
pkId = cache.getIfPresent(alarmControl.getTypeEnum().name()); pkId = cache.getIfPresent(alarmControl.getTypeEnum().name());
if (StringUtil.isBlank(pkId)) { if (StringUtil.isBlank(pkId)) {
// Val meaningless. cache.put(alarmControl.getTypeEnum().name(), "-");
cache.put(alarmControl.getTypeEnum().name(), IdUtil.simpleUUID());
return true; return true;
} }
} finally { } finally {

@ -34,7 +34,7 @@
--- ---
${timout-content} ${timeout-content}
<font color=#708090 size=2>拒绝策略:%s</font> <font color=#708090 size=2>拒绝策略:%s</font>

@ -14,7 +14,7 @@
> 队列元素个数:%s > 队列元素个数:%s
> 队列剩余个数:%s > 队列剩余个数:%s
> 拒绝策略:%s > 拒绝策略:%s
> 拒绝策略执行次数:<font color='#FF0000'>%s</font> ${timout-content} > 拒绝策略执行次数:<font color='#FF0000'>%s</font> ${timeout-content}
> OWNER<@%s> > OWNER<@%s>
> 提示:%d 分钟内此线程池不会重复告警(可配置) > 提示:%d 分钟内此线程池不会重复告警(可配置)

@ -42,9 +42,6 @@ public abstract class AbstractDynamicThreadPoolMonitor implements DynamicThreadP
@Override @Override
public void collect() { public void collect() {
List<String> listDynamicThreadPoolId = GlobalThreadPoolManage.listThreadPoolId(); List<String> listDynamicThreadPoolId = GlobalThreadPoolManage.listThreadPoolId();
for (String each : listDynamicThreadPoolId) { listDynamicThreadPoolId.forEach(each -> execute(threadPoolRunStateHandler.getPoolRunState(each)));
ThreadPoolRunStateInfo poolRunState = threadPoolRunStateHandler.getPoolRunState(each);
execute(poolRunState);
}
} }
} }

@ -21,5 +21,4 @@ package cn.hippo4j.monitor.base;
* Adapter thread-pool monitor. * Adapter thread-pool monitor.
*/ */
public interface AdapterThreadPoolMonitor extends ThreadPoolMonitor { public interface AdapterThreadPoolMonitor extends ThreadPoolMonitor {
} }

@ -21,5 +21,4 @@ package cn.hippo4j.monitor.base;
* Dynamic thread-pool monitor. * Dynamic thread-pool monitor.
*/ */
public interface DynamicThreadPoolMonitor extends ThreadPoolMonitor { public interface DynamicThreadPoolMonitor extends ThreadPoolMonitor {
} }

@ -21,5 +21,4 @@ package cn.hippo4j.monitor.base;
* Web thread-pool monitor. * Web thread-pool monitor.
*/ */
public interface WebThreadPoolMonitor extends ThreadPoolMonitor { public interface WebThreadPoolMonitor extends ThreadPoolMonitor {
} }

@ -46,10 +46,10 @@ public class AdapterThreadPoolMicrometerMonitorHandler extends AbstractAdapterTh
@Override @Override
protected void execute(ThreadPoolAdapterState threadPoolAdapterState) { protected void execute(ThreadPoolAdapterState threadPoolAdapterState) {
ThreadPoolAdapterState stateInfo = RUN_STATE_CACHE.get(threadPoolAdapterState.getThreadPoolKey()); ThreadPoolAdapterState stateInfo = RUN_STATE_CACHE.get(threadPoolAdapterState.getThreadPoolKey());
if (stateInfo == null) { if (stateInfo != null) {
RUN_STATE_CACHE.put(threadPoolAdapterState.getThreadPoolKey(), threadPoolAdapterState);
} else {
BeanUtil.convert(threadPoolAdapterState, stateInfo); BeanUtil.convert(threadPoolAdapterState, stateInfo);
} else {
RUN_STATE_CACHE.put(threadPoolAdapterState.getThreadPoolKey(), threadPoolAdapterState);
} }
Environment environment = ApplicationContextHolder.getInstance().getEnvironment(); Environment environment = ApplicationContextHolder.getInstance().getEnvironment();
String applicationName = environment.getProperty("spring.application.name", "application"); String applicationName = environment.getProperty("spring.application.name", "application");

@ -46,10 +46,10 @@ public class DynamicThreadPoolMicrometerMonitorHandler extends AbstractDynamicTh
@Override @Override
protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) { protected void execute(ThreadPoolRunStateInfo poolRunStateInfo) {
ThreadPoolRunStateInfo stateInfo = RUN_STATE_CACHE.get(poolRunStateInfo.getTpId()); ThreadPoolRunStateInfo stateInfo = RUN_STATE_CACHE.get(poolRunStateInfo.getTpId());
if (stateInfo == null) { if (stateInfo != null) {
RUN_STATE_CACHE.put(poolRunStateInfo.getTpId(), poolRunStateInfo);
} else {
BeanUtil.convert(poolRunStateInfo, stateInfo); BeanUtil.convert(poolRunStateInfo, stateInfo);
} else {
RUN_STATE_CACHE.put(poolRunStateInfo.getTpId(), poolRunStateInfo);
} }
Environment environment = ApplicationContextHolder.getInstance().getEnvironment(); Environment environment = ApplicationContextHolder.getInstance().getEnvironment();
String applicationName = environment.getProperty("spring.application.name", "application"); String applicationName = environment.getProperty("spring.application.name", "application");

@ -46,10 +46,10 @@ public class WebThreadPoolMicrometerMonitorHandler extends AbstractWebThreadPool
Environment environment = ApplicationContextHolder.getInstance().getEnvironment(); Environment environment = ApplicationContextHolder.getInstance().getEnvironment();
String applicationName = environment.getProperty("spring.application.name", "application"); String applicationName = environment.getProperty("spring.application.name", "application");
ThreadPoolRunStateInfo stateInfo = RUN_STATE_CACHE.get(applicationName); ThreadPoolRunStateInfo stateInfo = RUN_STATE_CACHE.get(applicationName);
if (stateInfo == null) { if (stateInfo != null) {
RUN_STATE_CACHE.put(applicationName, webThreadPoolRunStateInfo);
} else {
BeanUtil.convert(webThreadPoolRunStateInfo, stateInfo); BeanUtil.convert(webThreadPoolRunStateInfo, stateInfo);
} else {
RUN_STATE_CACHE.put(applicationName, webThreadPoolRunStateInfo);
} }
Iterable<Tag> tags = CollectionUtil.newArrayList(Tag.of(APPLICATION_NAME_TAG, applicationName)); Iterable<Tag> tags = CollectionUtil.newArrayList(Tag.of(APPLICATION_NAME_TAG, applicationName));
Metrics.gauge(metricName("current.load"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getSimpleCurrentLoad); Metrics.gauge(metricName("current.load"), tags, webThreadPoolRunStateInfo, ThreadPoolRunStateInfo::getSimpleCurrentLoad);

@ -23,7 +23,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* * Filter config.
*/ */
@Configuration @Configuration
public class FilterConfig { public class FilterConfig {

@ -68,14 +68,12 @@ public class JWTAuthorizationFilter extends BasicAuthenticationFilter {
chain.doFilter(request, response); chain.doFilter(request, response);
return; return;
} }
// If there is no Authorization information in the request header, it will be released directly. // If there is no Authorization information in the request header, it will be released directly.
String tokenHeader = request.getHeader(JwtTokenUtil.TOKEN_HEADER); String tokenHeader = request.getHeader(JwtTokenUtil.TOKEN_HEADER);
if (tokenHeader == null || !tokenHeader.startsWith(JwtTokenUtil.TOKEN_PREFIX)) { if (tokenHeader == null || !tokenHeader.startsWith(JwtTokenUtil.TOKEN_PREFIX)) {
chain.doFilter(request, response); chain.doFilter(request, response);
return; return;
} }
// If there is a Token in the request header, it is parsed and the authentication information is set. // If there is a Token in the request header, it is parsed and the authentication information is set.
try { try {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(tokenHeader)); SecurityContextHolder.getContext().setAuthentication(getAuthentication(tokenHeader));

@ -41,15 +41,30 @@ import static cn.hippo4j.common.constant.Constants.AUTHORITIES_KEY;
@Component @Component
public class JwtTokenManager { public class JwtTokenManager {
/**
* Create token.
*
* @param userName user-name
* @return new token
*/
public String createToken(String userName) { public String createToken(String userName) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
Date validity; Date validity;
validity = new Date(now + TOKEN_VALIDITY_IN_SECONDS * 1000L); validity = new Date(now + TOKEN_VALIDITY_IN_SECONDS * 1000L);
Claims claims = Jwts.claims().setSubject(userName); Claims claims = Jwts.claims().setSubject(userName);
return Jwts.builder().setClaims(claims).setExpiration(validity) String token = Jwts.builder()
.signWith(SignatureAlgorithm.HS512, SECRET).compact(); .setClaims(claims)
.setExpiration(validity)
.signWith(SignatureAlgorithm.HS512, SECRET)
.compact();
return token;
} }
/**
* Validate token.
*
* @param token token
*/
public void validateToken(String token) { public void validateToken(String token) {
Jwts.parser().setSigningKey(SECRET).parseClaimsJws(token); Jwts.parser().setSigningKey(SECRET).parseClaimsJws(token);
} }

@ -22,7 +22,6 @@ import cn.hippo4j.auth.model.UserInfo;
import cn.hippo4j.auth.model.biz.user.UserQueryPageReqDTO; import cn.hippo4j.auth.model.biz.user.UserQueryPageReqDTO;
import cn.hippo4j.auth.model.biz.user.UserReqDTO; import cn.hippo4j.auth.model.biz.user.UserReqDTO;
import cn.hippo4j.auth.model.biz.user.UserRespDTO; import cn.hippo4j.auth.model.biz.user.UserRespDTO;
import cn.hippo4j.auth.service.RoleService;
import cn.hippo4j.auth.service.UserService; import cn.hippo4j.auth.service.UserService;
import cn.hippo4j.common.toolkit.BeanUtil; import cn.hippo4j.common.toolkit.BeanUtil;
import cn.hippo4j.common.toolkit.StringUtil; import cn.hippo4j.common.toolkit.StringUtil;
@ -49,8 +48,6 @@ public class UserServiceImpl implements UserService {
private final UserMapper userMapper; private final UserMapper userMapper;
private final RoleService roleService;
private final BCryptPasswordEncoder bCryptPasswordEncoder; private final BCryptPasswordEncoder bCryptPasswordEncoder;
@Override @Override

@ -36,9 +36,11 @@ import static cn.hippo4j.common.constant.Constants.MAP_INITIAL_CAPACITY;
public class JwtTokenUtil { public class JwtTokenUtil {
public static final String TOKEN_HEADER = "Authorization"; public static final String TOKEN_HEADER = "Authorization";
public static final String TOKEN_PREFIX = "Bearer "; public static final String TOKEN_PREFIX = "Bearer ";
public static final String SECRET = "SecretKey039245678901232039487623456783092349288901402967890140939827"; public static final String SECRET = "SecretKey039245678901232039487623456783092349288901402967890140939827";
public static final String ISS = "admin"; public static final String ISS = "admin";
/** /**

@ -32,13 +32,17 @@ public class ReturnT<T> implements Serializable {
public static final long serialVersionUID = 42L; public static final long serialVersionUID = 42L;
public static final int SUCCESS_CODE = 200; public static final int SUCCESS_CODE = 200;
public static final int FAIL_CODE = 500; public static final int FAIL_CODE = 500;
public static final ReturnT<String> SUCCESS = new ReturnT<>(null); public static final ReturnT<String> SUCCESS = new ReturnT<>(null);
public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, null); public static final ReturnT<String> FAIL = new ReturnT<>(FAIL_CODE, null);
private int code; private int code;
private String msg; private String msg;
private T content; private T content;
public ReturnT(int code, String msg) { public ReturnT(int code, String msg) {

@ -1,44 +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.config.event;
import org.springframework.util.StringUtils;
/**
* Config data change event.
*/
public class ConfigDataChangeEvent extends AbstractEvent {
public final String tenantId;
public final String itemId;
public final String tpId;
public final long lastModifiedTs;
public ConfigDataChangeEvent(String tenantId, String itemId, String tpId, Long gmtModified) {
if (StringUtils.isEmpty(tenantId) || StringUtils.isEmpty(itemId) || StringUtils.isEmpty(tpId)) {
throw new IllegalArgumentException("DataId is null or group is null");
}
this.tenantId = tenantId;
this.itemId = itemId;
this.tpId = tpId;
this.lastModifiedTs = gmtModified;
}
}

@ -27,14 +27,14 @@ public abstract class AbstractMonitorDataExecuteStrategy<T extends Message> {
/** /**
* Mark. * Mark.
* *
* @return * @return mark
*/ */
public abstract String mark(); public abstract String mark();
/** /**
* Execute. * Execute.
* *
* @param message * @param message message
*/ */
public abstract void execute(T message); public abstract void execute(T message);
} }

@ -33,7 +33,7 @@ import java.util.Map;
public class QueryMonitorExecuteChoose implements CommandLineRunner { public class QueryMonitorExecuteChoose implements CommandLineRunner {
/** /**
* Storage monitoring data execution container. * Storage monitoring data execution container
*/ */
private Map<String, AbstractMonitorDataExecuteStrategy> monitorDataExecuteStrategyChooseMap = new HashMap<>(); private Map<String, AbstractMonitorDataExecuteStrategy> monitorDataExecuteStrategyChooseMap = new HashMap<>();

@ -63,7 +63,6 @@ public class DefaultPublisher extends Thread implements EventPublisher {
@Override @Override
public synchronized void start() { public synchronized void start() {
if (!initialized) { if (!initialized) {
// start just called once
super.start(); super.start();
if (queueMaxSize == -1) { if (queueMaxSize == -1) {
queueMaxSize = NotifyCenter.ringBufferSize; queueMaxSize = NotifyCenter.ringBufferSize;
@ -100,7 +99,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence())); UPDATER.compareAndSet(this, lastEventSequence, Math.max(lastEventSequence, event.sequence()));
} }
} catch (Throwable ex) { } catch (Throwable ex) {
log.error("Event listener exception: {}", ex); log.error("Event listener exception.", ex);
} }
} }
@ -123,9 +122,7 @@ public class DefaultPublisher extends Thread implements EventPublisher {
@Override @Override
public void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event) { public void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event) {
final Runnable job = () -> subscriber.onEvent(event); final Runnable job = () -> subscriber.onEvent(event);
final Executor executor = subscriber.executor(); final Executor executor = subscriber.executor();
if (executor != null) { if (executor != null) {
executor.execute(job); executor.execute(job);
} else { } else {

@ -28,31 +28,31 @@ public interface EventPublisher {
/** /**
* Init. * Init.
* *
* @param type * @param type type
* @param bufferSize * @param bufferSize buffer size
*/ */
void init(Class<? extends AbstractEvent> type, int bufferSize); void init(Class<? extends AbstractEvent> type, int bufferSize);
/** /**
* Add subscriber. * Add subscriber.
* *
* @param subscriber * @param subscriber subscriber
*/ */
void addSubscriber(AbstractSubscriber subscriber); void addSubscriber(AbstractSubscriber subscriber);
/** /**
* Publish. * Publish.
* *
* @param event * @param event event
* @return * @return publish result
*/ */
boolean publish(AbstractEvent event); boolean publish(AbstractEvent event);
/** /**
* Notify subscriber. * Notify subscriber.
* *
* @param subscriber * @param subscriber subscriber
* @param event * @param event event
*/ */
void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event); void notifySubscriber(AbstractSubscriber subscriber, AbstractEvent event);
} }

@ -43,11 +43,9 @@ public class NotifyCenter {
private DefaultSharePublisher sharePublisher; private DefaultSharePublisher sharePublisher;
private static Class<? extends EventPublisher> clazz = null;
private static EventPublisher eventPublisher = new DefaultPublisher(); private static EventPublisher eventPublisher = new DefaultPublisher();
private static BiFunction<Class<? extends AbstractEvent>, Integer, EventPublisher> publisherFactory = null; private static BiFunction<Class<? extends AbstractEvent>, Integer, EventPublisher> publisherFactory;
private final Map<String, EventPublisher> publisherMap = new ConcurrentHashMap(16); private final Map<String, EventPublisher> publisherMap = new ConcurrentHashMap(16);

@ -40,6 +40,11 @@ public abstract class AbstractSubscriber<T extends AbstractEvent> {
*/ */
public abstract Class<? extends AbstractEvent> subscribeType(); public abstract Class<? extends AbstractEvent> subscribeType();
/**
* Executor.
*
* @return executor
*/
public Executor executor() { public Executor executor() {
return null; return null;
} }

@ -28,7 +28,7 @@ public class ConfigChangePublisher {
/** /**
* Notify configChange. * Notify configChange.
* *
* @param event * @param event event
*/ */
public static void notifyConfigChange(LocalDataChangeEvent event) { public static void notifyConfigChange(LocalDataChangeEvent event) {
NotifyCenter.publishEvent(event); NotifyCenter.publishEvent(event);

@ -68,13 +68,9 @@ public class LongPollingService {
@Override @Override
public void onEvent(AbstractEvent event) { public void onEvent(AbstractEvent event) {
if (isFixedPolling()) { if (!isFixedPolling() && event instanceof LocalDataChangeEvent) {
// Ignore. LocalDataChangeEvent evt = (LocalDataChangeEvent) event;
} else { ConfigExecutor.executeLongPolling(new DataChangeTask(evt.identify, evt.groupKey));
if (event instanceof LocalDataChangeEvent) {
LocalDataChangeEvent evt = (LocalDataChangeEvent) event;
ConfigExecutor.executeLongPolling(new DataChangeTask(evt.identify, evt.groupKey));
}
} }
} }
@ -300,11 +296,11 @@ public class LongPollingService {
/** /**
* Is support long polling. * Is support long polling.
* *
* @param req * @param request
* @return * @return
*/ */
public static boolean isSupportLongPolling(HttpServletRequest req) { public static boolean isSupportLongPolling(HttpServletRequest request) {
return null != req.getHeader(LONG_POLLING_HEADER); return request.getHeader(LONG_POLLING_HEADER) != null;
} }
/** /**

@ -33,7 +33,7 @@ import java.util.Map;
public class ConfigModificationVerifyServiceChoose implements CommandLineRunner { public class ConfigModificationVerifyServiceChoose implements CommandLineRunner {
/** /**
* Storage config change verify service container. * Storage config change verify service container
*/ */
private Map<Integer, ConfigModificationVerifyService> configChangeVerifyServiceChooseMap = new HashMap<>(); private Map<Integer, ConfigModificationVerifyService> configChangeVerifyServiceChooseMap = new HashMap<>();
@ -44,8 +44,7 @@ public class ConfigModificationVerifyServiceChoose implements CommandLineRunner
* @return * @return
*/ */
public ConfigModificationVerifyService choose(Integer type) { public ConfigModificationVerifyService choose(Integer type) {
ConfigModificationVerifyService verifyService = configChangeVerifyServiceChooseMap.get(type); return configChangeVerifyServiceChooseMap.get(type);
return verifyService;
} }
@Override @Override

@ -17,32 +17,19 @@
package cn.hippo4j.discovery.core; package cn.hippo4j.discovery.core;
import lombok.Getter;
/** /**
* Lease. * Lease.
*/ */
public class Lease<T> { public class Lease<T> {
enum Action {
/**
* REGISTER
*/
REGISTER,
/**
* CANCEL
*/
CANCEL,
/**
* RENEW
*/
RENEW
}
private T holder; private T holder;
@Getter
private long evictionTimestamp; private long evictionTimestamp;
@Getter
private long registrationTimestamp; private long registrationTimestamp;
private long serviceUpTimestamp; private long serviceUpTimestamp;
@ -50,6 +37,7 @@ public class Lease<T> {
/** /**
* Make it volatile so that the expiration task would see this quicker * Make it volatile so that the expiration task would see this quicker
*/ */
@Getter
private volatile long lastUpdateTimestamp; private volatile long lastUpdateTimestamp;
private long duration; private long duration;
@ -91,18 +79,6 @@ public class Lease<T> {
return (evictionTimestamp > 0 || System.currentTimeMillis() > (lastUpdateTimestamp + additionalLeaseMs)); return (evictionTimestamp > 0 || System.currentTimeMillis() > (lastUpdateTimestamp + additionalLeaseMs));
} }
public long getRegistrationTimestamp() {
return registrationTimestamp;
}
public long getLastRenewalTimestamp() {
return lastUpdateTimestamp;
}
public long getEvictionTimestamp() {
return evictionTimestamp;
}
public long getServiceUpTimestamp() { public long getServiceUpTimestamp() {
return serviceUpTimestamp; return serviceUpTimestamp;
} }

@ -215,8 +215,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -215,8 +215,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -215,8 +215,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -227,8 +227,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -214,8 +214,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -215,8 +215,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -214,8 +214,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -215,8 +215,6 @@ export default {
runTimeTemp: {}, runTimeTemp: {},
typeOptions: [ typeOptions: [
{ key: 'Dubbo', display_name: 'Dubbo' }, { key: 'Dubbo', display_name: 'Dubbo' },
{ key: 'Kafka', display_name: 'Kafka' },
{ key: 'KafkaSpringCloudStream', display_name: 'KafkaSpringCloudStream' },
{ key: 'RocketMQ', display_name: 'RocketMQ' }, { key: 'RocketMQ', display_name: 'RocketMQ' },
{ key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' }, { key: 'RocketMQSpringCloudStream', display_name: 'RocketMQSpringCloudStream' },
{ key: 'RabbitMQ', display_name: 'RabbitMQ' }, { key: 'RabbitMQ', display_name: 'RabbitMQ' },

@ -1,19 +0,0 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-spring-boot-starter-adapter</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-spring-boot-starter-adapter-kafka</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-adapter-kafka</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</project>

@ -1,45 +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.springboot.starter.adapter.kafka;
import cn.hippo4j.adapter.kafka.KafkaThreadPoolAdapter;
import cn.hippo4j.common.config.ApplicationContextHolder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Kafka adapter auto configuration.
*/
@Configuration
public class KafkaAdapterAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ApplicationContextHolder simpleApplicationContextHolder() {
return new ApplicationContextHolder();
}
@Bean
@SuppressWarnings("all")
@ConditionalOnProperty(name = "spring.kafka.bootstrap-servers")
public KafkaThreadPoolAdapter kafkaMQThreadPoolAdapter(ApplicationContextHolder applicationContextHolder) {
return new KafkaThreadPoolAdapter();
}
}

@ -1 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.adapter.kafka.KafkaAdapterAutoConfiguration

@ -1,19 +0,0 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-spring-boot-starter-adapter</artifactId>
<version>${revision}</version>
</parent>
<artifactId>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-kafka</artifactId>
<dependencies>
<dependency>
<groupId>cn.hippo4j</groupId>
<artifactId>hippo4j-adapter-spring-cloud-stream-kafka</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</project>

@ -1,45 +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.springboot.starter.adapter.springcloud.stream.kafka;
import cn.hippo4j.adapter.springcloud.stream.kafka.SpringCloudStreamKafkaThreadPoolAdapter;
import cn.hippo4j.common.config.ApplicationContextHolder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Spring cloud stream kafka adapter auto configuration.
*/
@Configuration
public class SpringCloudStreamKafkaAdapterAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ApplicationContextHolder simpleApplicationContextHolder() {
return new ApplicationContextHolder();
}
@Bean
@SuppressWarnings("all")
@ConditionalOnProperty(name = "xxx")
public SpringCloudStreamKafkaThreadPoolAdapter springCloudStreamKafkaThreadPoolAdapter(ApplicationContextHolder applicationContextHolder) {
return new SpringCloudStreamKafkaThreadPoolAdapter();
}
}

@ -1 +0,0 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.springboot.starter.adapter.springcloud.stream.kafka.SpringCloudStreamKafkaAdapterAutoConfiguration

@ -14,11 +14,9 @@
<module>hippo4j-spring-boot-starter-adapter-all</module> <module>hippo4j-spring-boot-starter-adapter-all</module>
<module>hippo4j-spring-boot-starter-adapter-dubbo</module> <module>hippo4j-spring-boot-starter-adapter-dubbo</module>
<module>hippo4j-spring-boot-starter-adapter-alibaba-dubbo</module> <module>hippo4j-spring-boot-starter-adapter-alibaba-dubbo</module>
<module>hippo4j-spring-boot-starter-adapter-kafka</module>
<module>hippo4j-spring-boot-starter-adapter-rabbitmq</module> <module>hippo4j-spring-boot-starter-adapter-rabbitmq</module>
<module>hippo4j-spring-boot-starter-adapter-rocketmq</module> <module>hippo4j-spring-boot-starter-adapter-rocketmq</module>
<module>hippo4j-spring-boot-starter-adapter-hystrix</module> <module>hippo4j-spring-boot-starter-adapter-hystrix</module>
<module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-kafka</module>
<module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq</module> <module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq</module>
<module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq</module> <module>hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq</module>
<module>hippo4j-spring-boot-starter-adapter-web</module> <module>hippo4j-spring-boot-starter-adapter-web</module>

Loading…
Cancel
Save