├── hippo4j-console ├── src │ └── main │ │ ├── resources │ │ └── static │ │ │ ├── static │ │ │ ├── css │ │ │ │ ├── chunk-434632c4.adc5827d.css │ │ │ │ ├── chunk-45e73af7.13821f5e.css │ │ │ │ ├── chunk-003006fa.6d24dacd.css │ │ │ │ ├── chunk-0a5b5b6f.6d24dacd.css │ │ │ │ ├── chunk-0c349c3a.9905f991.css │ │ │ │ ├── chunk-22d8af12.6d24dacd.css │ │ │ │ ├── chunk-648295c6.6d24dacd.css │ │ │ │ ├── chunk-7b4c55c2.9905f991.css │ │ │ │ └── chunk-e25b23da.6d24dacd.css │ │ │ ├── img │ │ │ │ ├── 401.089007e7.gif │ │ │ │ ├── 404.a57b6f31.png │ │ │ │ ├── hippo4j.ecba1844.gif │ │ │ │ └── 404_cloud.0f4bc32b.png │ │ │ ├── fonts │ │ │ │ ├── element-icons.732389de.ttf │ │ │ │ └── element-icons.535877f5.woff │ │ │ └── js │ │ │ │ ├── chunk-2d230fe7.19def69d.js │ │ │ │ ├── chunk-04a4268a.c9a819e9.js │ │ │ │ ├── chunk-434632c4.a264a0ed.js │ │ │ │ └── chunk-91584750.a58b5769.js │ │ │ ├── favicon.ico │ │ │ └── hippo4j.gif │ │ └── java │ │ └── cn │ │ └── hippo4j │ │ └── console │ │ ├── service │ │ ├── DashboardService.java │ │ └── impl │ │ │ └── DashboardServiceImpl.java │ │ ├── model │ │ ├── ThreadPoolInstanceInfo.java │ │ └── ChartInfo.java │ │ ├── config │ │ ├── WebConfig.java │ │ └── GlobalExceptionHandler.java │ │ └── controller │ │ ├── DashboardController.java │ │ ├── LogRecordController.java │ │ ├── PermissionController.java │ │ └── RoleController.java ├── .gitignore └── pom.xml ├── hippo4j-spring-boot-starter ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ ├── spring.factories │ │ │ └── additional-spring-configuration-metadata.json │ │ └── java │ │ └── cn │ │ └── hippo4j │ │ └── starter │ │ ├── core │ │ ├── ThreadPoolSubscribeCallback.java │ │ ├── ConfigAdapter.java │ │ ├── ConfigEmptyException.java │ │ ├── DynamicThreadPool.java │ │ ├── Listener.java │ │ ├── ConfigService.java │ │ ├── ConfigEmptyAnalyzer.java │ │ ├── ThreadPoolConfigService.java │ │ ├── ThreadPoolOperation.java │ │ └── GlobalThreadPoolManage.java │ │ ├── toolkit │ │ ├── CalculateUtil.java │ │ ├── thread │ │ │ ├── Builder.java │ │ │ ├── ResizableCapacityLinkedBlockIngQueue.java │ │ │ ├── RejectedPolicies.java │ │ │ └── TaskQueue.java │ │ ├── ByteConvertUtil.java │ │ ├── ArrayUtil.java │ │ └── CloudCommonIdUtil.java │ │ ├── alarm │ │ ├── NotifyPlatformEnum.java │ │ ├── MessageTypeEnum.java │ │ ├── NotifyConfig.java │ │ ├── ThreadPoolAlarm.java │ │ ├── SendMessageService.java │ │ ├── AlarmControlDTO.java │ │ ├── SendMessageHandler.java │ │ ├── NotifyDTO.java │ │ ├── lark │ │ │ └── LarkAlarmConstants.java │ │ └── AlarmControlHandler.java │ │ ├── spi │ │ ├── ServiceLoaderInstantiationException.java │ │ ├── CustomBlockingQueue.java │ │ ├── CustomRejectedExecutionHandler.java │ │ └── DynamicTpServiceLoader.java │ │ ├── enable │ │ ├── EnableDynamicThreadPool.java │ │ └── MarkerConfiguration.java │ │ ├── wrapper │ │ └── ManagerListenerWrapper.java │ │ ├── config │ │ ├── UtilAutoConfiguration.java │ │ ├── BootstrapProperties.java │ │ └── CorsConfig.java │ │ ├── controller │ │ └── PoolRunStateController.java │ │ ├── event │ │ └── EventExecutor.java │ │ └── common │ │ └── CommonDynamicThreadPool.java └── .gitignore ├── hippo4j-tools ├── log-record-tool │ ├── src │ │ ├── test │ │ │ └── java │ │ │ │ └── cn │ │ │ │ └── hippo4j │ │ │ │ └── tools │ │ │ │ └── logrecord │ │ │ │ └── LogRecordToolApplicationTests.java │ │ └── main │ │ │ └── java │ │ │ └── cn │ │ │ └── hippo4j │ │ │ └── tools │ │ │ └── logrecord │ │ │ ├── annotation │ │ │ ├── LogField.java │ │ │ └── LogRecord.java │ │ │ ├── enums │ │ │ └── LogRecordTypeEnum.java │ │ │ ├── service │ │ │ ├── OperatorGetService.java │ │ │ ├── LogRecordService.java │ │ │ ├── impl │ │ │ │ ├── DefaultOperatorGetServiceImpl.java │ │ │ │ ├── DefaultLogRecordServiceImpl.java │ │ │ │ ├── DefaultParseFunction.java │ │ │ │ ├── DefaultFunctionServiceImpl.java │ │ │ │ └── ParseFunctionFactory.java │ │ │ ├── FunctionService.java │ │ │ └── ParseFunction.java │ │ │ ├── model │ │ │ ├── Operator.java │ │ │ ├── MethodExecuteResult.java │ │ │ ├── LogRecordOps.java │ │ │ └── LogRecordInfo.java │ │ │ ├── compare │ │ │ └── Equator.java │ │ │ ├── parse │ │ │ └── LogRecordEvaluationContext.java │ │ │ └── context │ │ │ └── LogRecordContext.java │ └── .gitignore ├── open-change-tool │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── cn │ │ │ └── hippo4j │ │ │ └── tools │ │ │ └── openchange │ │ │ ├── EnableOpenChangeNotify.java │ │ │ ├── GitHubRemote.java │ │ │ ├── OpenChangeNotifyConfig.java │ │ │ ├── OpenChangeInfo.java │ │ │ └── OpenChangeNotifyBootstrapProperties.java │ └── .gitignore ├── .gitignore └── pom.xml ├── hippo4j-example ├── src │ ├── test │ │ └── java │ │ │ └── cn │ │ │ └── hippo4j │ │ │ └── example │ │ │ └── ExampleApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.yaml │ │ └── java │ │ └── cn │ │ └── hippo4j │ │ └── example │ │ ├── constant │ │ └── GlobalTestConstant.java │ │ ├── ExampleApplication.java │ │ └── inittest │ │ └── AlarmSendMessageTest.java └── .gitignore ├── hippo4j-common ├── src │ └── main │ │ └── java │ │ └── cn │ │ └── hippo4j │ │ └── common │ │ ├── function │ │ └── NoArgsConsumer.java │ │ ├── toolkit │ │ ├── UserContext.java │ │ ├── ConditionUtil.java │ │ └── GroupKey.java │ │ ├── web │ │ ├── base │ │ │ ├── Result.java │ │ │ └── Results.java │ │ └── exception │ │ │ ├── ServiceException.java │ │ │ └── ErrorCodeEnum.java │ │ ├── executor │ │ └── ExecutorFactory.java │ │ └── model │ │ ├── GlobalRemotePoolInfo.java │ │ ├── PoolParameter.java │ │ └── PoolParameterInfo.java └── .gitignore ├── hippo4j-config ├── src │ └── main │ │ └── java │ │ └── cn │ │ └── hippo4j │ │ └── config │ │ ├── event │ │ ├── SlowEvent.java │ │ ├── LocalDataChangeEvent.java │ │ ├── Event.java │ │ └── ConfigDataChangeEvent.java │ │ ├── model │ │ ├── ConfigInfo.java │ │ ├── biz │ │ │ ├── item │ │ │ │ ├── ItemUpdateReqDTO.java │ │ │ │ ├── ItemQueryReqDTO.java │ │ │ │ ├── ItemSaveReqDTO.java │ │ │ │ └── ItemRespDTO.java │ │ │ ├── threadpool │ │ │ │ ├── ThreadPoolDelReqDTO.java │ │ │ │ ├── ThreadPoolQueryReqDTO.java │ │ │ │ ├── ThreadPoolSaveOrUpdateReqDTO.java │ │ │ │ └── ThreadPoolRespDTO.java │ │ │ ├── log │ │ │ │ ├── LogRecordQueryReqDTO.java │ │ │ │ └── LogRecordRespDTO.java │ │ │ ├── notify │ │ │ │ ├── NotifyListRespDTO.java │ │ │ │ ├── NotifyQueryReqDTO.java │ │ │ │ ├── NotifyReqDTO.java │ │ │ │ └── NotifyRespDTO.java │ │ │ └── tenant │ │ │ │ ├── TenantQueryReqDTO.java │ │ │ │ ├── TenantSaveReqDTO.java │ │ │ │ ├── TenantUpdateReqDTO.java │ │ │ │ └── TenantRespDTO.java │ │ ├── TenantInfo.java │ │ ├── ItemInfo.java │ │ ├── CacheItem.java │ │ ├── ConfigAllInfo.java │ │ └── NotifyInfo.java │ │ ├── mapper │ │ ├── ItemInfoMapper.java │ │ ├── NotifyInfoMapper.java │ │ ├── TenantInfoMapper.java │ │ ├── ConfigInfoMapper.java │ │ └── LogRecordMapper.java │ │ ├── notify │ │ ├── listener │ │ │ ├── SmartSubscriber.java │ │ │ └── Subscriber.java │ │ ├── EventPublisher.java │ │ └── DefaultSharePublisher.java │ │ ├── config │ │ ├── CommonConfig.java │ │ ├── MybatisPlusConfig.java │ │ └── MyMetaObjectHandler.java │ │ ├── service │ │ ├── ConfigChangePublisher.java │ │ ├── biz │ │ │ ├── LogRecordBizService.java │ │ │ ├── ConfigService.java │ │ │ ├── impl │ │ │ │ ├── LogRecordServiceImpl.java │ │ │ │ └── LogRecordBizServiceImpl.java │ │ │ ├── NotifyService.java │ │ │ ├── TenantService.java │ │ │ ├── ItemService.java │ │ │ └── ThreadPoolService.java │ │ ├── handler │ │ │ ├── CustomOperatorGetServiceImpl.java │ │ │ └── TenantIdFunctionServiceImpl.java │ │ ├── ConfigServletInner.java │ │ └── SwitchService.java │ │ ├── toolkit │ │ ├── ClassUtil.java │ │ ├── SimpleReadWriteLock.java │ │ ├── SingletonRepository.java │ │ ├── RequestUtil.java │ │ ├── ConfigExecutor.java │ │ └── BeanUtil.java │ │ └── enums │ │ └── DelEnum.java └── .gitignore ├── hippo4j-auth ├── src │ └── main │ │ └── java │ │ └── cn │ │ └── hippo4j │ │ └── auth │ │ ├── constant │ │ └── Constants.java │ │ ├── mapper │ │ ├── RoleMapper.java │ │ ├── UserMapper.java │ │ └── PermissionMapper.java │ │ ├── model │ │ ├── biz │ │ │ ├── role │ │ │ │ ├── RoleRespDTO.java │ │ │ │ └── RoleQueryPageReqDTO.java │ │ │ ├── user │ │ │ │ ├── UserQueryPageReqDTO.java │ │ │ │ ├── LoginUser.java │ │ │ │ ├── UserReqDTO.java │ │ │ │ ├── UserRespDTO.java │ │ │ │ └── JwtUser.java │ │ │ └── permission │ │ │ │ ├── PermissionQueryPageReqDTO.java │ │ │ │ └── PermissionRespDTO.java │ │ ├── RoleInfo.java │ │ ├── UserInfo.java │ │ └── PermissionInfo.java │ │ ├── service │ │ ├── PermissionService.java │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ │ └── UserDetailsServiceImpl.java │ │ └── toolkit │ │ └── ReturnT.java └── .gitignore ├── hippo4j-server ├── bin │ ├── shutdown.cmd │ ├── shutdown.sh │ └── startup.cmd ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── cn │ │ │ └── hippo4j │ │ │ └── server │ │ │ └── ServerApplication.java │ │ └── resources │ │ └── application.properties ├── conf │ └── application.properties └── pom.xml ├── .gitignore └── hippo4j-discovery ├── .gitignore ├── src └── main │ └── java │ └── cn │ └── hippo4j │ └── discovery │ ├── config │ └── RegistryConfiguration.java │ └── core │ ├── Pair.java │ ├── InstanceRegistry.java │ └── StatusOverrideResult.java └── pom.xml /hippo4j-console/src/main/resources/static/static/css/chunk-434632c4.adc5827d.css: -------------------------------------------------------------------------------- 1 | .editor-container[data-v-7505e034]{height:82vh;overflow:auto} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/hippo4j.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/hippo4j.gif -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/img/401.089007e7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/static/img/401.089007e7.gif -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/img/404.a57b6f31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/static/img/404.a57b6f31.png -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/img/hippo4j.ecba1844.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/static/img/hippo4j.ecba1844.gif -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/img/404_cloud.0f4bc32b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/static/img/404_cloud.0f4bc32b.png -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/fonts/element-icons.732389de.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/static/fonts/element-icons.732389de.ttf -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/fonts/element-icons.535877f5.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Snailclimb/dynamic-threadpool/HEAD/hippo4j-console/src/main/resources/static/static/fonts/element-icons.535877f5.woff -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=cn.hippo4j.starter.config.DynamicThreadPoolAutoConfiguration 2 | org.springframework.boot.diagnostics.FailureAnalyzer=cn.hippo4j.starter.core.ConfigEmptyAnalyzer 3 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/test/java/cn/hippo4j/tools/logrecord/LogRecordToolApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | class LogRecordToolApplicationTests { 6 | 7 | @Test 8 | void contextLoads() { 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /hippo4j-example/src/test/java/cn/hippo4j/example/ExampleApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.example; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ExampleApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/function/NoArgsConsumer.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.function; 2 | 3 | /** 4 | * 无参消费者. 5 | * 6 | * @author chen.ma 7 | * @date 2021/11/9 00:06 8 | */ 9 | @FunctionalInterface 10 | public interface NoArgsConsumer { 11 | 12 | /** 13 | * 方法执行 14 | */ 15 | void accept(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/event/SlowEvent.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.event; 2 | 3 | /** 4 | * Slow event. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/23 19:05 8 | */ 9 | public abstract class SlowEvent extends Event { 10 | 11 | @Override 12 | public long sequence() { 13 | return 0; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/constant/Constants.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.constant; 2 | 3 | /** 4 | * Constants. 5 | * 6 | * @author chen.ma 7 | * @date 2021/11/9 22:24 8 | */ 9 | public class Constants { 10 | 11 | public static final String SPLIT_STAR = "*"; 12 | 13 | public static final String SPLIT_COMMA = ","; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Config info. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/20 15:59 10 | */ 11 | @Data 12 | public class ConfigInfo extends ConfigInfoBase { 13 | 14 | private static final long serialVersionUID = -3504960832191834675L; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/annotation/LogField.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.annotation; 2 | 3 | /** 4 | * 日志字段, 用于标记需要比较的实体属性. 5 | * 6 | * @author chen.ma 7 | * @date 2021/10/23 21:29 8 | */ 9 | public @interface LogField { 10 | 11 | /** 12 | * 字段名称 13 | * 14 | * @return 15 | */ 16 | String name(); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /hippo4j-server/bin/shutdown.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1 4 | 5 | setlocal 6 | 7 | set "PATH=%JAVA_HOME%\bin;%PATH%" 8 | 9 | echo killing hippo4j server 10 | 11 | for /f "tokens=1" %%i in ('jps -m ^| find "hippo4j.hippo4j"') do ( taskkill /F /PID %%i ) 12 | 13 | echo Done! 14 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/js/chunk-2d230fe7.19def69d.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d230fe7"],{ef3c:function(e,r,n){"use strict";n.r(r);n("a481");var t,u,a={created:function(){var e=this.$route,r=e.params,n=e.query,t=r.path;this.$router.replace({path:"/"+t,query:n})},render:function(e){return e()}},c=a,o=n("2877"),p=Object(o["a"])(c,t,u,!1,null,null,null);r["default"]=p.exports}}]); -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/enums/LogRecordTypeEnum.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.enums; 2 | 3 | /** 4 | * 日志记录类型. 5 | * 6 | * @author chen.ma 7 | * @date 2021/10/24 21:54 8 | */ 9 | public enum LogRecordTypeEnum { 10 | 11 | /** 12 | * 按照文字模版记录 13 | */ 14 | TEMPLATE, 15 | 16 | /** 17 | * 比较修改前后所有区别 18 | */ 19 | COMPLETE 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hippo4j-server/bin/shutdown.sh: -------------------------------------------------------------------------------- 1 | cd `dirname $0`/../target 2 | target_dir=`pwd` 3 | 4 | pid=`ps ax | grep -i 'hippo4j.hippo4j' | grep ${target_dir} | grep java | grep -v grep | awk '{print $1}'` 5 | if [ -z "$pid" ] ; then 6 | echo "No hippo4jServer running." 7 | exit -1; 8 | fi 9 | 10 | echo "The hippo4jServer(${pid}) is running..." 11 | 12 | kill ${pid} 13 | 14 | echo "Send shutdown request to hippo4jServer(${pid}) OK" -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import cn.hippo4j.auth.model.RoleInfo; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Role mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/30 22:55 12 | */ 13 | @Mapper 14 | public interface RoleMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.mapper; 2 | 3 | import cn.hippo4j.auth.model.UserInfo; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * User mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/30 21:42 12 | */ 13 | @Mapper 14 | public interface UserMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolSubscribeCallback.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | /** 4 | * ThreadPool subscribe callback. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/22 20:26 8 | */ 9 | public interface ThreadPoolSubscribeCallback { 10 | 11 | /** 12 | * Callback. 13 | * 14 | * @param config 15 | */ 16 | void callback(String config); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CalculateUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit; 2 | 3 | /** 4 | * Calculate util. 5 | * 6 | * @author chen.ma 7 | * @date 2021/8/15 14:29 8 | */ 9 | public class CalculateUtil { 10 | 11 | public static int divide(int num1, int num2) { 12 | return ((int) (Double.parseDouble(num1 + "") / Double.parseDouble(num2 + "") * 100)); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-example/src/main/resources/application.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8088 3 | servlet: 4 | context-path: /example 5 | 6 | spring: 7 | profiles: 8 | active: dev 9 | 10 | # 应用配置 11 | application: 12 | name: dynamic-threadpool-example 13 | 14 | # 动态线程池配置 15 | dynamic: 16 | thread-pool: 17 | server-addr: http://localhost:6691 18 | namespace: prescription 19 | item-id: ${spring.application.name} 20 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/service/DashboardService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.service; 2 | 3 | import cn.hippo4j.console.model.ChartInfo; 4 | 5 | /** 6 | * Dashboard service. 7 | * 8 | * @author chen.ma 9 | * @date 2021/11/1 21:06 10 | */ 11 | public interface DashboardService { 12 | 13 | /** 14 | * Get chart info. 15 | * 16 | * @return 17 | */ 18 | ChartInfo getChartInfo(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ItemInfoMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import cn.hippo4j.config.model.ItemInfo; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Item info mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/29 21:53 12 | */ 13 | @Mapper 14 | public interface ItemInfoMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/role/RoleRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.role; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Role resp dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/30 22:49 10 | */ 11 | @Data 12 | public class RoleRespDTO { 13 | 14 | /** 15 | * role 16 | */ 17 | private String role; 18 | 19 | /** 20 | * userName 21 | */ 22 | private String userName; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/Builder.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit.thread; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * Builder pattern interface definition. 7 | * 8 | * @author chen.ma 9 | * @date 2021/7/5 21:39 10 | */ 11 | public interface Builder extends Serializable { 12 | 13 | /** 14 | * Build. 15 | * 16 | * @return 17 | */ 18 | T build(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/OperatorGetService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service; 2 | 3 | import cn.hippo4j.tools.logrecord.model.Operator; 4 | 5 | /** 6 | * 获取操作人. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/23 22:46 10 | */ 11 | public interface OperatorGetService { 12 | 13 | /** 14 | * 获取操作人. 15 | * 16 | * @return 17 | */ 18 | Operator getUser(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/mapper/PermissionMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import cn.hippo4j.auth.model.PermissionInfo; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Permission mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/30 22:34 12 | */ 13 | @Mapper 14 | public interface PermissionMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/mapper/NotifyInfoMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.mapper; 2 | 3 | import cn.hippo4j.config.model.NotifyInfo; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Notify info mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/11/17 22:04 12 | */ 13 | @Mapper 14 | public interface NotifyInfoMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/mapper/TenantInfoMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import cn.hippo4j.config.model.TenantInfo; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Tenant info mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/29 22:44 12 | */ 13 | @Mapper 14 | public interface TenantInfoMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/NotifyPlatformEnum.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | /** 4 | * Notify platform enum. 5 | * 6 | * @author chen.ma 7 | * @date 2021/8/15 15:50 8 | */ 9 | public enum NotifyPlatformEnum { 10 | 11 | /** 12 | * 钉钉 13 | */ 14 | DING, 15 | 16 | /** 17 | * 飞书 18 | */ 19 | LARK, 20 | 21 | /** 22 | * 企业微信 23 | */ 24 | WECHAT 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/mapper/ConfigInfoMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.mapper; 2 | 3 | import cn.hippo4j.config.model.ConfigAllInfo; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Config info mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/29 22:44 12 | */ 13 | @Mapper 14 | public interface ConfigInfoMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/mapper/LogRecordMapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import cn.hippo4j.tools.logrecord.model.LogRecordInfo; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | * Log record mapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/24 21:01 12 | */ 13 | @Mapper 14 | public interface LogRecordMapper extends BaseMapper { 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/user/UserQueryPageReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.user; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * User query page. 8 | * 9 | * @author chen.ma 10 | * @date 2021/10/30 21:47 11 | */ 12 | @Data 13 | public class UserQueryPageReqDTO extends Page { 14 | 15 | /** 16 | * userName 17 | */ 18 | private String userName; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigAdapter.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | /** 4 | * Config adapter. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/22 21:29 8 | */ 9 | public class ConfigAdapter { 10 | 11 | /** 12 | * Callback Config. 13 | * 14 | * @param config 15 | */ 16 | public void callbackConfig(String config) { 17 | ThreadPoolDynamicRefresh.refreshDynamicPool(config); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-example/src/main/java/cn/hippo4j/example/constant/GlobalTestConstant.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.example.constant; 2 | 3 | /** 4 | * Global test variables. 5 | * 6 | * @author chen.ma 7 | * @date 2021/8/15 21:06 8 | */ 9 | public class GlobalTestConstant { 10 | 11 | public static final String CUSTOM_POOL = "custom-pool"; 12 | 13 | public static final String MESSAGE_PRODUCE = "message-produce"; 14 | 15 | public static final String MESSAGE_CONSUME = "message-consume"; 16 | } 17 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigEmptyException.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | /** 7 | * Config empty exception. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/28 21:58 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | public class ConfigEmptyException extends RuntimeException { 15 | 16 | private String description; 17 | 18 | private String action; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/LogRecordService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service; 2 | 3 | import cn.hippo4j.tools.logrecord.model.LogRecordInfo; 4 | 5 | /** 6 | * 日志记录. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/23 22:43 10 | */ 11 | public interface LogRecordService { 12 | 13 | /** 14 | * 保存日志. 15 | * 16 | * @param logRecordInfo 17 | */ 18 | void record(LogRecordInfo logRecordInfo); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemUpdateReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.item; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Item update req dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/29 22:05 10 | */ 11 | @Data 12 | public class ItemUpdateReqDTO { 13 | 14 | private String tenantId; 15 | 16 | private String itemId; 17 | 18 | private String itemName; 19 | 20 | private String itemDesc; 21 | 22 | private String owner; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/role/RoleQueryPageReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.role; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * Role query page. 8 | * 9 | * @author chen.ma 10 | * @date 2021/10/30 21:47 11 | */ 12 | @Data 13 | public class RoleQueryPageReqDTO extends Page { 14 | 15 | public RoleQueryPageReqDTO(long current, long size) { 16 | super(current, size); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/model/Operator.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | /** 8 | * 操作人. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/24 21:44 12 | */ 13 | @Data 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class Operator { 17 | 18 | /** 19 | * 操作人 Id 20 | */ 21 | private String operatorId; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/UserContext.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.toolkit; 2 | 3 | /** 4 | * User context (Transition scheme). 5 | * 6 | * @author chen.ma 7 | * @date 2021/11/17 21:13 8 | */ 9 | public class UserContext { 10 | 11 | private static String username; 12 | 13 | public static void setUserName(String username) { 14 | UserContext.username = username; 15 | } 16 | 17 | public static String getUserName() { 18 | return username; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hippo4j-tools/open-change-tool/src/main/java/cn/hippo4j/tools/openchange/EnableOpenChangeNotify.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.openchange; 2 | 3 | import org.springframework.context.annotation.Import; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * Change timed task. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/31 13:39 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Import(OpenChangeNotifyConfig.class) 16 | @Documented 17 | public @interface EnableOpenChangeNotify { 18 | } 19 | -------------------------------------------------------------------------------- /hippo4j-example/src/main/java/cn/hippo4j/example/ExampleApplication.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.example; 2 | 3 | import cn.hippo4j.starter.enable.EnableDynamicThreadPool; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | @EnableDynamicThreadPool 9 | public class ExampleApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ExampleApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/MessageTypeEnum.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | /** 4 | * Message type enum. 5 | * 6 | * @author chen.ma 7 | * @date 2021/8/16 20:50 8 | */ 9 | public enum MessageTypeEnum { 10 | 11 | /** 12 | * 通知类型 13 | */ 14 | CHANGE, 15 | 16 | /** 17 | * 容量报警 18 | */ 19 | CAPACITY, 20 | 21 | /** 22 | * 活跃度报警 23 | */ 24 | LIVENESS, 25 | 26 | /** 27 | * 拒绝策略报警 28 | */ 29 | REJECT 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-tools/open-change-tool/src/main/java/cn/hippo4j/tools/openchange/GitHubRemote.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.openchange; 2 | 3 | import com.dtflys.forest.annotation.Get; 4 | 5 | /** 6 | * GitHub remote. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/31 10:45 10 | */ 11 | public interface GitHubRemote { 12 | 13 | /** 14 | * 获取 GitHub 仓库详细信息. 15 | * 16 | * @return 17 | */ 18 | @Get("https://api.github.com/repos/acmenlt/dynamic-threadpool") 19 | OpenChangeInfo getGitHubItemInfo(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/DynamicThreadPool.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Dynamic thread pool. 10 | * 11 | * @author chen.ma 12 | * @date 2021/10/13 21:50 13 | */ 14 | @Target(ElementType.METHOD) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface DynamicThreadPool { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/permission/PermissionQueryPageReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.permission; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * Permission query page. 8 | * 9 | * @author chen.ma 10 | * @date 2021/10/30 21:47 11 | */ 12 | @Data 13 | public class PermissionQueryPageReqDTO extends Page { 14 | 15 | public PermissionQueryPageReqDTO(long current, long size) { 16 | super(current, size); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/user/LoginUser.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.user; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Login user. 7 | * 8 | * @author chen.ma 9 | * @date 2021/11/9 22:41 10 | */ 11 | @Data 12 | public class LoginUser { 13 | 14 | /** 15 | * username 16 | */ 17 | private String username; 18 | 19 | /** 20 | * password 21 | */ 22 | private String password; 23 | 24 | /** 25 | * rememberMe 26 | */ 27 | private Integer rememberMe; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hippo4j-auth/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-common/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-config/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-console/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-example/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-server/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-tools/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-discovery/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/permission/PermissionRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.permission; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Permission resp dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/30 22:21 10 | */ 11 | @Data 12 | public class PermissionRespDTO { 13 | 14 | /** 15 | * role 16 | */ 17 | private String role; 18 | 19 | /** 20 | * source 21 | */ 22 | private String resource; 23 | 24 | /** 25 | * action 26 | */ 27 | private String action; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/SmartSubscriber.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.notify.listener; 2 | 3 | import cn.hippo4j.config.event.Event; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Subscribers to multiple events can be listened to. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/23 19:02 12 | */ 13 | public abstract class SmartSubscriber extends Subscriber { 14 | 15 | /** 16 | * Subscribe types. 17 | * 18 | * @return 19 | */ 20 | public abstract List> subscribeTypes(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/model/ThreadPoolInstanceInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.model; 2 | 3 | import cn.hippo4j.config.model.ConfigAllInfo; 4 | import lombok.Data; 5 | 6 | /** 7 | * ThreadPool instance info. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/11 23:39 11 | */ 12 | @Data 13 | public class ThreadPoolInstanceInfo extends ConfigAllInfo { 14 | 15 | /** 16 | * identify 17 | */ 18 | private String identify; 19 | 20 | /** 21 | * clientBasePath 22 | */ 23 | private String clientBasePath; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/Listener.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import java.util.concurrent.Executor; 4 | 5 | /** 6 | * Listener. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/22 20:20 10 | */ 11 | public interface Listener { 12 | 13 | /** 14 | * Get executor. 15 | * 16 | * @return 17 | */ 18 | Executor getExecutor(); 19 | 20 | /** 21 | * Receive config info. 22 | * 23 | * @param configInfo 24 | */ 25 | void receiveConfigInfo(String configInfo); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-tools/open-change-tool/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/impl/DefaultOperatorGetServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service.impl; 2 | 3 | import cn.hippo4j.tools.logrecord.model.Operator; 4 | import cn.hippo4j.tools.logrecord.service.OperatorGetService; 5 | 6 | /** 7 | * 默认实现. 8 | * 9 | * @author chen.ma 10 | * @date 2021/10/24 17:58 11 | */ 12 | public class DefaultOperatorGetServiceImpl implements OperatorGetService { 13 | 14 | @Override 15 | public Operator getUser() { 16 | return new Operator("-"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolDelReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.threadpool; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * ThreadPool del req dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/11/11 21:40 10 | */ 11 | @Data 12 | public class ThreadPoolDelReqDTO { 13 | 14 | /** 15 | * tenantId 16 | */ 17 | private String tenantId; 18 | 19 | /** 20 | * itemId 21 | */ 22 | private String itemId; 23 | 24 | /** 25 | * tpId 26 | */ 27 | private String tpId; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/ConditionUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.toolkit; 2 | 3 | import cn.hippo4j.common.function.NoArgsConsumer; 4 | 5 | /** 6 | * Condition util. 7 | * 8 | * @author chen.ma 9 | * @date 2021/11/6 22:40 10 | */ 11 | public class ConditionUtil { 12 | 13 | public static void condition(boolean condition, NoArgsConsumer trueConsumer, NoArgsConsumer falseConsumer) { 14 | if (condition) { 15 | trueConsumer.accept(); 16 | } else { 17 | falseConsumer.accept(); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/spi/ServiceLoaderInstantiationException.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.spi; 2 | 3 | /** 4 | * Service loader instantiation exception. 5 | * 6 | * @author chen.ma 7 | * @date 2021/7/10 23:48 8 | */ 9 | public class ServiceLoaderInstantiationException extends RuntimeException { 10 | 11 | public ServiceLoaderInstantiationException(final Class clazz, final Exception cause) { 12 | super(String.format("Can not find public default constructor for SPI class `%s`", clazz.getName()), cause); 13 | } 14 | 15 | } 16 | 17 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/enable/EnableDynamicThreadPool.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.enable; 2 | 3 | import org.springframework.context.annotation.Import; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * Annotation to activate dynamic threadPool related configuration. 9 | * 10 | * @author chen.ma 11 | * @date 2021/7/8 23:28 12 | */ 13 | @Target(ElementType.TYPE) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Documented 16 | @Import({BeforeCheckConfiguration.class, MarkerConfiguration.class}) 17 | public @interface EnableDynamicThreadPool { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hippo4j-server/src/main/java/cn/hippo4j/server/ServerApplication.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.server; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication(scanBasePackages = "cn.hippo4j") 8 | @MapperScan(basePackages = {"cn.hippo4j.config.mapper", "cn.hippo4j.auth.mapper"}) 9 | public class ServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/config/CommonConfig.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.config; 2 | 3 | import cn.hippo4j.common.config.ApplicationContextHolder; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | /** 8 | * Common config. 9 | * 10 | * @author chen.ma 11 | * @date 2021/7/19 21:03 12 | */ 13 | @Configuration 14 | public class CommonConfig { 15 | 16 | @Bean 17 | public ApplicationContextHolder simpleApplicationContextHolder() { 18 | return new ApplicationContextHolder(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/model/ChartInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.model; 2 | 3 | import lombok.Data; 4 | import lombok.experimental.Accessors; 5 | 6 | /** 7 | * Char info. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/10 21:06 11 | */ 12 | @Data 13 | @Accessors(chain = true) 14 | public class ChartInfo { 15 | 16 | /** 17 | * 租户统计 18 | */ 19 | private Integer tenantCount; 20 | 21 | /** 22 | * 项目统计 23 | */ 24 | private Integer itemCount; 25 | 26 | /** 27 | * 线程池统计 28 | */ 29 | private Integer threadPoolCount; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigChangePublisher.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service; 2 | 3 | import cn.hippo4j.config.notify.NotifyCenter; 4 | import cn.hippo4j.config.event.LocalDataChangeEvent; 5 | 6 | /** 7 | * Config change publisher. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/24 23:34 11 | */ 12 | public class ConfigChangePublisher { 13 | 14 | /** 15 | * Notify configChange. 16 | * 17 | * @param event 18 | */ 19 | public static void notifyConfigChange(LocalDataChangeEvent event) { 20 | NotifyCenter.publishEvent(event); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/NotifyConfig.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Alarm config. 7 | * 8 | * @author chen.ma 9 | * @date 2021/8/15 16:09 10 | */ 11 | @Data 12 | public class NotifyConfig { 13 | 14 | /** 15 | * type 16 | */ 17 | private String type; 18 | 19 | /** 20 | * url 21 | */ 22 | private String url; 23 | 24 | /** 25 | * token 26 | */ 27 | private String token; 28 | 29 | /** 30 | * receives 31 | */ 32 | private String receives; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/spi/CustomBlockingQueue.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.spi; 2 | 3 | import java.util.concurrent.BlockingQueue; 4 | 5 | /** 6 | * Custom blockingQueue. 7 | * 8 | * @author chen.ma 9 | * @date 2021/7/11 00:51 10 | */ 11 | public interface CustomBlockingQueue { 12 | 13 | /** 14 | * Gets the custom blocking queue type. 15 | * 16 | * @return 17 | */ 18 | Integer getType(); 19 | 20 | /** 21 | * Get custom blocking queue. 22 | * 23 | * @return 24 | */ 25 | BlockingQueue generateBlockingQueue(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/user/UserReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.user; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * User req dto. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/11 20:30 11 | */ 12 | @Data 13 | public class UserReqDTO extends Page { 14 | 15 | /** 16 | * userName 17 | */ 18 | private String userName; 19 | 20 | /** 21 | * password 22 | */ 23 | private String password; 24 | 25 | /** 26 | * role 27 | */ 28 | private String role; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/enable/MarkerConfiguration.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.enable; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * Marker configuration. 8 | * 9 | * @author chen.ma 10 | * @date 2021/7/8 23:30 11 | */ 12 | @Configuration(proxyBeanMethods = false) 13 | public class MarkerConfiguration { 14 | 15 | @Bean 16 | public Marker dynamicThreadPoolMarkerBean() { 17 | return new Marker(); 18 | } 19 | 20 | public class Marker { 21 | 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/event/LocalDataChangeEvent.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.event; 2 | 3 | /** 4 | * Local data change event. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/23 19:13 8 | */ 9 | public class LocalDataChangeEvent extends Event { 10 | 11 | /** 12 | * 租户+项目+线程池 13 | */ 14 | public final String groupKey; 15 | 16 | /** 17 | * 客户端实例唯一标识 18 | */ 19 | public final String identify; 20 | 21 | public LocalDataChangeEvent(String identify, String groupKey) { 22 | this.identify = identify; 23 | this.groupKey = groupKey; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/toolkit/ClassUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.toolkit; 2 | 3 | import java.util.Objects; 4 | 5 | /** 6 | * Class util. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/23 19:03 10 | */ 11 | public class ClassUtil { 12 | 13 | public static boolean isAssignableFrom(Class clazz, Class cls) { 14 | Objects.requireNonNull(cls, "cls"); 15 | return clazz.isAssignableFrom(cls); 16 | } 17 | 18 | public static String getCanonicalName(Class cls) { 19 | Objects.requireNonNull(cls, "cls"); 20 | return cls.getCanonicalName(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordQueryReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.log; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * 日志记录查询. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/17 21:43 11 | */ 12 | @Data 13 | public class LogRecordQueryReqDTO extends Page { 14 | 15 | /** 16 | * 业务标识 17 | */ 18 | private String bizNo; 19 | 20 | /** 21 | * 业务类型 22 | */ 23 | private String category; 24 | 25 | /** 26 | * 操作人 27 | */ 28 | private String operator; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/LogRecordBizService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz; 2 | 3 | import cn.hippo4j.config.model.biz.log.LogRecordQueryReqDTO; 4 | import cn.hippo4j.config.model.biz.log.LogRecordRespDTO; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | 7 | /** 8 | * 操作日志. 9 | * 10 | * @author chen.ma 11 | * @date 2021/11/17 21:41 12 | */ 13 | public interface LogRecordBizService { 14 | 15 | /** 16 | * 查询操作日志. 17 | * 18 | * @param pageQuery 19 | * @return 20 | */ 21 | IPage queryPage(LogRecordQueryReqDTO pageQuery); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/FunctionService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service; 2 | 3 | /** 4 | * 函数服务. 5 | * 6 | * @author chen.ma 7 | * @date 2021/10/24 21:30 8 | */ 9 | public interface FunctionService { 10 | 11 | /** 12 | * 执行. 13 | * 14 | * @param functionName 15 | * @param value 16 | * @return 17 | */ 18 | String apply(String functionName, String value); 19 | 20 | /** 21 | * 是否提前执行. 22 | * 23 | * @param functionName 24 | * @return 25 | */ 26 | boolean beforeFunction(String functionName); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyListRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.notify; 2 | 3 | import cn.hippo4j.config.model.NotifyInfo; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Notify list resp dto. 11 | * 12 | * @author chen.ma 13 | * @date 2021/11/17 22:53 14 | */ 15 | @Data 16 | @AllArgsConstructor 17 | public class NotifyListRespDTO { 18 | 19 | /** 20 | * 通知 Key 21 | */ 22 | private String notifyKey; 23 | 24 | /** 25 | * 通知配置 26 | */ 27 | private List notifyList; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/ThreadPoolAlarm.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | /** 7 | * Thread pool alarm. 8 | * 9 | * @author chen.ma 10 | * @date 2021/8/15 13:13 11 | */ 12 | @Data 13 | @AllArgsConstructor 14 | public class ThreadPoolAlarm { 15 | 16 | /** 17 | * isAlarm 18 | */ 19 | private Boolean isAlarm; 20 | 21 | /** 22 | * livenessAlarm 23 | */ 24 | private Integer livenessAlarm; 25 | 26 | /** 27 | * capacityAlarm 28 | */ 29 | private Integer capacityAlarm; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | /** 4 | * Config service. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/21 21:49 8 | */ 9 | public interface ConfigService { 10 | 11 | /** 12 | * Add listener. 13 | * 14 | * @param tenantId 15 | * @param itemId 16 | * @param tpId 17 | * @param listener 18 | */ 19 | void addListener(String tenantId, String itemId, String tpId, Listener listener); 20 | 21 | /** 22 | * Get server status. 23 | * 24 | * @return 25 | */ 26 | String getServerStatus(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantQueryReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.tenant; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * Tenant query req dto. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/29 22:28 11 | */ 12 | @Data 13 | public class TenantQueryReqDTO extends Page { 14 | 15 | /** 16 | * tenantId 17 | */ 18 | private String tenantId; 19 | 20 | /** 21 | * tenantName 22 | */ 23 | private String tenantName; 24 | 25 | /** 26 | * owner 27 | */ 28 | private String owner; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantSaveReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.tenant; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Tenant save req dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/29 20:40 10 | */ 11 | @Data 12 | public class TenantSaveReqDTO { 13 | 14 | /** 15 | * tenantId 16 | */ 17 | private String tenantId; 18 | 19 | /** 20 | * tenantName 21 | */ 22 | private String tenantName; 23 | 24 | /** 25 | * tenantDesc 26 | */ 27 | private String tenantDesc; 28 | 29 | /** 30 | * owner 31 | */ 32 | private String owner; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/spi/CustomRejectedExecutionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.spi; 2 | 3 | import java.util.concurrent.RejectedExecutionHandler; 4 | 5 | /** 6 | * Custom rejectedExecution handler. 7 | * 8 | * @author chen.ma 9 | * @date 2021/7/10 23:51 10 | */ 11 | public interface CustomRejectedExecutionHandler { 12 | 13 | /** 14 | * Get custom reject policy type. 15 | * 16 | * @return 17 | */ 18 | Integer getType(); 19 | 20 | /** 21 | * Get custom reject policy. 22 | * 23 | * @return 24 | */ 25 | RejectedExecutionHandler generateRejected(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/model/MethodExecuteResult.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.model; 2 | 3 | import lombok.*; 4 | 5 | /** 6 | * 方法执行结果. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/24 21:59 10 | */ 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @RequiredArgsConstructor 15 | public class MethodExecuteResult { 16 | 17 | /** 18 | * 是否成功 19 | */ 20 | @NonNull 21 | private boolean success; 22 | 23 | /** 24 | * 异常 25 | */ 26 | private Throwable throwable; 27 | 28 | /** 29 | * 错误日志 30 | */ 31 | private String errorMsg; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/wrapper/ManagerListenerWrapper.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.wrapper; 2 | 3 | import cn.hippo4j.starter.core.Listener; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | /** 8 | * Manager listener wrapper. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/22 17:47 12 | */ 13 | @Getter 14 | @Setter 15 | public class ManagerListenerWrapper { 16 | 17 | private String lastCallMd5; 18 | 19 | final Listener listener; 20 | 21 | public ManagerListenerWrapper(String md5, Listener listener) { 22 | this.lastCallMd5 = md5; 23 | this.listener = listener; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolQueryReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.threadpool; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * Thread pool query req dto. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/30 21:22 11 | */ 12 | @Data 13 | public class ThreadPoolQueryReqDTO extends Page { 14 | 15 | /** 16 | * tenantId 17 | */ 18 | private String tenantId; 19 | 20 | /** 21 | * itemId 22 | */ 23 | private String itemId; 24 | 25 | /** 26 | * tpId 27 | */ 28 | private String tpId; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/impl/DefaultLogRecordServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service.impl; 2 | 3 | import cn.hippo4j.tools.logrecord.model.LogRecordInfo; 4 | import cn.hippo4j.tools.logrecord.service.LogRecordService; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | /** 8 | * 默认实现日志存储. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/24 17:59 12 | */ 13 | @Slf4j 14 | public class DefaultLogRecordServiceImpl implements LogRecordService { 15 | 16 | @Override 17 | public void record(LogRecordInfo logRecordInfo) { 18 | log.info("Log print :: {}", logRecordInfo); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/model/LogRecordOps.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.model; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | /** 7 | * 日志操作记录. 8 | * 9 | * @author chen.ma 10 | * @date 2021/10/24 21:07 11 | */ 12 | @Data 13 | @Builder 14 | public class LogRecordOps { 15 | 16 | private String successLogTemplate; 17 | 18 | private String failLogTemplate; 19 | 20 | private String operatorId; 21 | 22 | private String bizKey; 23 | 24 | private String bizNo; 25 | 26 | private String category; 27 | 28 | private String detail; 29 | 30 | private String condition; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ConfigEmptyAnalyzer.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import org.springframework.boot.diagnostics.AbstractFailureAnalyzer; 4 | import org.springframework.boot.diagnostics.FailureAnalysis; 5 | 6 | /** 7 | * Config empty analyzer. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/28 21:59 11 | */ 12 | public class ConfigEmptyAnalyzer extends AbstractFailureAnalyzer { 13 | 14 | @Override 15 | protected FailureAnalysis analyze(Throwable rootFailure, ConfigEmptyException cause) { 16 | return new FailureAnalysis(cause.getDescription(), cause.getAction(), cause); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/ParseFunction.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service; 2 | 3 | /** 4 | * 函数解析. 5 | * 6 | * @author chen.ma 7 | * @date 2021/10/23 22:40 8 | */ 9 | public interface ParseFunction { 10 | 11 | /** 12 | * 是否先执行. 13 | * 14 | * @return 15 | */ 16 | default boolean executeBefore() { 17 | return false; 18 | } 19 | 20 | /** 21 | * 函数名称. 22 | * 23 | * @return 24 | */ 25 | String functionName(); 26 | 27 | /** 28 | * 执行. 29 | * 30 | * @param value 31 | * @return 32 | */ 33 | String apply(String value); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/compare/Equator.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.compare; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 对象比对器. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/24 20:27 10 | */ 11 | public interface Equator { 12 | 13 | /** 14 | * 判断两个对象是否相等. 15 | * 16 | * @param first 17 | * @param second 18 | * @return 19 | */ 20 | boolean isEquals(Object first, Object second); 21 | 22 | /** 23 | * 获取两个对象不想等的属性. 24 | * 25 | * @param first 26 | * @param second 27 | * @return 28 | */ 29 | List getDiffFields(Object first, Object second); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/impl/DefaultParseFunction.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service.impl; 2 | 3 | import cn.hippo4j.tools.logrecord.service.ParseFunction; 4 | 5 | /** 6 | * 默认实现. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/24 17:57 10 | */ 11 | public class DefaultParseFunction implements ParseFunction { 12 | 13 | @Override 14 | public boolean executeBefore() { 15 | return true; 16 | } 17 | 18 | @Override 19 | public String functionName() { 20 | return null; 21 | } 22 | 23 | @Override 24 | public String apply(String value) { 25 | return null; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/CustomOperatorGetServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.handler; 2 | 3 | import cn.hippo4j.common.toolkit.UserContext; 4 | import cn.hippo4j.tools.logrecord.model.Operator; 5 | import cn.hippo4j.tools.logrecord.service.OperatorGetService; 6 | import org.springframework.stereotype.Component; 7 | 8 | /** 9 | * Custom operator get service. 10 | * 11 | * @author chen.ma 12 | * @date 2021/11/28 17:57 13 | */ 14 | @Component 15 | public class CustomOperatorGetServiceImpl implements OperatorGetService { 16 | 17 | @Override 18 | public Operator getUser() { 19 | return new Operator(UserContext.getUserName()); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemQueryReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.item; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | /** 7 | * Item query req dto. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/29 22:28 11 | */ 12 | @Data 13 | public class ItemQueryReqDTO extends Page { 14 | 15 | /** 16 | * tenantId 17 | */ 18 | private String tenantId; 19 | 20 | /** 21 | * itemId 22 | */ 23 | private String itemId; 24 | 25 | /** 26 | * itemName 27 | */ 28 | private String itemName; 29 | 30 | /** 31 | * owner 32 | */ 33 | private String owner; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemSaveReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.item; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Item save req dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/29 22:05 10 | */ 11 | @Data 12 | public class ItemSaveReqDTO { 13 | 14 | /** 15 | * tenantId 16 | */ 17 | private String tenantId; 18 | 19 | /** 20 | * itemId 21 | */ 22 | private String itemId; 23 | 24 | /** 25 | * itemName 26 | */ 27 | private String itemName; 28 | 29 | /** 30 | * itemDesc 31 | */ 32 | private String itemDesc; 33 | 34 | /** 35 | * owner 36 | */ 37 | private String owner; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hippo4j-discovery/src/main/java/cn/hippo4j/discovery/config/RegistryConfiguration.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.discovery.config; 2 | 3 | import cn.hippo4j.discovery.core.BaseInstanceRegistry; 4 | import lombok.AllArgsConstructor; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import javax.annotation.PostConstruct; 8 | 9 | /** 10 | * Registry configuration. 11 | * 12 | * @author chen.ma 13 | * @date 2021/8/12 21:48 14 | */ 15 | @Configuration 16 | @AllArgsConstructor 17 | public class RegistryConfiguration { 18 | 19 | private final BaseInstanceRegistry baseInstanceRegistry; 20 | 21 | @PostConstruct 22 | public void registryInit() { 23 | baseInstanceRegistry.postInit(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Result.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.web.base; 2 | 3 | import lombok.Data; 4 | import lombok.experimental.Accessors; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Result. 10 | * 11 | * @author chen.ma 12 | * @date 2021/3/19 16:12 13 | */ 14 | @Data 15 | @Accessors(chain = true) 16 | public class Result implements Serializable { 17 | 18 | private static final long serialVersionUID = -4408341719434417427L; 19 | 20 | public static final String SUCCESS_CODE = "0"; 21 | 22 | private String code; 23 | 24 | private String message; 25 | 26 | private T data; 27 | 28 | public boolean isSuccess() { 29 | return SUCCESS_CODE.equals(code); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/Pair.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.discovery.core; 2 | 3 | /** 4 | * Pair. 5 | * 6 | * @author chen.ma 7 | * @date 2021/8/8 23:04 8 | */ 9 | public class Pair { 10 | 11 | public E1 first() { 12 | return first; 13 | } 14 | 15 | public void setFirst(E1 first) { 16 | this.first = first; 17 | } 18 | 19 | public E2 second() { 20 | return second; 21 | } 22 | 23 | public void setSecond(E2 second) { 24 | this.second = second; 25 | } 26 | 27 | private E1 first; 28 | 29 | private E2 second; 30 | 31 | public Pair(E1 first, E2 second) { 32 | this.first = first; 33 | this.second = second; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyQueryReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.notify; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Notify query req dto. 10 | * 11 | * @author chen.ma 12 | * @date 2021/11/17 22:52 13 | */ 14 | @Data 15 | public class NotifyQueryReqDTO extends Page { 16 | 17 | /** 18 | * groupKeys 19 | */ 20 | private List groupKeys; 21 | 22 | /** 23 | * 租户id 24 | */ 25 | private String tenantId; 26 | 27 | /** 28 | * 项目id 29 | */ 30 | private String itemId; 31 | 32 | /** 33 | * 线程池id 34 | */ 35 | private String tpId; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/event/Event.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.event; 2 | 3 | import java.io.Serializable; 4 | import java.util.concurrent.atomic.AtomicLong; 5 | 6 | /** 7 | * An abstract class for event. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/23 18:59 11 | */ 12 | public abstract class Event implements Serializable { 13 | 14 | private static final AtomicLong SEQUENCE = new AtomicLong(0); 15 | 16 | private final long sequence = SEQUENCE.getAndIncrement(); 17 | 18 | /** 19 | * Event sequence number, which can be used to handle the sequence of events. 20 | * 21 | * @return sequence num, It's best to make sure it's monotone. 22 | */ 23 | public long sequence() { 24 | return sequence; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-45e73af7.13821f5e.css: -------------------------------------------------------------------------------- 1 | .errPage-container[data-v-6fb1594e]{width:800px;max-width:100%;margin:100px auto}.errPage-container .pan-back-btn[data-v-6fb1594e]{background:#008489;color:#fff;border:none!important}.errPage-container .pan-gif[data-v-6fb1594e]{margin:0 auto;display:block}.errPage-container .pan-img[data-v-6fb1594e]{display:block;margin:0 auto;width:100%}.errPage-container .text-jumbo[data-v-6fb1594e]{font-size:60px;font-weight:700;color:#484848}.errPage-container .list-unstyled[data-v-6fb1594e]{font-size:14px}.errPage-container .list-unstyled li[data-v-6fb1594e]{padding-bottom:5px}.errPage-container .list-unstyled a[data-v-6fb1594e]{color:#008489;text-decoration:none}.errPage-container .list-unstyled a[data-v-6fb1594e]:hover{text-decoration:underline} -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/SendMessageService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import cn.hippo4j.common.model.PoolParameterInfo; 4 | import cn.hippo4j.starter.core.DynamicThreadPoolExecutor; 5 | 6 | /** 7 | * Send msg. 8 | * 9 | * @author chen.ma 10 | * @date 2021/8/15 15:31 11 | */ 12 | public interface SendMessageService { 13 | 14 | /** 15 | * Send alarm message. 16 | * 17 | * @param typeEnum 18 | * @param threadPoolExecutor 19 | */ 20 | void sendAlarmMessage(MessageTypeEnum typeEnum, DynamicThreadPoolExecutor threadPoolExecutor); 21 | 22 | /** 23 | * Send change message. 24 | * 25 | * @param parameter 26 | */ 27 | void sendChangeMessage(PoolParameterInfo parameter); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-003006fa.6d24dacd.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-0a5b5b6f.6d24dacd.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-0c349c3a.9905f991.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-22d8af12.6d24dacd.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-648295c6.6d24dacd.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-7b4c55c2.9905f991.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/css/chunk-e25b23da.6d24dacd.css: -------------------------------------------------------------------------------- 1 | .waves-ripple{position:absolute;border-radius:100%;background-color:rgba(0,0,0,.15);background-clip:padding-box;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:scale(0);transform:scale(0);opacity:1}.waves-ripple.z-active{opacity:0;-webkit-transform:scale(2);transform:scale(2);-webkit-transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,-webkit-transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out;transition:opacity 1.2s ease-out,transform .6s ease-out,-webkit-transform .6s ease-out}.pagination-container[data-v-6af373ef]{background:#fff;padding:32px 16px}.pagination-container.hidden[data-v-6af373ef]{display:none} -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/notify/listener/Subscriber.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.notify.listener; 2 | 3 | import cn.hippo4j.config.event.Event; 4 | 5 | import java.util.concurrent.Executor; 6 | 7 | /** 8 | * An abstract subscriber class for subscriber interface. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/23 19:02 12 | */ 13 | public abstract class Subscriber { 14 | 15 | /** 16 | * Event callback. 17 | * 18 | * @param event 19 | */ 20 | public abstract void onEvent(T event); 21 | 22 | /** 23 | * Type of this subscriber's subscription. 24 | * 25 | * @return 26 | */ 27 | public abstract Class subscribeType(); 28 | 29 | public Executor executor() { 30 | return null; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/ConfigService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz; 2 | 3 | import cn.hippo4j.config.model.ConfigAllInfo; 4 | 5 | /** 6 | * Config service. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/20 15:18 10 | */ 11 | public interface ConfigService { 12 | 13 | /** 14 | * Find config all info. 15 | * 16 | * @param tpId tpId 17 | * @param itemId itemId 18 | * @param tenantId tenantId 19 | * @return all config 20 | */ 21 | ConfigAllInfo findConfigAllInfo(String tpId, String itemId, String tenantId); 22 | 23 | /** 24 | * Insert or update. 25 | * 26 | * @param identify 27 | * @param configAllInfo 28 | */ 29 | void insertOrUpdate(String identify, ConfigAllInfo configAllInfo); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/LogRecordServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz.impl; 2 | 3 | import cn.hippo4j.config.mapper.LogRecordMapper; 4 | import cn.hippo4j.tools.logrecord.model.LogRecordInfo; 5 | import cn.hippo4j.tools.logrecord.service.LogRecordService; 6 | import lombok.AllArgsConstructor; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * 操作日志保存数据库. 11 | * 12 | * @author chen.ma 13 | * @date 2021/10/24 20:57 14 | */ 15 | @Service 16 | @AllArgsConstructor 17 | public class LogRecordServiceImpl implements LogRecordService { 18 | 19 | private final LogRecordMapper logRecordMapper; 20 | 21 | @Override 22 | public void record(LogRecordInfo logRecordInfo) { 23 | logRecordMapper.insert(logRecordInfo); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/enums/DelEnum.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.enums; 2 | 3 | /** 4 | * Del enum. 5 | * 6 | * @author chen.ma 7 | * @date 2021/3/26 18:45 8 | */ 9 | public enum DelEnum { 10 | 11 | /** 12 | * Normal state 13 | */ 14 | NORMAL("0"), 15 | 16 | /** 17 | * Deleted state 18 | */ 19 | DELETE("1"); 20 | 21 | private final String statusCode; 22 | 23 | DelEnum(String statusCode) { 24 | this.statusCode = statusCode; 25 | } 26 | 27 | public String getCode() { 28 | return this.statusCode; 29 | } 30 | 31 | public Integer getIntCode() { 32 | return Integer.parseInt(this.statusCode); 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return statusCode; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * Web config. 9 | * 10 | * @author chen.ma 11 | * @date 2021/11/9 22:56 12 | */ 13 | @Configuration 14 | public class WebConfig implements WebMvcConfigurer { 15 | 16 | @Override 17 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 18 | registry.addResourceHandler("/index.html").addResourceLocations("classpath:/static/index.html"); 19 | registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/static/"); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/AlarmControlDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | 7 | /** 8 | * 报警控制实体. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/28 22:15 12 | */ 13 | @Data 14 | @Builder 15 | public class AlarmControlDTO { 16 | 17 | /** 18 | * 线程池 Id 19 | */ 20 | private String threadPool; 21 | 22 | /** 23 | * 推送报警平台 24 | */ 25 | private String platform; 26 | 27 | /** 28 | * 推送报警类型 29 | */ 30 | private MessageTypeEnum typeEnum; 31 | 32 | /** 33 | * 构建线程池报警标识 34 | * 35 | * @return 36 | */ 37 | public String buildPk() { 38 | return StrUtil.builder(threadPool, "+", platform).toString(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/log/LogRecordRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.log; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * 日志记录返回. 10 | * 11 | * @author chen.ma 12 | * @date 2021/11/17 21:37 13 | */ 14 | @Data 15 | public class LogRecordRespDTO { 16 | 17 | /** 18 | * 业务标识 19 | */ 20 | private String bizNo; 21 | 22 | /** 23 | * 日志内容 24 | */ 25 | private String action; 26 | 27 | /** 28 | * 操作人 29 | */ 30 | private String operator; 31 | 32 | /** 33 | * 业务类型 34 | */ 35 | private String category; 36 | 37 | /** 38 | * gmtCreate 39 | */ 40 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 41 | private Date createTime; 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/user/UserRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.user; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * User resp dto. 10 | * 11 | * @author chen.ma 12 | * @date 2021/10/30 21:51 13 | */ 14 | @Data 15 | public class UserRespDTO { 16 | 17 | /** 18 | * userName 19 | */ 20 | private String userName; 21 | 22 | /** 23 | * role 24 | */ 25 | private String role; 26 | 27 | /** 28 | * gmtCreate 29 | */ 30 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 31 | private Date gmtCreate; 32 | 33 | /** 34 | * gmtModified 35 | */ 36 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 37 | private Date gmtModified; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantUpdateReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.tenant; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import lombok.Data; 5 | 6 | /** 7 | * Tenant save req dto. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/29 20:40 11 | */ 12 | @Data 13 | public class TenantUpdateReqDTO { 14 | 15 | /** 16 | * id 17 | */ 18 | private Long id; 19 | 20 | /** 21 | * tenantId 22 | */ 23 | private String tenantId; 24 | 25 | /** 26 | * tenantName 27 | */ 28 | private String tenantName; 29 | 30 | /** 31 | * tenantDesc 32 | */ 33 | private String tenantDesc; 34 | 35 | /** 36 | * owner 37 | */ 38 | private String owner; 39 | 40 | @Override 41 | public String toString() { 42 | return JSON.toJSONString(this); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/UtilAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.config; 2 | 3 | import cn.hippo4j.starter.toolkit.inet.InetUtils; 4 | import cn.hippo4j.starter.toolkit.inet.InetUtilsProperties; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | import org.springframework.context.annotation.Bean; 8 | 9 | /** 10 | * Util auto configuration. 11 | * 12 | * @author Spencer Gibb 13 | * @date 2021/11/12 21:34 14 | */ 15 | @EnableConfigurationProperties(InetUtilsProperties.class) 16 | public class UtilAutoConfiguration { 17 | 18 | @Bean 19 | @ConditionalOnMissingBean 20 | public InetUtils hippo4JInetUtils(InetUtilsProperties properties) { 21 | return new InetUtils(properties); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.config; 2 | 3 | import com.baomidou.mybatisplus.annotation.DbType; 4 | import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; 5 | import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | * Mybatis plus config. 11 | * 12 | * @author chen.ma 13 | * @date 2021/6/29 20:22 14 | */ 15 | @Configuration 16 | public class MybatisPlusConfig { 17 | 18 | @Bean 19 | public MybatisPlusInterceptor mybatisPlusInterceptor() { 20 | MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); 21 | interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); 22 | return interceptor; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/InstanceRegistry.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.discovery.core; 2 | 3 | import cn.hippo4j.common.model.InstanceInfo; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Instance registry. 9 | * 10 | * @author chen.ma 11 | * @date 2021/8/8 22:31 12 | */ 13 | public interface InstanceRegistry { 14 | 15 | /** 16 | * List instance. 17 | * 18 | * @param appName 19 | * @return 20 | */ 21 | List> listInstance(String appName); 22 | 23 | /** 24 | * Register. 25 | * 26 | * @param info 27 | */ 28 | void register(T info); 29 | 30 | /** 31 | * Renew. 32 | * 33 | * @param instanceRenew 34 | * @return 35 | */ 36 | boolean renew(InstanceInfo.InstanceRenew instanceRenew); 37 | 38 | /** 39 | * Remove. 40 | * 41 | * @param info 42 | */ 43 | void remove(T info); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": [ 3 | { 4 | "name": "spring.dynamic.thread-pool.server-addr", 5 | "type": "java.lang.String", 6 | "defaultValue": "localhost:6691", 7 | "description": "dynamic thread-pool server address." 8 | }, 9 | { 10 | "name": "spring.dynamic.thread-pool.namespace", 11 | "type": "java.lang.String", 12 | "defaultValue": "public", 13 | "description": "dynamic thread-pool namespace." 14 | }, 15 | { 16 | "name": "spring.dynamic.thread-pool.item-id", 17 | "type": "java.lang.String", 18 | "description": "dynamic thread-pool item-id." 19 | }, 20 | { 21 | "name": "spring.dynamic.thread-pool.banner", 22 | "type": "java.lang.Boolean", 23 | "defaultValue": true, 24 | "description": "dynamic thread-pool banner." 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/SendMessageHandler.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import cn.hippo4j.common.model.PoolParameterInfo; 4 | import cn.hippo4j.starter.core.DynamicThreadPoolExecutor; 5 | 6 | /** 7 | * Send message handler. 8 | * 9 | * @author chen.ma 10 | * @date 2021/8/15 15:44 11 | */ 12 | public interface SendMessageHandler { 13 | 14 | /** 15 | * Get type. 16 | * 17 | * @return 18 | */ 19 | String getType(); 20 | 21 | /** 22 | * Send alarm message. 23 | * 24 | * @param notifyConfig 25 | * @param threadPoolExecutor 26 | */ 27 | void sendAlarmMessage(NotifyDTO notifyConfig, DynamicThreadPoolExecutor threadPoolExecutor); 28 | 29 | /** 30 | * Send change message. 31 | * 32 | * @param notifyConfig 33 | * @param parameter 34 | */ 35 | void sendChangeMessage(NotifyDTO notifyConfig, PoolParameterInfo parameter); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hippo4j-tools/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | cn.hippo4j 8 | hippo4j-all 9 | ${revision} 10 | 11 | 12 | hippo4j-tools 13 | pom 14 | 15 | tools 16 | 动态线程池工具类模块 17 | 18 | 19 | true 20 | 21 | 22 | 23 | 24 | log-record-tool 25 | 26 | 27 | open-change-tool 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/event/ConfigDataChangeEvent.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.event; 2 | 3 | import org.springframework.util.StringUtils; 4 | 5 | /** 6 | * Config data change event. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/24 23:35 10 | */ 11 | public class ConfigDataChangeEvent extends Event { 12 | 13 | public final String tenantId; 14 | 15 | public final String itemId; 16 | 17 | public final String tpId; 18 | 19 | public final long lastModifiedTs; 20 | 21 | public ConfigDataChangeEvent(String tenantId, String itemId, String tpId, Long gmtModified) { 22 | if (StringUtils.isEmpty(tenantId) || StringUtils.isEmpty(itemId) || StringUtils.isEmpty(tpId)) { 23 | throw new IllegalArgumentException("DataId is null or group is null"); 24 | } 25 | 26 | this.tenantId = tenantId; 27 | this.itemId = itemId; 28 | this.tpId = tpId; 29 | this.lastModifiedTs = gmtModified; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/js/chunk-04a4268a.c9a819e9.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-04a4268a"],{"386d":function(n,t,e){"use strict";var r=e("cb7c"),a=e("83a1"),i=e("5f1b");e("214f")("search",1,(function(n,t,e,o){return[function(e){var r=n(this),a=void 0==e?void 0:e[t];return void 0!==a?a.call(e,r):new RegExp(e)[t](String(r))},function(n){var t=o(e,n,this);if(t.done)return t.value;var c=r(n),u=String(this),d=c.lastIndex;a(d,0)||(c.lastIndex=0);var l=i(c,u);return a(c.lastIndex,d)||(c.lastIndex=d),null===l?-1:l.index}]}))},"83a1":function(n,t){n.exports=Object.is||function(n,t){return n===t?0!==n||1/n===1/t:n!=n&&t!=t}},b829:function(n,t,e){"use strict";e.r(t);e("386d");var r,a,i={name:"AuthRedirect",created:function(){var n=window.location.search.slice(1);window.localStorage&&(window.localStorage.setItem("x-admin-oauth-code",n),window.close())},render:function(n){return n()}},o=i,c=e("2877"),u=Object(c["a"])(o,r,a,!1,null,null,null);t["default"]=u.exports}}]); -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/BootstrapProperties.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.config; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | 8 | /** 9 | * Bootstrap properties. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/22 09:14 13 | */ 14 | @Slf4j 15 | @Getter 16 | @Setter 17 | @ConfigurationProperties(prefix = BootstrapProperties.PREFIX) 18 | public class BootstrapProperties { 19 | 20 | public static final String PREFIX = "spring.dynamic.thread-pool"; 21 | 22 | /** 23 | * serverAddr 24 | */ 25 | private String serverAddr; 26 | 27 | /** 28 | * namespace 29 | */ 30 | private String namespace; 31 | 32 | /** 33 | * itemId 34 | */ 35 | private String itemId; 36 | 37 | /** 38 | * Enable banner 39 | */ 40 | private boolean banner = true; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/controller/PoolRunStateController.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.controller; 2 | 3 | import cn.hippo4j.starter.handler.ThreadPoolRunStateHandler; 4 | import cn.hippo4j.common.model.PoolRunStateInfo; 5 | import cn.hippo4j.common.web.base.Result; 6 | import cn.hippo4j.common.web.base.Results; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * Pool run state controller. 13 | * 14 | * @author chen.ma 15 | * @date 2021/7/7 21:34 16 | */ 17 | @RestController 18 | public class PoolRunStateController { 19 | 20 | @GetMapping("/run/state/{tpId}") 21 | public Result getPoolRunState(@PathVariable("tpId") String tpId) { 22 | PoolRunStateInfo poolRunState = ThreadPoolRunStateHandler.getPoolRunState(tpId); 23 | return Results.success(poolRunState); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/service/PermissionService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.service; 2 | 3 | import cn.hippo4j.auth.model.biz.permission.PermissionRespDTO; 4 | import com.baomidou.mybatisplus.core.metadata.IPage; 5 | 6 | /** 7 | * Permission service. 8 | * 9 | * @author chen.ma 10 | * @date 2021/10/30 22:13 11 | */ 12 | public interface PermissionService { 13 | 14 | /** 15 | * 分页查询权限列表. 16 | * 17 | * @param pageNo 18 | * @param pageSize 19 | * @return 20 | */ 21 | IPage listPermission(int pageNo, int pageSize); 22 | 23 | /** 24 | * 新增权限. 25 | * 26 | * @param role 27 | * @param resource 28 | * @param action 29 | */ 30 | void addPermission(String role, String resource, String action); 31 | 32 | /** 33 | * 删除权限. 34 | * 35 | * @param role 36 | * @param resource 37 | * @param action 38 | */ 39 | void deletePermission(String role, String resource, String action); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hippo4j-discovery/src/main/java/cn/hippo4j/discovery/core/StatusOverrideResult.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.discovery.core; 2 | 3 | import cn.hippo4j.common.model.InstanceInfo.InstanceStatus; 4 | 5 | /** 6 | * Status override result. 7 | * 8 | * @author chen.ma 9 | * @date 2021/8/8 23:11 10 | */ 11 | public class StatusOverrideResult { 12 | 13 | public static StatusOverrideResult NO_MATCH = new StatusOverrideResult(false, null); 14 | 15 | public static StatusOverrideResult matchingStatus(InstanceStatus status) { 16 | return new StatusOverrideResult(true, status); 17 | } 18 | 19 | private final boolean matches; 20 | 21 | private final InstanceStatus status; 22 | 23 | private StatusOverrideResult(boolean matches, InstanceStatus status) { 24 | this.matches = matches; 25 | this.status = status; 26 | } 27 | 28 | public boolean matches() { 29 | return matches; 30 | } 31 | 32 | public InstanceStatus status() { 33 | return status; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/notify/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.notify; 2 | 3 | import cn.hippo4j.config.notify.listener.Subscriber; 4 | import cn.hippo4j.config.event.Event; 5 | 6 | /** 7 | * Event publisher. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/23 18:58 11 | */ 12 | public interface EventPublisher { 13 | 14 | /** 15 | * Init. 16 | * 17 | * @param type 18 | * @param bufferSize 19 | */ 20 | void init(Class type, int bufferSize); 21 | 22 | /** 23 | * Add subscriber. 24 | * 25 | * @param subscriber 26 | */ 27 | void addSubscriber(Subscriber subscriber); 28 | 29 | /** 30 | * Publish. 31 | * 32 | * @param event 33 | * @return 34 | */ 35 | boolean publish(Event event); 36 | 37 | /** 38 | * Notify subscriber. 39 | * 40 | * @param subscriber 41 | * @param event 42 | */ 43 | void notifySubscriber(Subscriber subscriber, Event event); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/RoleInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Role info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/10/30 22:54 13 | */ 14 | @Data 15 | @TableName("role") 16 | public class RoleInfo { 17 | 18 | /** 19 | * id 20 | */ 21 | @TableId 22 | private Long id; 23 | 24 | /** 25 | * role 26 | */ 27 | private String role; 28 | 29 | /** 30 | * userName 31 | */ 32 | private String userName; 33 | 34 | /** 35 | * gmtCreate 36 | */ 37 | @TableField(fill = FieldFill.INSERT) 38 | private Date gmtCreate; 39 | 40 | /** 41 | * gmtModified 42 | */ 43 | @TableField(fill = FieldFill.INSERT_UPDATE) 44 | private Date gmtModified; 45 | 46 | /** 47 | * delFlag 48 | */ 49 | @TableLogic 50 | @TableField(fill = FieldFill.INSERT) 51 | private Integer delFlag; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/ByteConvertUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit; 2 | 3 | /** 4 | * 字节转换工具类. 5 | * 6 | * @author chen.ma 7 | * @date 2021/11/20 12:21 8 | */ 9 | public class ByteConvertUtil { 10 | 11 | /** 12 | * 字节转换. 13 | * 14 | * @param size 15 | * @return 16 | */ 17 | public static String getPrintSize(long size) { 18 | long covertNum = 1024; 19 | if (size < covertNum) { 20 | return size + "B"; 21 | } else { 22 | size = size / covertNum; 23 | } 24 | if (size < covertNum) { 25 | return size + "KB"; 26 | } else { 27 | size = size / covertNum; 28 | } 29 | if (size < covertNum) { 30 | size = size * 100; 31 | return (size / 100) + "." + (size % 100) + "MB"; 32 | } else { 33 | size = size * 100 / covertNum; 34 | return (size / 100) + "." + (size % 100) + "GB"; 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/executor/ExecutorFactory.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.executor; 2 | 3 | import java.util.concurrent.Executors; 4 | import java.util.concurrent.ScheduledExecutorService; 5 | import java.util.concurrent.ThreadFactory; 6 | 7 | /** 8 | * Executor factory. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/23 18:35 12 | */ 13 | public class ExecutorFactory { 14 | 15 | public static final class Managed { 16 | 17 | private static final String DEFAULT_NAMESPACE = "dynamic.thread-pool"; 18 | 19 | private static final ThreadPoolManager THREAD_POOL_MANAGER = ThreadPoolManager.getInstance(); 20 | 21 | public static ScheduledExecutorService newSingleScheduledExecutorService(String group, ThreadFactory threadFactory) { 22 | ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1, threadFactory); 23 | THREAD_POOL_MANAGER.register(DEFAULT_NAMESPACE, group, executorService); 24 | return executorService; 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/toolkit/ReturnT.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.toolkit; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * ReturnT. 10 | * 11 | * @author chen.ma 12 | * @date 2021/11/10 00:00 13 | */ 14 | @Data 15 | @NoArgsConstructor 16 | public class ReturnT implements Serializable { 17 | 18 | public static final long serialVersionUID = 42L; 19 | 20 | public static final int SUCCESS_CODE = 200; 21 | public static final int FAIL_CODE = 500; 22 | 23 | public static final ReturnT SUCCESS = new ReturnT<>(null); 24 | public static final ReturnT FAIL = new ReturnT<>(FAIL_CODE, null); 25 | 26 | private int code; 27 | private String msg; 28 | private T content; 29 | 30 | public ReturnT(int code, String msg) { 31 | this.code = code; 32 | this.msg = msg; 33 | } 34 | 35 | public ReturnT(T content) { 36 | this.code = SUCCESS_CODE; 37 | this.content = content; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.service; 2 | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; 4 | import cn.hippo4j.auth.model.biz.role.RoleRespDTO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * Role service. 10 | * 11 | * @author chen.ma 12 | * @date 2021/10/30 22:45 13 | */ 14 | public interface RoleService { 15 | 16 | /** 17 | * 分页查询角色列表. 18 | * 19 | * @param pageNo 20 | * @param pageSize 21 | * @return 22 | */ 23 | IPage listRole(int pageNo, int pageSize); 24 | 25 | /** 26 | * 新增角色. 27 | * 28 | * @param role 29 | * @param userName 30 | */ 31 | void addRole(String role, String userName); 32 | 33 | /** 34 | * 删除角色. 35 | * 36 | * @param role 37 | * @param userName 38 | */ 39 | void deleteRole(String role, String userName); 40 | 41 | /** 42 | * 根据角色模糊搜索. 43 | * 44 | * @param role 45 | * @return 46 | */ 47 | List getRoleLike(String role); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigServletInner.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | import java.util.Map; 9 | 10 | /** 11 | * Config servlet inner. 12 | * 13 | * @author chen.ma 14 | * @date 2021/6/22 23:13 15 | */ 16 | @Service 17 | public class ConfigServletInner { 18 | 19 | @Autowired 20 | private LongPollingService longPollingService; 21 | 22 | public String doPollingConfig(HttpServletRequest request, HttpServletResponse response, Map clientMd5Map, int probeRequestSize) { 23 | if (LongPollingService.isSupportLongPolling(request)) { 24 | longPollingService.addLongPollingClient(request, response, clientMd5Map, probeRequestSize); 25 | return HttpServletResponse.SC_OK + ""; 26 | } 27 | return HttpServletResponse.SC_OK + ""; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/controller/DashboardController.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.controller; 2 | 3 | import cn.hippo4j.common.constant.Constants; 4 | import cn.hippo4j.common.web.base.Result; 5 | import cn.hippo4j.common.web.base.Results; 6 | import cn.hippo4j.console.model.ChartInfo; 7 | import cn.hippo4j.console.service.DashboardService; 8 | import lombok.AllArgsConstructor; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | /** 14 | * Dash board controller. 15 | * 16 | * @author chen.ma 17 | * @date 2021/11/10 21:03 18 | */ 19 | @RestController 20 | @AllArgsConstructor 21 | @RequestMapping(Constants.BASE_PATH + "/dashboard") 22 | public class DashboardController { 23 | 24 | private final DashboardService dashboardService; 25 | 26 | @GetMapping 27 | public Result dashboard() { 28 | return Results.success(dashboardService.getChartInfo()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolConfigService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import cn.hippo4j.starter.remote.HttpAgent; 4 | 5 | import java.util.Arrays; 6 | 7 | /** 8 | * ThreadPool config service. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/21 21:50 12 | */ 13 | public class ThreadPoolConfigService implements ConfigService { 14 | 15 | private final ClientWorker clientWorker; 16 | 17 | public ThreadPoolConfigService(HttpAgent httpAgent, String identification) { 18 | clientWorker = new ClientWorker(httpAgent, identification); 19 | } 20 | 21 | @Override 22 | public void addListener(String tenantId, String itemId, String tpId, Listener listener) { 23 | clientWorker.addTenantListeners(tenantId, itemId, tpId, Arrays.asList(listener)); 24 | } 25 | 26 | @Override 27 | public String getServerStatus() { 28 | if (clientWorker.isHealthServer()) { 29 | return "UP"; 30 | } else { 31 | return "DOWN"; 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/impl/DefaultFunctionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service.impl; 2 | 3 | import cn.hippo4j.tools.logrecord.service.FunctionService; 4 | import cn.hippo4j.tools.logrecord.service.ParseFunction; 5 | import lombok.AllArgsConstructor; 6 | 7 | /** 8 | * 默认实现函数接口. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/24 21:54 12 | */ 13 | @AllArgsConstructor 14 | public class DefaultFunctionServiceImpl implements FunctionService { 15 | 16 | private final ParseFunctionFactory parseFunctionFactory; 17 | 18 | @Override 19 | public String apply(String functionName, String value) { 20 | ParseFunction function = parseFunctionFactory.getFunction(functionName); 21 | if (function == null) { 22 | return value; 23 | } 24 | return function.apply(value); 25 | } 26 | 27 | @Override 28 | public boolean beforeFunction(String functionName) { 29 | return parseFunctionFactory.isBeforeFunction(functionName); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/NotifyDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import lombok.Data; 4 | import lombok.experimental.Accessors; 5 | 6 | /** 7 | * 通知实体. 8 | * 9 | * @author chen.ma 10 | * @date 2021/11/17 22:12 11 | */ 12 | @Data 13 | @Accessors(chain = true) 14 | public class NotifyDTO { 15 | 16 | /** 17 | * 租户id 18 | */ 19 | private String tenantId; 20 | 21 | /** 22 | * 项目id 23 | */ 24 | private String itemId; 25 | 26 | /** 27 | * 线程池id 28 | */ 29 | private String tpId; 30 | 31 | /** 32 | * 通知平台 33 | */ 34 | private String platform; 35 | 36 | /** 37 | * 通知类型 38 | */ 39 | private String type; 40 | 41 | /** 42 | * 密钥 43 | */ 44 | private String secretKey; 45 | 46 | /** 47 | * 报警间隔 48 | */ 49 | private Integer interval; 50 | 51 | /** 52 | * 接收者 53 | */ 54 | private String receives; 55 | 56 | /** 57 | * 报警类型 58 | */ 59 | private MessageTypeEnum typeEnum; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /hippo4j-tools/open-change-tool/src/main/java/cn/hippo4j/tools/openchange/OpenChangeNotifyConfig.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.openchange; 2 | 3 | import com.dtflys.forest.springboot.annotation.ForestScan; 4 | import lombok.AllArgsConstructor; 5 | import org.springframework.boot.autoconfigure.ImportAutoConfiguration; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.scheduling.annotation.EnableScheduling; 8 | 9 | /** 10 | * 项目变更通知配置. 11 | * 12 | * @author chen.ma 13 | * @date 2021/10/31 10:23 14 | */ 15 | @EnableScheduling 16 | @AllArgsConstructor 17 | @ImportAutoConfiguration(OpenChangeNotifyBootstrapProperties.class) 18 | @ForestScan(basePackages = "com.github.dynamic.threadpool.openchange") 19 | public class OpenChangeNotifyConfig { 20 | 21 | private final GitHubRemote gitHubRemote; 22 | 23 | private final OpenChangeNotifyBootstrapProperties bootstrapProperties; 24 | 25 | @Bean 26 | public OpenChangeTimedTask changeTimedTask() { 27 | return new OpenChangeTimedTask(gitHubRemote, bootstrapProperties); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.notify; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 消息通知入参实体. 7 | * 8 | * @author chen.ma 9 | * @date 2021/11/18 20:15 10 | */ 11 | @Data 12 | public class NotifyReqDTO { 13 | 14 | /** 15 | * id 16 | */ 17 | private String id; 18 | 19 | /** 20 | * 租户id 21 | */ 22 | private String tenantId; 23 | 24 | /** 25 | * 项目id 26 | */ 27 | private String itemId; 28 | 29 | /** 30 | * 线程池id 31 | */ 32 | private String tpId; 33 | 34 | /** 35 | * 通知平台 36 | */ 37 | private String platform; 38 | 39 | /** 40 | * 通知类型 41 | */ 42 | private String type; 43 | 44 | /** 45 | * 密钥 46 | */ 47 | private String secretKey; 48 | 49 | /** 50 | * 报警间隔 51 | */ 52 | private Integer interval; 53 | 54 | /** 55 | * 接收者 56 | */ 57 | private String receives; 58 | 59 | /** 60 | * 是否启用 61 | */ 62 | private Integer enable; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/notify/NotifyRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.notify; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 消息通知返回. 7 | * 8 | * @author chen.ma 9 | * @date 2021/11/18 20:07 10 | */ 11 | @Data 12 | public class NotifyRespDTO { 13 | 14 | /** 15 | * id 16 | */ 17 | private String id; 18 | 19 | /** 20 | * 租户id 21 | */ 22 | private String tenantId; 23 | 24 | /** 25 | * 项目id 26 | */ 27 | private String itemId; 28 | 29 | /** 30 | * 线程池id 31 | */ 32 | private String tpId; 33 | 34 | /** 35 | * 通知平台 36 | */ 37 | private String platform; 38 | 39 | /** 40 | * 通知类型 41 | */ 42 | private String type; 43 | 44 | /** 45 | * 密钥 46 | */ 47 | private String secretKey; 48 | 49 | /** 50 | * 报警间隔 51 | */ 52 | private Integer interval; 53 | 54 | /** 55 | * 接收者 56 | */ 57 | private String receives; 58 | 59 | /** 60 | * 是否启用 61 | */ 62 | private Integer enable; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /hippo4j-tools/open-change-tool/src/main/java/cn/hippo4j/tools/openchange/OpenChangeInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.openchange; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Open change info. 7 | * 8 | * @author chen.ma 9 | * @date 2021/10/31 10:33 10 | */ 11 | @Data 12 | public class OpenChangeInfo { 13 | 14 | /** 15 | * name 16 | */ 17 | private String name; 18 | 19 | /** 20 | * stars 21 | */ 22 | private Long stargazers_count; 23 | 24 | /** 25 | * forks 26 | */ 27 | private Long forks_count; 28 | 29 | /** 30 | * open issues 31 | */ 32 | private Long open_issues_count; 33 | 34 | /** 35 | * url 36 | */ 37 | private String html_url; 38 | 39 | /** 40 | * subscribers 41 | */ 42 | private Long subscribers_count; 43 | 44 | /** 45 | * default branch 46 | */ 47 | private String default_branch; 48 | 49 | /** 50 | * star_add 51 | */ 52 | private Long star_add; 53 | 54 | /** 55 | * fork_add 56 | */ 57 | 58 | private Long fork_add; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/CorsConfig.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.web.cors.CorsConfiguration; 5 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 6 | import org.springframework.web.filter.CorsFilter; 7 | 8 | /** 9 | * Cors config. 10 | * 11 | * @author chen.ma 12 | * @date 2021/11/12 21:46 13 | */ 14 | public class CorsConfig { 15 | 16 | private CorsConfiguration buildConfig() { 17 | CorsConfiguration corsConfiguration = new CorsConfiguration(); 18 | corsConfiguration.addAllowedOrigin("*"); 19 | corsConfiguration.addAllowedHeader("*"); 20 | corsConfiguration.addAllowedMethod("GET"); 21 | return corsConfiguration; 22 | } 23 | 24 | @Bean 25 | public CorsFilter corsFilter() { 26 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 27 | source.registerCorsConfiguration("/**", buildConfig()); 28 | return new CorsFilter(source); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/toolkit/SimpleReadWriteLock.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.toolkit; 2 | 3 | /** 4 | * Simple read write lock. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/24 21:26 8 | */ 9 | public class SimpleReadWriteLock { 10 | 11 | private int status = 0; 12 | 13 | public synchronized boolean tryReadLock() { 14 | if (isWriteLocked()) { 15 | return false; 16 | } else { 17 | status++; 18 | return true; 19 | } 20 | } 21 | 22 | public synchronized void releaseReadLock() { 23 | status--; 24 | } 25 | 26 | public synchronized boolean tryWriteLock() { 27 | if (!isFree()) { 28 | return false; 29 | } else { 30 | status = -1; 31 | return true; 32 | } 33 | } 34 | 35 | public synchronized void releaseWriteLock() { 36 | status = 0; 37 | } 38 | 39 | private boolean isWriteLocked() { 40 | return status < 0; 41 | } 42 | 43 | private boolean isFree() { 44 | return status == 0; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/toolkit/SingletonRepository.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.toolkit; 2 | 3 | import java.util.concurrent.ConcurrentHashMap; 4 | 5 | /** 6 | * Singleton repository. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/24 21:28 10 | */ 11 | public class SingletonRepository { 12 | 13 | public SingletonRepository() { 14 | shared = new ConcurrentHashMap(1 << 16); 15 | } 16 | 17 | public T getSingleton(T obj) { 18 | T previous = shared.putIfAbsent(obj, obj); 19 | return (null == previous) ? obj : previous; 20 | } 21 | 22 | public int size() { 23 | return shared.size(); 24 | } 25 | 26 | public void remove(Object obj) { 27 | shared.remove(obj); 28 | } 29 | 30 | private final ConcurrentHashMap shared; 31 | 32 | public static class DataIdGroupIdCache { 33 | 34 | public static String getSingleton(String str) { 35 | return cache.getSingleton(str); 36 | } 37 | 38 | static SingletonRepository cache = new SingletonRepository(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/UserInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * User info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/10/30 21:37 13 | */ 14 | @Data 15 | @TableName("user") 16 | public class UserInfo { 17 | 18 | /** 19 | * id 20 | */ 21 | @TableId 22 | private Long id; 23 | 24 | /** 25 | * userName 26 | */ 27 | private String userName; 28 | 29 | /** 30 | * password 31 | */ 32 | private String password; 33 | 34 | /** 35 | * role 36 | */ 37 | private String role; 38 | 39 | /** 40 | * gmtCreate 41 | */ 42 | @TableField(fill = FieldFill.INSERT) 43 | private Date gmtCreate; 44 | 45 | /** 46 | * gmtModified 47 | */ 48 | @TableField(fill = FieldFill.INSERT_UPDATE) 49 | private Date gmtModified; 50 | 51 | /** 52 | * delFlag 53 | */ 54 | @TableLogic 55 | @TableField(fill = FieldFill.INSERT) 56 | private Integer delFlag; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/tenant/TenantRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.tenant; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Tenant resp dto. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/29 21:16 13 | */ 14 | @Data 15 | public class TenantRespDTO { 16 | 17 | /** 18 | * ID 19 | */ 20 | private Integer id; 21 | 22 | /** 23 | * tenantId 24 | */ 25 | private String tenantId; 26 | 27 | /** 28 | * tenantName 29 | */ 30 | private String tenantName; 31 | 32 | /** 33 | * tenantDesc 34 | */ 35 | private String tenantDesc; 36 | 37 | /** 38 | * owner 39 | */ 40 | private String owner; 41 | 42 | /** 43 | * gmtCreate 44 | */ 45 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 46 | private Date gmtCreate; 47 | 48 | /** 49 | * gmtModified 50 | */ 51 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 52 | private Date gmtModified; 53 | } 54 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/PermissionInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Permission info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/10/30 22:33 13 | */ 14 | @Data 15 | @TableName("permission") 16 | public class PermissionInfo { 17 | 18 | /** 19 | * id 20 | */ 21 | @TableId 22 | private Long id; 23 | 24 | /** 25 | * role 26 | */ 27 | private String role; 28 | 29 | /** 30 | * resource 31 | */ 32 | private String resource; 33 | 34 | /** 35 | * action 36 | */ 37 | private String action; 38 | 39 | /** 40 | * gmtCreate 41 | */ 42 | @TableField(fill = FieldFill.INSERT) 43 | private Date gmtCreate; 44 | 45 | /** 46 | * gmtModified 47 | */ 48 | @TableField(fill = FieldFill.INSERT_UPDATE) 49 | private Date gmtModified; 50 | 51 | /** 52 | * delFlag 53 | */ 54 | @TableLogic 55 | @TableField(fill = FieldFill.INSERT) 56 | private Integer delFlag; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/config/MyMetaObjectHandler.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.config; 2 | 3 | import cn.hippo4j.config.enums.DelEnum; 4 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.ibatis.reflection.MetaObject; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Date; 10 | 11 | /** 12 | * Meta object handler. 13 | * 14 | * @author chen.ma 15 | * @date 2021/7/1 22:43 16 | */ 17 | @Slf4j 18 | @Component 19 | public class MyMetaObjectHandler implements MetaObjectHandler { 20 | 21 | @Override 22 | public void insertFill(MetaObject metaObject) { 23 | this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date()); 24 | this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date()); 25 | 26 | this.strictInsertFill(metaObject, "delFlag", Integer.class, DelEnum.NORMAL.getIntCode()); 27 | } 28 | 29 | @Override 30 | public void updateFill(MetaObject metaObject) { 31 | this.strictInsertFill(metaObject, "gmtModified", Date.class, new Date()); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/js/chunk-434632c4.a264a0ed.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-434632c4"],{"461f":function(t,e,n){"use strict";n("b1cb")},ab3b:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("split-pane",{attrs:{split:"vertical"},on:{resize:t.resize}},[n("template",{slot:"paneL"},[n("el-input",{attrs:{type:"textarea",rows:36,placeholder:"请输入内容",clearable:""},on:{change:t.originChange},model:{value:t.originText,callback:function(e){t.originText=e},expression:"originText"}})],1),t._v(" "),n("template",{slot:"paneR"},[n("div",{staticClass:"editor-container"},[n("JSONEditor",{attrs:{json:t.formatedValue}})],1)])],2)],1)},i=[],o=n("19ab"),r=n.n(o),s=n("33c3"),c={name:"JsonFormat",components:{splitPane:r.a,JSONEditor:s["a"]},data:function(){return{originText:"",formatedValue:""}},watch:{originText:function(t){try{this.formatedValue=JSON.parse(t)}catch(e){}}},methods:{resize:function(){},originChange:function(t){}}},l=c,u=(n("461f"),n("2877")),p=Object(u["a"])(l,a,i,!1,null,"7505e034",null);e["default"]=p.exports},b1cb:function(t,e,n){}}]); -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/handler/TenantIdFunctionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.handler; 2 | 3 | import cn.hippo4j.config.model.biz.tenant.TenantRespDTO; 4 | import cn.hippo4j.config.service.biz.TenantService; 5 | import cn.hippo4j.tools.logrecord.service.ParseFunction; 6 | import lombok.AllArgsConstructor; 7 | import org.springframework.stereotype.Component; 8 | 9 | import java.util.Optional; 10 | 11 | /** 12 | * 查找原租户名称. 13 | * 14 | * @author chen.ma 15 | * @date 2021/10/24 22:07 16 | */ 17 | @Component 18 | @AllArgsConstructor 19 | public class TenantIdFunctionServiceImpl implements ParseFunction { 20 | 21 | private final TenantService tenantService; 22 | 23 | @Override 24 | public boolean executeBefore() { 25 | return true; 26 | } 27 | 28 | @Override 29 | public String functionName() { 30 | return "TENANT"; 31 | } 32 | 33 | @Override 34 | public String apply(String tenantId) { 35 | TenantRespDTO tenant = tenantService.getTenantById(tenantId); 36 | return Optional.ofNullable(tenant).map(TenantRespDTO::getTenantName).orElse(""); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/item/ItemRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.item; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Item resp dto. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/29 21:15 13 | */ 14 | @Data 15 | public class ItemRespDTO { 16 | 17 | /** 18 | * ID 19 | */ 20 | private Integer id; 21 | 22 | /** 23 | * tenantId 24 | */ 25 | private String tenantId; 26 | 27 | /** 28 | * itemId 29 | */ 30 | private String itemId; 31 | 32 | /** 33 | * itemName 34 | */ 35 | private String itemName; 36 | 37 | /** 38 | * itemDesc 39 | */ 40 | private String itemDesc; 41 | 42 | /** 43 | * owner 44 | */ 45 | private String owner; 46 | 47 | /** 48 | * gmtCreate 49 | */ 50 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 51 | private Date gmtCreate; 52 | 53 | /** 54 | * gmtModified 55 | */ 56 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 57 | private Date gmtModified; 58 | } 59 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/toolkit/RequestUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.toolkit; 2 | 3 | import org.springframework.util.StringUtils; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | import static cn.hippo4j.common.constant.Constants.LONG_PULLING_CLIENT_IDENTIFICATION; 8 | 9 | /** 10 | * Request util. 11 | * 12 | * @author chen.ma 13 | * @date 2021/6/23 18:28 14 | */ 15 | public class RequestUtil { 16 | 17 | private static final String X_REAL_IP = "X-Real-IP"; 18 | 19 | private static final String X_FORWARDED_FOR = "X-Forwarded-For"; 20 | 21 | private static final String X_FORWARDED_FOR_SPLIT_SYMBOL = ","; 22 | 23 | public static String getRemoteIp(HttpServletRequest request) { 24 | String xForwardedFor = request.getHeader(X_FORWARDED_FOR); 25 | if (!StringUtils.isEmpty(xForwardedFor)) { 26 | return xForwardedFor.split(X_FORWARDED_FOR_SPLIT_SYMBOL)[0].trim(); 27 | } 28 | String nginxHeader = request.getHeader(X_REAL_IP); 29 | String ipPort = request.getHeader(LONG_PULLING_CLIENT_IDENTIFICATION); 30 | return StringUtils.isEmpty(nginxHeader) ? ipPort : nginxHeader; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/event/EventExecutor.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.event; 2 | 3 | import cn.hippo4j.common.function.NoArgsConsumer; 4 | import cn.hippo4j.starter.toolkit.thread.QueueTypeEnum; 5 | import cn.hippo4j.starter.toolkit.thread.ThreadPoolBuilder; 6 | 7 | import java.util.concurrent.ExecutorService; 8 | import java.util.concurrent.ThreadPoolExecutor; 9 | 10 | /** 11 | * 事件执行器. 12 | * 13 | * @author chen.ma 14 | * @date 2021/11/8 23:44 15 | */ 16 | public class EventExecutor { 17 | 18 | private static final ExecutorService EVENT_EXECUTOR = ThreadPoolBuilder.builder() 19 | .threadFactory("event-executor") 20 | .corePoolSize(Runtime.getRuntime().availableProcessors()) 21 | .maxPoolNum(Runtime.getRuntime().availableProcessors()) 22 | .workQueue(QueueTypeEnum.ARRAY_BLOCKING_QUEUE, 2048) 23 | .rejected(new ThreadPoolExecutor.DiscardPolicy()) 24 | .build(); 25 | 26 | /** 27 | * 发布事件. 28 | * 29 | * @param consumer 30 | */ 31 | public static void publishEvent(NoArgsConsumer consumer) { 32 | EVENT_EXECUTOR.execute(consumer::accept); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/toolkit/ConfigExecutor.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.toolkit; 2 | 3 | import cn.hippo4j.common.executor.ExecutorFactory; 4 | 5 | import java.util.concurrent.ScheduledExecutorService; 6 | import java.util.concurrent.ScheduledFuture; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | /** 10 | * Config executor. 11 | * 12 | * @author chen.ma 13 | * @date 2021/6/23 18:33 14 | */ 15 | public class ConfigExecutor { 16 | 17 | private static final ScheduledExecutorService LONG_POLLING_EXECUTOR = ExecutorFactory.Managed 18 | .newSingleScheduledExecutorService("default group", r -> new Thread(r, "long-polling")); 19 | 20 | public static void executeLongPolling(Runnable runnable) { 21 | LONG_POLLING_EXECUTOR.execute(runnable); 22 | } 23 | 24 | public static ScheduledFuture scheduleLongPolling(Runnable runnable, long period, TimeUnit unit) { 25 | return LONG_POLLING_EXECUTOR.schedule(runnable, period, unit); 26 | } 27 | 28 | public static void scheduleLongPolling(Runnable runnable, long initialDelay, long period, TimeUnit unit) { 29 | LONG_POLLING_EXECUTOR.scheduleWithFixedDelay(runnable, initialDelay, period, unit); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/lark/LarkAlarmConstants.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm.lark; 2 | 3 | /** 4 | * lark alarm constants. 5 | * 6 | * @author imyzt 7 | * @date 2021-11-23 19:29 8 | */ 9 | public class LarkAlarmConstants { 10 | 11 | /** 12 | * lark bot url 13 | */ 14 | public static final String LARK_BOT_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/"; 15 | 16 | /** 17 | * lark 报警 json文件路径 18 | */ 19 | public static final String ALARM_JSON_PATH = "classpath:properties/lark/alarm.json"; 20 | 21 | /** 22 | * lark 配置变更通知 json文件路径 23 | */ 24 | public static final String NOTICE_JSON_PATH = "classpath:properties/lark/notice.json"; 25 | 26 | /** 27 | * lark at format. openid 28 | * 当配置openid时,机器人可以@人 29 | */ 30 | public static final String LARK_AT_FORMAT_OPENID = ""; 31 | 32 | /** 33 | * lark at format. username 34 | * 当配置username时,只能蓝色字体展示@username,被@人无@提醒 35 | */ 36 | public static final String LARK_AT_FORMAT_USERNAME = "%s"; 37 | 38 | /** 39 | * lark openid prefix 40 | */ 41 | public static final String LARK_OPENID_PREFIX = "ou_"; 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/service/UserService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.service; 2 | 3 | import cn.hippo4j.auth.model.biz.user.UserQueryPageReqDTO; 4 | import cn.hippo4j.auth.model.biz.user.UserRespDTO; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import cn.hippo4j.auth.model.biz.user.UserReqDTO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * User service. 12 | * 13 | * @author chen.ma 14 | * @date 2021/10/30 21:34 15 | */ 16 | public interface UserService { 17 | 18 | /** 19 | * 分页查询用户列表. 20 | * 21 | * @param reqDTO 22 | * @return 23 | */ 24 | IPage listUser(UserQueryPageReqDTO reqDTO); 25 | 26 | /** 27 | * 新增用户. 28 | * 29 | * @param reqDTO 30 | */ 31 | void addUser(UserReqDTO reqDTO); 32 | 33 | /** 34 | * 修改用户. 35 | * 36 | * @param reqDTO 37 | */ 38 | void updateUser(UserReqDTO reqDTO); 39 | 40 | /** 41 | * 删除用户. 42 | * 43 | * @param userName 44 | */ 45 | void deleteUser(String userName); 46 | 47 | /** 48 | * 根据用户名模糊搜索. 49 | * 50 | * @param userName 51 | * @return 52 | */ 53 | List getUserLikeUsername(String userName); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/TenantInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Tenant info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/29 22:04 13 | */ 14 | @Data 15 | @TableName("tenant") 16 | public class TenantInfo { 17 | 18 | /** 19 | * ID 20 | */ 21 | @TableId(type = IdType.AUTO) 22 | private Integer id; 23 | 24 | /** 25 | * tenantId 26 | */ 27 | private String tenantId; 28 | 29 | /** 30 | * tenantName 31 | */ 32 | private String tenantName; 33 | 34 | /** 35 | * tenantDesc 36 | */ 37 | private String tenantDesc; 38 | 39 | /** 40 | * owner 41 | */ 42 | private String owner; 43 | 44 | /** 45 | * gmtCreate 46 | */ 47 | @TableField(fill = FieldFill.INSERT) 48 | private Date gmtCreate; 49 | 50 | /** 51 | * gmtModified 52 | */ 53 | @TableField(fill = FieldFill.INSERT_UPDATE) 54 | private Date gmtModified; 55 | 56 | /** 57 | * delFlag 58 | */ 59 | @TableField(fill = FieldFill.INSERT) 60 | private Integer delFlag; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/AlarmControlHandler.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.alarm; 2 | 3 | import cn.hutool.core.util.IdUtil; 4 | import cn.hutool.core.util.StrUtil; 5 | import com.google.common.cache.Cache; 6 | import com.google.common.collect.Maps; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * 报警控制组件. 12 | * 13 | * @author chen.ma 14 | * @date 2021/10/28 21:24 15 | */ 16 | public class AlarmControlHandler { 17 | 18 | public static Map> THREAD_POOL_ALARM_CACHE = Maps.newConcurrentMap(); 19 | 20 | /** 21 | * 控制消息推送报警频率. 22 | * 23 | * @param alarmControl 24 | * @return 25 | */ 26 | public boolean isSendAlarm(AlarmControlDTO alarmControl) { 27 | Cache cache = THREAD_POOL_ALARM_CACHE.get(alarmControl.buildPk()); 28 | if (cache != null) { 29 | String pkId = cache.getIfPresent(alarmControl.getTypeEnum().name()); 30 | if (StrUtil.isBlank(pkId)) { 31 | // val 无意义 32 | cache.put(alarmControl.getTypeEnum().name(), IdUtil.simpleUUID()); 33 | return true; 34 | } 35 | } 36 | 37 | return false; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/common/CommonDynamicThreadPool.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.common; 2 | 3 | import cn.hippo4j.starter.core.DynamicThreadPoolExecutor; 4 | import cn.hippo4j.starter.toolkit.thread.QueueTypeEnum; 5 | import cn.hippo4j.starter.toolkit.thread.RejectedPolicies; 6 | import cn.hippo4j.starter.toolkit.thread.ThreadPoolBuilder; 7 | 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * Common dynamic threadPool. 12 | * 13 | * @author chen.ma 14 | * @date 2021/6/16 22:35 15 | */ 16 | public class CommonDynamicThreadPool { 17 | 18 | public static DynamicThreadPoolExecutor getInstance(String threadPoolId) { 19 | DynamicThreadPoolExecutor poolExecutor = (DynamicThreadPoolExecutor) ThreadPoolBuilder.builder() 20 | .dynamicPool() 21 | .threadFactory(threadPoolId) 22 | .poolThreadSize(3, 5) 23 | .keepAliveTime(1000L, TimeUnit.SECONDS) 24 | .rejected(RejectedPolicies.runsOldestTaskPolicy()) 25 | .alarmConfig(1, 80, 80) 26 | .workQueue(QueueTypeEnum.RESIZABLE_LINKED_BLOCKING_QUEUE, 512) 27 | .build(); 28 | return poolExecutor; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/model/biz/user/JwtUser.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.model.biz.user; 2 | 3 | import lombok.Data; 4 | import org.springframework.security.core.GrantedAuthority; 5 | import org.springframework.security.core.userdetails.UserDetails; 6 | 7 | import java.util.Collection; 8 | 9 | /** 10 | * Jwt user. 11 | * 12 | * @author chen.ma 13 | * @date 2021/11/9 22:34 14 | */ 15 | @Data 16 | public class JwtUser implements UserDetails { 17 | 18 | /** 19 | * id 20 | */ 21 | private Long id; 22 | 23 | /** 24 | * userName 25 | */ 26 | private String username; 27 | 28 | /** 29 | * password 30 | */ 31 | private String password; 32 | 33 | /** 34 | * authorities 35 | */ 36 | private Collection authorities; 37 | 38 | @Override 39 | public boolean isAccountNonExpired() { 40 | return true; 41 | } 42 | 43 | @Override 44 | public boolean isAccountNonLocked() { 45 | return true; 46 | } 47 | 48 | @Override 49 | public boolean isCredentialsNonExpired() { 50 | return true; 51 | } 52 | 53 | @Override 54 | public boolean isEnabled() { 55 | return true; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/ItemInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Item info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/29 21:53 13 | */ 14 | @Data 15 | @TableName("item") 16 | public class ItemInfo { 17 | 18 | /** 19 | * ID 20 | */ 21 | @TableId(type = IdType.AUTO) 22 | private Integer id; 23 | 24 | /** 25 | * tenantId 26 | */ 27 | private String tenantId; 28 | 29 | /** 30 | * itemId 31 | */ 32 | private String itemId; 33 | 34 | /** 35 | * itemName 36 | */ 37 | private String itemName; 38 | 39 | /** 40 | * itemDesc 41 | */ 42 | private String itemDesc; 43 | 44 | /** 45 | * owner 46 | */ 47 | private String owner; 48 | 49 | /** 50 | * gmtCreate 51 | */ 52 | @TableField(fill = FieldFill.INSERT) 53 | private Date gmtCreate; 54 | 55 | /** 56 | * gmtModified 57 | */ 58 | @TableField(fill = FieldFill.INSERT_UPDATE) 59 | private Date gmtModified; 60 | 61 | /** 62 | * delFlag 63 | */ 64 | @TableLogic 65 | @TableField(fill = FieldFill.INSERT) 66 | private Integer delFlag; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/parse/LogRecordEvaluationContext.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.parse; 2 | 3 | import cn.hippo4j.tools.logrecord.context.LogRecordContext; 4 | import org.springframework.context.expression.MethodBasedEvaluationContext; 5 | import org.springframework.core.ParameterNameDiscoverer; 6 | 7 | import java.lang.reflect.Method; 8 | import java.util.Map; 9 | 10 | /** 11 | * Log record evaluation context. 12 | * 13 | * @author chen.ma 14 | * @date 2021/10/24 21:25 15 | */ 16 | public class LogRecordEvaluationContext extends MethodBasedEvaluationContext { 17 | 18 | public LogRecordEvaluationContext(Object rootObject, Method method, Object[] arguments, 19 | ParameterNameDiscoverer parameterNameDiscoverer, Object ret, String errorMsg) { 20 | super(rootObject, method, arguments, parameterNameDiscoverer); 21 | 22 | Map variables = LogRecordContext.getVariables(); 23 | if (variables != null && variables.size() > 0) { 24 | for (Map.Entry entry : variables.entrySet()) { 25 | setVariable(entry.getKey(), entry.getValue()); 26 | } 27 | } 28 | 29 | setVariable("_ret", ret); 30 | setVariable("_errorMsg", errorMsg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ServiceException.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.web.exception; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | /** 7 | * Service exception. 8 | * 9 | * @author chen.ma 10 | * @date 2021/3/19 16:14 11 | */ 12 | @Data 13 | @EqualsAndHashCode(callSuper = true) 14 | public class ServiceException extends RuntimeException { 15 | 16 | private static final long serialVersionUID = -8667394300356618037L; 17 | 18 | private String detail; 19 | 20 | public ServiceException(String message) { 21 | super(message); 22 | } 23 | 24 | public ServiceException(String message, String detail) { 25 | super(message); 26 | this.detail = detail; 27 | } 28 | 29 | public ServiceException(String message, Throwable cause) { 30 | super(message, cause); 31 | this.detail = cause.getMessage(); 32 | } 33 | 34 | public ServiceException(String message, String detail, Throwable cause) { 35 | super(message, cause); 36 | this.detail = detail; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "ServiceException{" + 42 | "message='" + getMessage() + "'," + 43 | "detail='" + getDetail() + "'" + 44 | '}'; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/controller/LogRecordController.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.controller; 2 | 3 | import cn.hippo4j.common.constant.Constants; 4 | import cn.hippo4j.common.web.base.Result; 5 | import cn.hippo4j.common.web.base.Results; 6 | import cn.hippo4j.config.model.biz.log.LogRecordQueryReqDTO; 7 | import cn.hippo4j.config.model.biz.log.LogRecordRespDTO; 8 | import cn.hippo4j.config.service.biz.LogRecordBizService; 9 | import com.baomidou.mybatisplus.core.metadata.IPage; 10 | import lombok.AllArgsConstructor; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | /** 17 | * Log record controller. 18 | * 19 | * @author chen.ma 20 | * @date 2021/11/17 21:10 21 | */ 22 | @RestController 23 | @AllArgsConstructor 24 | @RequestMapping(Constants.BASE_PATH + "/log") 25 | public class LogRecordController { 26 | 27 | private final LogRecordBizService logRecordBizService; 28 | 29 | @PostMapping("/query/page") 30 | public Result> queryPage(@RequestBody LogRecordQueryReqDTO queryReqDTO) { 31 | return Results.success(logRecordBizService.queryPage(queryReqDTO)); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/context/LogRecordContext.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.context; 2 | 3 | import com.alibaba.ttl.TransmittableThreadLocal; 4 | import com.google.common.collect.Maps; 5 | 6 | import java.util.Map; 7 | import java.util.Stack; 8 | 9 | /** 10 | * 日志记录上下文. 11 | * 12 | * @author chen.ma 13 | * @date 2021/10/23 21:47 14 | */ 15 | public class LogRecordContext { 16 | 17 | private static final ThreadLocal>> VARIABLE_MAP_STACK = new TransmittableThreadLocal(); 18 | 19 | /** 20 | * 出栈. 21 | */ 22 | public static void clear() { 23 | if (VARIABLE_MAP_STACK.get() != null) { 24 | VARIABLE_MAP_STACK.get().pop(); 25 | } 26 | } 27 | 28 | /** 29 | * 初始化. 30 | */ 31 | public static void putEmptySpan() { 32 | Stack> mapStack = VARIABLE_MAP_STACK.get(); 33 | if (mapStack == null) { 34 | Stack> stack = new Stack<>(); 35 | VARIABLE_MAP_STACK.set(stack); 36 | } 37 | 38 | VARIABLE_MAP_STACK.get().push(Maps.newHashMap()); 39 | } 40 | 41 | public static Map getVariables() { 42 | Stack> mapStack = VARIABLE_MAP_STACK.get(); 43 | return mapStack.peek(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /hippo4j-tools/open-change-tool/src/main/java/cn/hippo4j/tools/openchange/OpenChangeNotifyBootstrapProperties.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.openchange; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | * Bootstrap properties. 14 | * 15 | * @author chen.ma 16 | * @date 2021/6/22 09:14 17 | */ 18 | @Slf4j 19 | @Getter 20 | @Setter 21 | @Configuration 22 | @ConfigurationProperties(prefix = OpenChangeNotifyBootstrapProperties.PREFIX) 23 | public class OpenChangeNotifyBootstrapProperties { 24 | 25 | public static final String PREFIX = "spring.dynamic.thread-pool"; 26 | 27 | /** 28 | * notifyInterval 29 | */ 30 | private Long notifyInterval; 31 | 32 | /** 33 | * notifys 34 | */ 35 | private List notifys; 36 | 37 | @Data 38 | public static class NotifyConfig { 39 | 40 | /** 41 | * type 42 | */ 43 | private String type; 44 | 45 | /** 46 | * url 47 | */ 48 | private String url; 49 | 50 | /** 51 | * token 52 | */ 53 | private String token; 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/ThreadPoolOperation.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import cn.hippo4j.starter.config.BootstrapProperties; 4 | 5 | import java.util.concurrent.Executor; 6 | 7 | /** 8 | * ThreadPool operation. 9 | * 10 | * @author chen.ma 11 | * @date 2021/6/22 20:25 12 | */ 13 | public class ThreadPoolOperation { 14 | 15 | private final ConfigService configService; 16 | 17 | private final BootstrapProperties properties; 18 | 19 | public ThreadPoolOperation(BootstrapProperties properties, ConfigService configService) { 20 | this.properties = properties; 21 | this.configService = configService; 22 | } 23 | 24 | public Listener subscribeConfig(String tpId, Executor executor, ThreadPoolSubscribeCallback threadPoolSubscribeCallback) { 25 | Listener configListener = new Listener() { 26 | @Override 27 | public void receiveConfigInfo(String config) { 28 | threadPoolSubscribeCallback.callback(config); 29 | } 30 | 31 | @Override 32 | public Executor getExecutor() { 33 | return executor; 34 | } 35 | }; 36 | 37 | configService.addListener(properties.getNamespace(), properties.getItemId(), tpId, configListener); 38 | 39 | return configListener; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/model/LogRecordInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import org.hibernate.validator.constraints.Length; 8 | 9 | import javax.validation.constraints.NotBlank; 10 | import java.util.Date; 11 | 12 | /** 13 | * 日志记录实体. 14 | * 15 | * @author chen.ma 16 | * @date 2021/10/24 17:47 17 | */ 18 | @Data 19 | @Builder 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | public class LogRecordInfo { 23 | 24 | private Long id; 25 | 26 | private String tenant; 27 | 28 | @NotBlank(message = "bizKey required") 29 | @Length(max = 200, message = "appKey max length is 200") 30 | private String bizKey; 31 | 32 | @NotBlank(message = "bizNo required") 33 | @Length(max = 200, message = "bizNo max length is 200") 34 | private String bizNo; 35 | 36 | @NotBlank(message = "operator required") 37 | @Length(max = 63, message = "operator max length 63") 38 | private String operator; 39 | 40 | @NotBlank(message = "opAction required") 41 | @Length(max = 511, message = "operator max length 511") 42 | private String action; 43 | 44 | private String category; 45 | 46 | private Date createTime; 47 | 48 | private String detail; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolSaveOrUpdateReqDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.threadpool; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Thread pool save or update req dto. 7 | * 8 | * @author chen.ma 9 | * @date 2021/6/30 21:23 10 | */ 11 | @Data 12 | public class ThreadPoolSaveOrUpdateReqDTO { 13 | 14 | /** 15 | * tenantId 16 | */ 17 | private String tenantId; 18 | 19 | /** 20 | * TpId 21 | */ 22 | private String tpId; 23 | 24 | /** 25 | * ItemId 26 | */ 27 | private String itemId; 28 | 29 | /** 30 | * coreSize 31 | */ 32 | private Integer coreSize; 33 | 34 | /** 35 | * maxSize 36 | */ 37 | private Integer maxSize; 38 | 39 | /** 40 | * queueType 41 | */ 42 | private Integer queueType; 43 | 44 | /** 45 | * capacity 46 | */ 47 | private Integer capacity; 48 | 49 | /** 50 | * keepAliveTime 51 | */ 52 | private Integer keepAliveTime; 53 | 54 | /** 55 | * isAlarm 56 | */ 57 | private Integer isAlarm; 58 | 59 | /** 60 | * capacityAlarm 61 | */ 62 | private Integer capacityAlarm; 63 | 64 | /** 65 | * livenessAlarm 66 | */ 67 | private Integer livenessAlarm; 68 | 69 | /** 70 | * rejectedType 71 | */ 72 | private Integer rejectedType; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/web/exception/ErrorCodeEnum.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.web.exception; 2 | 3 | /** 4 | * Error code enum. 5 | * 6 | * @author chen.ma 7 | * @date 2021/3/19 16:07 8 | */ 9 | public enum ErrorCodeEnum { 10 | 11 | UNKNOWN_ERROR { 12 | @Override 13 | public String getCode() { 14 | return "1"; 15 | } 16 | 17 | @Override 18 | public String getMessage() { 19 | return "UNKNOWN_ERROR"; 20 | } 21 | }, 22 | 23 | VALIDATION_ERROR { 24 | @Override 25 | public String getCode() { 26 | return "2"; 27 | } 28 | 29 | @Override 30 | public String getMessage() { 31 | return "VALIDATION_ERROR"; 32 | } 33 | }, 34 | 35 | SERVICE_ERROR { 36 | @Override 37 | public String getCode() { 38 | return "3"; 39 | } 40 | 41 | @Override 42 | public String getMessage() { 43 | return "SERVICE_ERROR"; 44 | } 45 | }, 46 | 47 | NOT_FOUND { 48 | @Override 49 | public String getCode() { 50 | return "404"; 51 | } 52 | 53 | @Override 54 | public String getMessage() { 55 | return "NOT_FOUND"; 56 | } 57 | }; 58 | 59 | public abstract String getCode(); 60 | 61 | public abstract String getMessage(); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/CacheItem.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model; 2 | 3 | import cn.hippo4j.common.toolkit.Md5Util; 4 | import cn.hippo4j.config.toolkit.SimpleReadWriteLock; 5 | import cn.hippo4j.config.toolkit.SingletonRepository; 6 | import cn.hippo4j.common.constant.Constants; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | * Cache item. 12 | * 13 | * @author chen.ma 14 | * @date 2021/6/24 21:23 15 | */ 16 | @Getter 17 | @Setter 18 | public class CacheItem { 19 | 20 | final String groupKey; 21 | 22 | public volatile String md5 = Constants.NULL; 23 | 24 | public volatile long lastModifiedTs; 25 | 26 | public volatile ConfigAllInfo configAllInfo; 27 | 28 | public SimpleReadWriteLock rwLock = new SimpleReadWriteLock(); 29 | 30 | public CacheItem(String groupKey) { 31 | this.groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey); 32 | } 33 | 34 | public CacheItem(String groupKey, String md5) { 35 | this.md5 = md5; 36 | this.groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey); 37 | } 38 | 39 | public CacheItem(String groupKey, ConfigAllInfo configAllInfo) { 40 | this.configAllInfo = configAllInfo; 41 | this.md5 = Md5Util.getTpContentMd5(configAllInfo); 42 | this.groupKey = SingletonRepository.DataIdGroupIdCache.getSingleton(groupKey); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hippo4j-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #*************** Spring Boot Related Configurations ***************# 2 | ### Server Startup Port 3 | server.port=6691 4 | 5 | 6 | #*************** Dynamic Thread Pool Custom Configuration ***************# 7 | ### Custom Logging Tenant 8 | tenant=hippo4j 9 | 10 | 11 | #*************** Config Module Related Configurations ***************# 12 | ### Hikari Datasource 13 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 14 | spring.datasource.url=jdbc:mysql://localhost:3306/hippo_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 15 | spring.datasource.username=root 16 | spring.datasource.password=root 17 | spring.datasource.hikari.pool-name=Hikari 18 | spring.datasource.hikari.connectionTimeout=30000 19 | spring.datasource.hikari.idleTimeout=30000 20 | spring.datasource.hikari.validationTimeout=3000 21 | spring.datasource.hikari.maxLifetime=120000 22 | spring.datasource.hikari.loginTimeout=5 23 | spring.datasource.hikari.minimumIdle=5 24 | spring.datasource.hikari.maximumPoolSize=15 25 | spring.datasource.hikari.connection-test-query=SELECT 1 26 | 27 | ### Mybatis-Plus Config 28 | mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl 29 | mybatis-plus.global-config.db-config.logic-delete-field=delFlag 30 | mybatis-plus.global-config.db-config.logic-delete-value=1 31 | mybatis-plus.global-config.db-config.logic-not-delete-value=0 32 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/NotifyService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz; 2 | 3 | import cn.hippo4j.config.model.biz.notify.NotifyListRespDTO; 4 | import cn.hippo4j.config.model.biz.notify.NotifyQueryReqDTO; 5 | import cn.hippo4j.config.model.biz.notify.NotifyReqDTO; 6 | import cn.hippo4j.config.model.biz.notify.NotifyRespDTO; 7 | import com.baomidou.mybatisplus.core.metadata.IPage; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * 通知管理. 13 | * 14 | * @author chen.ma 15 | * @date 2021/11/17 22:01 16 | */ 17 | public interface NotifyService { 18 | 19 | /** 20 | * 查询通知配置集合. 21 | * 22 | * @param reqDTO 23 | * @return 24 | */ 25 | List listNotifyConfig(NotifyQueryReqDTO reqDTO); 26 | 27 | /** 28 | * 分页查询. 29 | * 30 | * @param reqDTO 31 | * @return 32 | */ 33 | IPage queryPage(NotifyQueryReqDTO reqDTO); 34 | 35 | /** 36 | * 新增通知配置. 37 | * 38 | * @param reqDTO 39 | */ 40 | void save(NotifyReqDTO reqDTO); 41 | 42 | /** 43 | * 修改通知配置. 44 | * 45 | * @param reqDTO 46 | */ 47 | void update(NotifyReqDTO reqDTO); 48 | 49 | /** 50 | * 删除通知配置. 51 | * 52 | * @param reqDTO 53 | */ 54 | void delete(NotifyReqDTO reqDTO); 55 | 56 | /** 57 | * 启用停用通知. 58 | * 59 | * @param id 60 | * @param status 61 | */ 62 | void enableNotify(String id, Integer status); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/annotation/LogRecord.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.annotation; 2 | 3 | import cn.hippo4j.tools.logrecord.enums.LogRecordTypeEnum; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * 日志记录注解. 9 | * 10 | * @author chen.ma 11 | * @date 2021/10/23 21:29 12 | */ 13 | @Documented 14 | @Target({ElementType.METHOD}) 15 | @Retention(RetentionPolicy.RUNTIME) 16 | public @interface LogRecord { 17 | 18 | /** 19 | * 业务前缀 20 | * 21 | * @return 22 | */ 23 | String prefix() default ""; 24 | 25 | /** 26 | * 操作日志文本模版 27 | * 28 | * @return 29 | */ 30 | String success(); 31 | 32 | /** 33 | * 操作日志失败的文本 34 | * 35 | * @return 36 | */ 37 | String fail() default ""; 38 | 39 | /** 40 | * 操作人 41 | * 42 | * @return 43 | */ 44 | String operator() default ""; 45 | 46 | /** 47 | * 业务码 48 | * 49 | * @return 50 | */ 51 | String bizNo(); 52 | 53 | /** 54 | * 日志详情 55 | * 56 | * @return 57 | */ 58 | String detail() default ""; 59 | 60 | /** 61 | * 日志种类 62 | * 63 | * @return 64 | */ 65 | String category(); 66 | 67 | /** 68 | * 记录类型 69 | * 70 | * @return 71 | */ 72 | LogRecordTypeEnum recordType() default LogRecordTypeEnum.COMPLETE; 73 | 74 | /** 75 | * 记录日志条件 76 | * 77 | * @return 78 | */ 79 | String condition() default ""; 80 | 81 | } 82 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/TenantService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz; 2 | 3 | import cn.hippo4j.config.model.biz.tenant.TenantQueryReqDTO; 4 | import cn.hippo4j.config.model.biz.tenant.TenantRespDTO; 5 | import cn.hippo4j.config.model.biz.tenant.TenantSaveReqDTO; 6 | import cn.hippo4j.config.model.biz.tenant.TenantUpdateReqDTO; 7 | import com.baomidou.mybatisplus.core.metadata.IPage; 8 | 9 | /** 10 | * Tenant service. 11 | * 12 | * @author chen.ma 13 | * @date 2021/6/29 21:59 14 | */ 15 | public interface TenantService { 16 | 17 | /** 18 | * Get tenant by id. 19 | * 20 | * @param id 21 | * @return 22 | */ 23 | TenantRespDTO getTenantById(String id); 24 | 25 | /** 26 | * Get tenant by tenantId. 27 | * 28 | * @param tenantId 29 | * @return 30 | */ 31 | TenantRespDTO getTenantByTenantId(String tenantId); 32 | 33 | /** 34 | * Query tenant page. 35 | * 36 | * @param reqDTO 37 | * @return 38 | */ 39 | IPage queryTenantPage(TenantQueryReqDTO reqDTO); 40 | 41 | /** 42 | * Save tenant. 43 | * 44 | * @param reqDTO 45 | */ 46 | void saveTenant(TenantSaveReqDTO reqDTO); 47 | 48 | /** 49 | * Update tenant. 50 | * 51 | * @param reqDTO 52 | */ 53 | void updateTenant(TenantUpdateReqDTO reqDTO); 54 | 55 | /** 56 | * Delete tenant by id. 57 | * 58 | * @param tenantId 59 | */ 60 | void deleteTenantById(String tenantId); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/ArrayUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit; 2 | 3 | import java.lang.reflect.Array; 4 | 5 | /** 6 | * Array util. 7 | * 8 | * @author chen.ma 9 | * @date 2021/7/5 21:54 10 | */ 11 | public class ArrayUtil { 12 | 13 | public static T[] addAll(final T[] array1, @SuppressWarnings("unchecked") final T... array2) { 14 | if (array1 == null) { 15 | return clone(array2); 16 | } else if (array2 == null) { 17 | return clone(array1); 18 | } 19 | final Class type1 = array1.getClass().getComponentType(); 20 | @SuppressWarnings("unchecked") final T[] joinedArray = (T[]) Array.newInstance(type1, array1.length + array2.length); 21 | System.arraycopy(array1, 0, joinedArray, 0, array1.length); 22 | try { 23 | System.arraycopy(array2, 0, joinedArray, array1.length, array2.length); 24 | } catch (final ArrayStoreException ase) { 25 | final Class type2 = array2.getClass().getComponentType(); 26 | if (!type1.isAssignableFrom(type2)) { 27 | throw new IllegalArgumentException("Cannot store " + type2.getName() + " in an array of " 28 | + type1.getName(), ase); 29 | } 30 | throw ase; 31 | } 32 | return joinedArray; 33 | } 34 | 35 | public static T[] clone(final T[] array) { 36 | if (array == null) { 37 | return null; 38 | } 39 | return array.clone(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-server/bin/startup.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1 4 | set "JAVA=%JAVA_HOME%\bin\java.exe" 5 | 6 | setlocal enabledelayedexpansion 7 | 8 | set BASE_DIR=%~dp0 9 | rem added double quotation marks to avoid the issue caused by the folder names containing spaces. 10 | rem removed the last 5 chars(which means \bin\) to get the base DIR. 11 | set BASE_DIR="%BASE_DIR:~0,-5%" 12 | 13 | set CUSTOM_SEARCH_LOCATIONS=%BASE_DIR%/conf/application.properties 14 | 15 | set SERVER=hippo4j-server 16 | 17 | echo "hippo4j is starting with standalone" 18 | set "HIPPO4J_JVM_OPTS=-Xms1024m -Xmx1024m -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof -XX:-UseLargePages" 19 | 20 | set "HIPPO4J_OPTS=%HIPPO4J_OPTS% -Dhippo4j.home=%BASE_DIR%" 21 | set "HIPPO4J_OPTS=%HIPPO4J_OPTS% -jar %BASE_DIR%\target\%SERVER%.jar" 22 | 23 | 24 | rem set hippo4j spring config location 25 | set "HIPPO4J_CONFIG_OPTS=--spring.config.location=%CUSTOM_SEARCH_LOCATIONS%" 26 | set "HIPPO4J_CONFIG_OPTS=%HIPPO4J_OPTS% --server.tomcat.basedir=%BASE_DIR%/bin" 27 | 28 | 29 | rem set hippo4j logback file location 30 | set "HIPPO4J_LOGBACK_OPTS=--logging.config=%BASE_DIR%/conf/hippo4j-logback.xml" 31 | 32 | set COMMAND="%JAVA%" %HIPPO4J_JVM_OPTS% %HIPPO4J_OPTS% %HIPPO4J_CONFIG_OPTS% %HIPPO4J_LOGBACK_OPTS% hippo4j.hippo4j %* 33 | 34 | rem start hippo4j command 35 | %COMMAND% 36 | -------------------------------------------------------------------------------- /hippo4j-example/src/main/java/cn/hippo4j/example/inittest/AlarmSendMessageTest.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.example.inittest; 2 | 3 | import cn.hippo4j.example.constant.GlobalTestConstant; 4 | import cn.hutool.core.thread.ThreadUtil; 5 | import cn.hippo4j.starter.core.GlobalThreadPoolManage; 6 | import cn.hippo4j.starter.wrapper.DynamicThreadPoolWrapper; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.concurrent.Executors; 11 | import java.util.concurrent.ScheduledExecutorService; 12 | import java.util.concurrent.ThreadPoolExecutor; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * Test alarm send message. 17 | * 18 | * @author chen.ma 19 | * @date 2021/8/15 21:03 20 | */ 21 | @Slf4j 22 | @Component 23 | public class AlarmSendMessageTest { 24 | 25 | // @PostConstruct 26 | @SuppressWarnings("all") 27 | public void alarmSendMessageTest() { 28 | ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor(); 29 | scheduledThreadPool.scheduleWithFixedDelay(() -> { 30 | DynamicThreadPoolWrapper poolWrapper = GlobalThreadPoolManage.getExecutorService(GlobalTestConstant.MESSAGE_PRODUCE); 31 | ThreadPoolExecutor poolExecutor = poolWrapper.getExecutor(); 32 | try { 33 | poolExecutor.execute(() -> ThreadUtil.sleep(10240124)); 34 | } catch (Exception ex) { 35 | log.error("Throw reject policy.", ex.getMessage()); 36 | } 37 | }, 3, 1, TimeUnit.SECONDS); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/web/base/Results.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.web.base; 2 | 3 | import cn.hippo4j.common.web.exception.ErrorCodeEnum; 4 | import cn.hippo4j.common.web.exception.ServiceException; 5 | 6 | /** 7 | * Results. 8 | * 9 | * @author chen.ma 10 | * @date 2021/3/19 16:12 11 | */ 12 | public final class Results { 13 | 14 | public static Result success() { 15 | return new Result() 16 | .setCode(Result.SUCCESS_CODE); 17 | } 18 | 19 | public static Result success(T data) { 20 | return new Result() 21 | .setCode(Result.SUCCESS_CODE) 22 | .setData(data); 23 | } 24 | 25 | public static Result failure(ServiceException serviceException) { 26 | return new Result().setCode(ErrorCodeEnum.SERVICE_ERROR.getCode()) 27 | .setMessage(serviceException.getMessage()); 28 | } 29 | 30 | public static Result failure(Throwable throwable) { 31 | return new Result().setCode(ErrorCodeEnum.SERVICE_ERROR.getCode()) 32 | .setMessage(throwable.getMessage()); 33 | } 34 | 35 | public static Result failure(String code, String message) { 36 | return new Result() 37 | .setCode(code) 38 | .setMessage(message); 39 | } 40 | 41 | public static Result failure(ErrorCodeEnum errorCode) { 42 | return new Result() 43 | .setCode(errorCode.getCode()) 44 | .setMessage(errorCode.getMessage()); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hippo4j-console/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | cn.hippo4j 8 | hippo4j-all 9 | ${revision} 10 | 11 | 12 | hippo4j-console 13 | jar 14 | 15 | ${project.artifactId} 16 | ${project.artifactId} 17 | 18 | 19 | true 20 | 21 | 22 | 23 | 24 | cn.hippo4j 25 | hippo4j-config 26 | 27 | 28 | 29 | cn.hippo4j 30 | hippo4j-discovery 31 | 32 | 33 | 34 | cn.hippo4j 35 | hippo4j-auth 36 | 37 | 38 | 39 | 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-maven-plugin 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/model/GlobalRemotePoolInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Global remote pool info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/23 21:08 13 | */ 14 | @Getter 15 | @Setter 16 | public class GlobalRemotePoolInfo implements Serializable { 17 | 18 | private static final long serialVersionUID = 5447003335557127308L; 19 | 20 | /** 21 | * tenantId 22 | */ 23 | private String tenantId; 24 | 25 | /** 26 | * itemId 27 | */ 28 | private String itemId; 29 | 30 | /** 31 | * tpId 32 | */ 33 | private String tpId; 34 | 35 | /** 36 | * coreSize 37 | */ 38 | private Integer coreSize; 39 | 40 | /** 41 | * maxSize 42 | */ 43 | private Integer maxSize; 44 | 45 | /** 46 | * queueType 47 | */ 48 | private Integer queueType; 49 | 50 | /** 51 | * capacity 52 | */ 53 | private Integer capacity; 54 | 55 | /** 56 | * keepAliveTime 57 | */ 58 | private Integer keepAliveTime; 59 | 60 | /** 61 | * isAlarm 62 | */ 63 | private Integer isAlarm; 64 | 65 | /** 66 | * capacityAlarm 67 | */ 68 | private Integer capacityAlarm; 69 | 70 | /** 71 | * livenessAlarm 72 | */ 73 | private Integer livenessAlarm; 74 | 75 | /** 76 | * md5 77 | */ 78 | private String md5; 79 | 80 | /** 81 | * content 82 | */ 83 | private String content; 84 | 85 | } 86 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/ItemService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz; 2 | 3 | import cn.hippo4j.config.model.biz.item.ItemRespDTO; 4 | import cn.hippo4j.config.model.biz.item.ItemUpdateReqDTO; 5 | import com.baomidou.mybatisplus.core.metadata.IPage; 6 | import cn.hippo4j.config.model.biz.item.ItemQueryReqDTO; 7 | import cn.hippo4j.config.model.biz.item.ItemSaveReqDTO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Item service. 13 | * 14 | * @author chen.ma 15 | * @date 2021/6/29 21:57 16 | */ 17 | public interface ItemService { 18 | 19 | /** 20 | * Query item page. 21 | * 22 | * @param reqDTO 23 | * @return 24 | */ 25 | IPage queryItemPage(ItemQueryReqDTO reqDTO); 26 | 27 | /** 28 | * Query item by id. 29 | * 30 | * @param tenantId 31 | * @param itemId 32 | * @return 33 | */ 34 | ItemRespDTO queryItemById(String tenantId, String itemId); 35 | 36 | /** 37 | * Query item. 38 | * 39 | * @param reqDTO 40 | * @return 41 | */ 42 | List queryItem(ItemQueryReqDTO reqDTO); 43 | 44 | /** 45 | * Save item. 46 | * 47 | * @param reqDTO 48 | */ 49 | void saveItem(ItemSaveReqDTO reqDTO); 50 | 51 | /** 52 | * Update item. 53 | * 54 | * @param reqDTO 55 | */ 56 | void updateItem(ItemUpdateReqDTO reqDTO); 57 | 58 | /** 59 | * Delete item. 60 | * 61 | * @param tenantId 62 | * @param itemId 63 | */ 64 | void deleteItem(String tenantId, String itemId); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/ResizableCapacityLinkedBlockIngQueue.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit.thread; 2 | 3 | import cn.hutool.core.util.ReflectUtil; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import java.util.concurrent.LinkedBlockingQueue; 7 | import java.util.concurrent.atomic.AtomicInteger; 8 | 9 | /** 10 | * Resizable capacity linkedBlockIngQueue. 11 | * 12 | * @author chen.ma 13 | * @date 2021/6/20 14:24 14 | */ 15 | @Slf4j 16 | public class ResizableCapacityLinkedBlockIngQueue extends LinkedBlockingQueue { 17 | 18 | public ResizableCapacityLinkedBlockIngQueue(int capacity) { 19 | super(capacity); 20 | } 21 | 22 | public synchronized boolean setCapacity(Integer capacity) { 23 | boolean successFlag = true; 24 | /** 25 | * TODO:后续考虑切换 Rabbitmq VariableLinkedBlockingQueue 26 | */ 27 | try { 28 | int oldCapacity = (int) ReflectUtil.getFieldValue(this, "capacity"); 29 | AtomicInteger count = (AtomicInteger) ReflectUtil.getFieldValue(this, "count"); 30 | int size = count.get(); 31 | 32 | ReflectUtil.setFieldValue(this, "capacity", capacity); 33 | if (capacity > size && size >= oldCapacity) { 34 | ReflectUtil.invoke(this, "signalNotFull"); 35 | } 36 | } catch (Exception ex) { 37 | // ignore 38 | log.error("Dynamic modification of blocking queue size failed.", ex); 39 | successFlag = false; 40 | } 41 | 42 | return successFlag; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/model/PoolParameter.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.model; 2 | 3 | /** 4 | * Pool parameter. 5 | * 6 | * @author chen.ma 7 | * @date 2021/6/24 16:04 8 | */ 9 | public interface PoolParameter { 10 | 11 | /** 12 | * tenantId 13 | * 14 | * @return 15 | */ 16 | String getTenantId(); 17 | 18 | /** 19 | * itemId 20 | * 21 | * @return 22 | */ 23 | String getItemId(); 24 | 25 | /** 26 | * tpId 27 | * 28 | * @return 29 | */ 30 | String getTpId(); 31 | 32 | /** 33 | * coreSize 34 | * 35 | * @return 36 | */ 37 | Integer getCoreSize(); 38 | 39 | /** 40 | * maxSize 41 | * 42 | * @return 43 | */ 44 | Integer getMaxSize(); 45 | 46 | /** 47 | * queueType 48 | * 49 | * @return 50 | */ 51 | Integer getQueueType(); 52 | 53 | /** 54 | * capacity 55 | * 56 | * @return 57 | */ 58 | Integer getCapacity(); 59 | 60 | /** 61 | * keepAliveTime 62 | * 63 | * @return 64 | */ 65 | Integer getKeepAliveTime(); 66 | 67 | /** 68 | * rejectedType 69 | * 70 | * @return 71 | */ 72 | Integer getRejectedType(); 73 | 74 | /** 75 | * isAlarm 76 | * 77 | * @return 78 | */ 79 | Integer getIsAlarm(); 80 | 81 | /** 82 | * capacityAlarm 83 | * 84 | * @return 85 | */ 86 | Integer getCapacityAlarm(); 87 | 88 | /** 89 | * livenessAlarm 90 | * 91 | * @return 92 | */ 93 | Integer getLivenessAlarm(); 94 | 95 | } 96 | -------------------------------------------------------------------------------- /hippo4j-auth/src/main/java/cn/hippo4j/auth/service/impl/UserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.auth.service.impl; 2 | 3 | import cn.hippo4j.auth.mapper.UserMapper; 4 | import cn.hippo4j.auth.model.UserInfo; 5 | import cn.hippo4j.auth.model.biz.user.JwtUser; 6 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | import org.springframework.security.core.userdetails.UserDetails; 9 | import org.springframework.security.core.userdetails.UserDetailsService; 10 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 11 | 12 | import javax.annotation.Resource; 13 | import java.util.Collections; 14 | import java.util.Set; 15 | 16 | /** 17 | * User details service impl. 18 | * 19 | * @author chen.ma 20 | * @date 2021/11/9 22:26 21 | */ 22 | public class UserDetailsServiceImpl implements UserDetailsService { 23 | 24 | @Resource 25 | private UserMapper userMapper; 26 | 27 | @Override 28 | public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException { 29 | UserInfo userInfo = userMapper.selectOne(Wrappers.lambdaQuery(UserInfo.class).eq(UserInfo::getUserName, userName)); 30 | 31 | JwtUser jwtUser = new JwtUser(); 32 | jwtUser.setId(userInfo.getId()); 33 | jwtUser.setUsername(userName); 34 | jwtUser.setPassword(userInfo.getPassword()); 35 | 36 | Set authorities = Collections.singleton(new SimpleGrantedAuthority(userInfo.getRole() + "")); 37 | jwtUser.setAuthorities(authorities); 38 | 39 | return jwtUser; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/ConfigAllInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.annotation.JSONField; 5 | import com.baomidou.mybatisplus.annotation.FieldFill; 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import com.baomidou.mybatisplus.annotation.TableLogic; 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | import cn.hippo4j.common.model.PoolParameter; 10 | import lombok.Data; 11 | 12 | import java.util.Date; 13 | 14 | /** 15 | * Config all info. 16 | * 17 | * @author chen.ma 18 | * @date 2021/6/20 15:14 19 | */ 20 | @Data 21 | @TableName("config") 22 | public class ConfigAllInfo extends ConfigInfo implements PoolParameter { 23 | 24 | private static final long serialVersionUID = -2417394244017463665L; 25 | 26 | /** 27 | * desc 28 | */ 29 | @JSONField(serialize = false) 30 | @TableField(exist = false, fill = FieldFill.UPDATE) 31 | private String desc; 32 | 33 | /** 34 | * gmtCreate 35 | */ 36 | @JSONField(serialize = false) 37 | @TableField(fill = FieldFill.INSERT) 38 | private Date gmtCreate; 39 | 40 | /** 41 | * gmtModified 42 | */ 43 | @JSONField(serialize = false) 44 | @TableField(fill = FieldFill.INSERT_UPDATE) 45 | private Date gmtModified; 46 | 47 | /** 48 | * delFlag 49 | */ 50 | @TableLogic 51 | @JSONField(serialize = false) 52 | @TableField(fill = FieldFill.INSERT) 53 | private Integer delFlag; 54 | 55 | @Override 56 | public String toString() { 57 | return JSON.toJSONString(this); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/RejectedPolicies.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit.thread; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.util.concurrent.BlockingQueue; 6 | import java.util.concurrent.RejectedExecutionHandler; 7 | 8 | /** 9 | * Rejected policies. 10 | * 11 | * @author chen.ma 12 | * @date 2021/7/5 21:23 13 | */ 14 | @Slf4j 15 | public class RejectedPolicies { 16 | 17 | /** 18 | * 发生拒绝事件时, 添加新任务并运行最早的任务 19 | * 20 | * @return 21 | */ 22 | public static RejectedExecutionHandler runsOldestTaskPolicy() { 23 | return (r, executor) -> { 24 | if (executor.isShutdown()) { 25 | return; 26 | } 27 | BlockingQueue workQueue = executor.getQueue(); 28 | Runnable firstWork = workQueue.poll(); 29 | boolean newTaskAdd = workQueue.offer(r); 30 | if (firstWork != null) { 31 | firstWork.run(); 32 | } 33 | if (!newTaskAdd) { 34 | executor.execute(r); 35 | } 36 | }; 37 | } 38 | 39 | /** 40 | * 使用阻塞方法将拒绝任务添加队列, 可保证任务不丢失 41 | * 42 | * @return 43 | */ 44 | public static RejectedExecutionHandler syncPutQueuePolicy() { 45 | return (r, executor) -> { 46 | if (executor.isShutdown()) { 47 | return; 48 | } 49 | try { 50 | executor.getQueue().put(r); 51 | } catch (InterruptedException e) { 52 | log.error("线程池添加队列任务失败", e); 53 | } 54 | }; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/model/PoolParameterInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.model; 2 | 3 | import lombok.Data; 4 | import lombok.experimental.Accessors; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * Thread pool parameter info. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/16 23:18 13 | */ 14 | @Data 15 | @Accessors(chain = true) 16 | public class PoolParameterInfo implements PoolParameter, Serializable { 17 | 18 | private static final long serialVersionUID = -7123935122108553864L; 19 | 20 | /** 21 | * tenantId 22 | */ 23 | private String tenantId; 24 | 25 | /** 26 | * itemId 27 | */ 28 | private String itemId; 29 | 30 | /** 31 | * tpId 32 | */ 33 | private String tpId; 34 | 35 | /** 36 | * content 37 | */ 38 | private String content; 39 | 40 | /** 41 | * coreSize 42 | */ 43 | private Integer coreSize; 44 | 45 | /** 46 | * maxSize 47 | */ 48 | private Integer maxSize; 49 | 50 | /** 51 | * queueType 52 | */ 53 | private Integer queueType; 54 | 55 | /** 56 | * capacity 57 | */ 58 | private Integer capacity; 59 | 60 | /** 61 | * keepAliveTime 62 | */ 63 | private Integer keepAliveTime; 64 | 65 | /** 66 | * rejectedType 67 | */ 68 | private Integer rejectedType; 69 | 70 | /** 71 | * isAlarm 72 | */ 73 | private Integer isAlarm; 74 | 75 | /** 76 | * capacityAlarm 77 | */ 78 | private Integer capacityAlarm; 79 | 80 | /** 81 | * livenessAlarm 82 | */ 83 | private Integer livenessAlarm; 84 | 85 | } 86 | -------------------------------------------------------------------------------- /hippo4j-tools/log-record-tool/src/main/java/cn/hippo4j/tools/logrecord/service/impl/ParseFunctionFactory.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.tools.logrecord.service.impl; 2 | 3 | import cn.hippo4j.tools.logrecord.service.ParseFunction; 4 | import com.google.common.collect.Maps; 5 | import org.springframework.util.CollectionUtils; 6 | import org.springframework.util.StringUtils; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * 函数解析工厂. 13 | * 14 | * @author chen.ma 15 | * @date 2021/10/23 22:39 16 | */ 17 | public class ParseFunctionFactory { 18 | 19 | private Map allFunctionMap; 20 | 21 | public ParseFunctionFactory(List parseFunctions) { 22 | if (CollectionUtils.isEmpty(parseFunctions)) { 23 | return; 24 | } 25 | 26 | allFunctionMap = Maps.newHashMap(); 27 | for (ParseFunction parseFunction : parseFunctions) { 28 | if (StringUtils.isEmpty(parseFunction.functionName())) { 29 | continue; 30 | } 31 | 32 | allFunctionMap.put(parseFunction.functionName(), parseFunction); 33 | } 34 | } 35 | 36 | /** 37 | * 获取函数实例. 38 | * 39 | * @param functionName 40 | * @return 41 | */ 42 | public ParseFunction getFunction(String functionName) { 43 | return allFunctionMap.get(functionName); 44 | } 45 | 46 | /** 47 | * 是否提前执行. 48 | * 49 | * @param functionName 50 | * @return 51 | */ 52 | public boolean isBeforeFunction(String functionName) { 53 | return allFunctionMap.get(functionName) != null && allFunctionMap.get(functionName).executeBefore(); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/SwitchService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * Switch service. 11 | * 12 | * @author chen.ma 13 | * @date 2021/6/23 18:23 14 | */ 15 | @Slf4j 16 | @Service 17 | public class SwitchService { 18 | 19 | public static final String FIXED_DELAY_TIME = "fixedDelayTime"; 20 | 21 | public static final String FIXED_POLLING = "isFixedPolling"; 22 | 23 | public static final String FIXED_POLLING_INTERVAL = "fixedPollingInertval"; 24 | 25 | private static volatile Map switches = new HashMap(16); 26 | 27 | public static int getSwitchInteger(String key, int defaultValue) { 28 | int rtn = defaultValue; 29 | try { 30 | String status = switches.get(key); 31 | rtn = status != null ? Integer.parseInt(status) : defaultValue; 32 | } catch (Exception e) { 33 | rtn = defaultValue; 34 | log.error("corrupt switch value {}, {}", key, switches.get(key)); 35 | } 36 | return rtn; 37 | } 38 | 39 | public static boolean getSwitchBoolean(String key, boolean defaultValue) { 40 | boolean rtn = defaultValue; 41 | try { 42 | String value = switches.get(key); 43 | rtn = value != null ? Boolean.parseBoolean(value) : defaultValue; 44 | } catch (Exception e) { 45 | rtn = defaultValue; 46 | log.error("corrupt switch value {}, {}", key, switches.get(key)); 47 | } 48 | return rtn; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/NotifyInfo.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import lombok.Data; 7 | 8 | import java.util.Date; 9 | 10 | /** 11 | * 通知管理. 12 | * 13 | * @author chen.ma 14 | * @date 2021/11/17 22:03 15 | */ 16 | @Data 17 | @TableName("notify") 18 | public class NotifyInfo { 19 | 20 | /** 21 | * id 22 | */ 23 | private Long id; 24 | 25 | /** 26 | * 租户id 27 | */ 28 | private String tenantId; 29 | 30 | /** 31 | * 项目id 32 | */ 33 | private String itemId; 34 | 35 | /** 36 | * 线程池id 37 | */ 38 | private String tpId; 39 | 40 | /** 41 | * 通知平台 42 | */ 43 | private String platform; 44 | 45 | /** 46 | * 通知类型 47 | */ 48 | private String type; 49 | 50 | /** 51 | * 密钥 52 | */ 53 | private String secretKey; 54 | 55 | /** 56 | * 报警间隔 57 | */ 58 | @TableField("`interval`") 59 | private Integer interval; 60 | 61 | /** 62 | * 接收者 63 | */ 64 | private String receives; 65 | 66 | /** 67 | * 创建时间 68 | */ 69 | @TableField(fill = FieldFill.INSERT) 70 | private Date gmtCreate; 71 | 72 | /** 73 | * 修改时间 74 | */ 75 | @TableField(fill = FieldFill.INSERT_UPDATE) 76 | private Date gmtModified; 77 | 78 | /** 79 | * 是否启用 80 | */ 81 | private Integer enable; 82 | 83 | /** 84 | * 是否删除 85 | */ 86 | @TableField(fill = FieldFill.INSERT) 87 | private Integer delFlag; 88 | 89 | } 90 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/thread/TaskQueue.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit.thread; 2 | 3 | import java.util.concurrent.LinkedBlockingQueue; 4 | import java.util.concurrent.RejectedExecutionException; 5 | import java.util.concurrent.TimeUnit; 6 | 7 | /** 8 | * Task queue. 9 | * 10 | * @author chen.ma 11 | * @date 2021/7/5 21:00 12 | */ 13 | public class TaskQueue extends LinkedBlockingQueue { 14 | 15 | private static final long serialVersionUID = -2635853580887179627L; 16 | 17 | private FastThreadPoolExecutor executor; 18 | 19 | public TaskQueue(int capacity) { 20 | super(capacity); 21 | } 22 | 23 | public void setExecutor(FastThreadPoolExecutor exec) { 24 | executor = exec; 25 | } 26 | 27 | @Override 28 | public boolean offer(Runnable runnable) { 29 | int currentPoolThreadSize = executor.getPoolSize(); 30 | // 如果有核心线程正在空闲, 将任务加入阻塞队列, 由核心线程进行处理任务 31 | if (executor.getSubmittedTaskCount() < currentPoolThreadSize) { 32 | return super.offer(runnable); 33 | } 34 | 35 | // 当前线程池线程数量小于最大线程数, 返回false, 根据线程池源码, 会创建非核心线程 36 | if (currentPoolThreadSize < executor.getMaximumPoolSize()) { 37 | return false; 38 | } 39 | 40 | // 如果当前线程池数量大于最大线程数, 任务加入阻塞队列 41 | return super.offer(runnable); 42 | } 43 | 44 | public boolean retryOffer(Runnable o, long timeout, TimeUnit unit) throws InterruptedException { 45 | if (executor.isShutdown()) { 46 | throw new RejectedExecutionException("Actuator closed!"); 47 | } 48 | return super.offer(o, timeout, unit); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/core/GlobalThreadPoolManage.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.core; 2 | 3 | import cn.hippo4j.common.model.PoolParameter; 4 | import cn.hippo4j.starter.wrapper.DynamicThreadPoolWrapper; 5 | import com.google.common.collect.Lists; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.concurrent.ConcurrentHashMap; 10 | 11 | /** 12 | * Global threadPool manage. 13 | * 14 | * @author chen.ma 15 | * @date 2021/6/20 15:57 16 | */ 17 | public class GlobalThreadPoolManage { 18 | 19 | private static final Map POOL_PARAMETER = new ConcurrentHashMap(); 20 | 21 | private static final Map EXECUTOR_MAP = new ConcurrentHashMap(); 22 | 23 | public static DynamicThreadPoolWrapper getExecutorService(String tpId) { 24 | return EXECUTOR_MAP.get(tpId); 25 | } 26 | 27 | public static PoolParameter getPoolParameter(String tpId) { 28 | return POOL_PARAMETER.get(tpId); 29 | } 30 | 31 | public static void register(String tpId, PoolParameter poolParameter, DynamicThreadPoolWrapper executor) { 32 | registerPool(tpId, executor); 33 | registerPoolParameter(tpId, poolParameter); 34 | } 35 | 36 | public static void registerPool(String tpId, DynamicThreadPoolWrapper executor) { 37 | EXECUTOR_MAP.put(tpId, executor); 38 | } 39 | 40 | public static void registerPoolParameter(String tpId, PoolParameter poolParameter) { 41 | POOL_PARAMETER.put(tpId, poolParameter); 42 | } 43 | 44 | public static List listThreadPoolId() { 45 | return Lists.newArrayList(POOL_PARAMETER.keySet()); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/notify/DefaultSharePublisher.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.notify; 2 | 3 | import cn.hutool.core.collection.ConcurrentHashSet; 4 | import cn.hippo4j.config.notify.listener.Subscriber; 5 | import cn.hippo4j.config.event.Event; 6 | import cn.hippo4j.config.event.SlowEvent; 7 | 8 | import java.util.Map; 9 | import java.util.Set; 10 | import java.util.concurrent.ConcurrentHashMap; 11 | import java.util.concurrent.locks.Lock; 12 | import java.util.concurrent.locks.ReentrantLock; 13 | 14 | /** 15 | * Default share publisher. 16 | * 17 | * @author chen.ma 18 | * @date 2021/6/23 19:05 19 | */ 20 | public class DefaultSharePublisher extends DefaultPublisher { 21 | 22 | private final Map, Set> subMappings = new ConcurrentHashMap(); 23 | 24 | protected final ConcurrentHashSet subscribers = new ConcurrentHashSet(); 25 | 26 | private final Lock lock = new ReentrantLock(); 27 | 28 | public void addSubscriber(Subscriber subscriber, Class subscribeType) { 29 | Class subSlowEventType = (Class) subscribeType; 30 | subscribers.add(subscriber); 31 | 32 | lock.lock(); 33 | try { 34 | Set sets = subMappings.get(subSlowEventType); 35 | if (sets == null) { 36 | Set newSet = new ConcurrentHashSet(); 37 | newSet.add(subscriber); 38 | subMappings.put(subSlowEventType, newSet); 39 | return; 40 | } 41 | sets.add(subscriber); 42 | } finally { 43 | lock.unlock(); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hippo4j-server/conf/application.properties: -------------------------------------------------------------------------------- 1 | #*************** Spring Boot Related Configurations ***************# 2 | ### Default Web Context Path 3 | # server.servlet.contextPath=/hippo4j 4 | 5 | ### Server Startup Port 6 | server.port=6691 7 | 8 | ### Server Tomcat 9 | server.tomcat.accesslog.enabled=true 10 | server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i 11 | 12 | ### Default Current Work Dir 13 | server.tomcat.basedir= 14 | 15 | #*************** Dynamic Thread Pool Custom Configuration ***************# 16 | ### Custom Logging Tenant 17 | tenant=hippo4j 18 | 19 | 20 | #*************** Config Module Related Configurations ***************# 21 | ### Hikari Datasource 22 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 23 | spring.datasource.url=jdbc:mysql://localhost:3306/hippo_manager?characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 24 | spring.datasource.username=root 25 | spring.datasource.password=root 26 | spring.datasource.hikari.pool-name=Hikari 27 | spring.datasource.hikari.connectionTimeout=30000 28 | spring.datasource.hikari.idleTimeout=30000 29 | spring.datasource.hikari.validationTimeout=3000 30 | spring.datasource.hikari.maxLifetime=120000 31 | spring.datasource.hikari.loginTimeout=5 32 | spring.datasource.hikari.minimumIdle=5 33 | spring.datasource.hikari.maximumPoolSize=15 34 | spring.datasource.hikari.connection-test-query=SELECT 1 35 | 36 | ### Mybatis-Plus Config 37 | mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl 38 | mybatis-plus.global-config.db-config.logic-delete-field=delFlag 39 | mybatis-plus.global-config.db-config.logic-delete-value=1 40 | mybatis-plus.global-config.db-config.logic-not-delete-value=0 41 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CloudCommonIdUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.toolkit; 2 | 3 | import cn.hippo4j.starter.toolkit.inet.InetUtils; 4 | import lombok.SneakyThrows; 5 | import org.springframework.core.env.PropertyResolver; 6 | 7 | /** 8 | * Cloud common id util. 9 | * 10 | * @author chen.ma 11 | * @date 2021/8/6 21:02 12 | */ 13 | public class CloudCommonIdUtil { 14 | 15 | private static final String SEPARATOR = ":"; 16 | 17 | @SneakyThrows 18 | public static String getDefaultInstanceId(PropertyResolver resolver, InetUtils inetUtils) { 19 | String namePart = getIpApplicationName(resolver, inetUtils); 20 | String indexPart = resolver.getProperty("spring.application.instance_id", resolver.getProperty("server.port")); 21 | return combineParts(namePart, SEPARATOR, indexPart); 22 | } 23 | 24 | @SneakyThrows 25 | public static String getIpApplicationName(PropertyResolver resolver, InetUtils inetUtils) { 26 | String hostname = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); 27 | String appName = resolver.getProperty("spring.application.name"); 28 | return combineParts(hostname, SEPARATOR, appName); 29 | } 30 | 31 | public static String combineParts(String firstPart, String separator, 32 | String secondPart) { 33 | String combined = null; 34 | if (firstPart != null && secondPart != null) { 35 | combined = firstPart + separator + secondPart; 36 | } else if (firstPart != null) { 37 | combined = firstPart; 38 | } else if (secondPart != null) { 39 | combined = secondPart; 40 | } 41 | return combined; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /hippo4j-discovery/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | cn.hippo4j 8 | hippo4j-all 9 | ${revision} 10 | 11 | 12 | hippo4j-discovery 13 | 14 | ${project.artifactId} 15 | ${project.artifactId} 16 | 17 | 18 | true 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | 31 | 32 | 33 | cn.hippo4j 34 | hippo4j-common 35 | 36 | 37 | 38 | com.google.guava 39 | guava 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /hippo4j-common/src/main/java/cn/hippo4j/common/toolkit/GroupKey.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.common.toolkit; 2 | 3 | import cn.hippo4j.common.constant.Constants; 4 | import org.springframework.util.StringUtils; 5 | 6 | /** 7 | * Group key. 8 | * 9 | * @author chen.ma 10 | * @date 2021/6/24 21:12 11 | */ 12 | public class GroupKey { 13 | 14 | public static String getKey(String dataId, String group) { 15 | return getKey(dataId, group, ""); 16 | } 17 | 18 | public static String getKey(String dataId, String group, String datumStr) { 19 | return doGetKey(dataId, group, datumStr); 20 | } 21 | 22 | public static String getKeyTenant(String dataId, String group, String tenant) { 23 | return doGetKey(dataId, group, tenant); 24 | } 25 | 26 | private static String doGetKey(String dataId, String group, String datumStr) { 27 | StringBuilder sb = new StringBuilder(); 28 | urlEncode(dataId, sb); 29 | sb.append('+'); 30 | urlEncode(group, sb); 31 | if (!StringUtils.isEmpty(datumStr)) { 32 | sb.append('+'); 33 | urlEncode(datumStr, sb); 34 | } 35 | 36 | return sb.toString(); 37 | } 38 | 39 | public static String[] parseKey(String groupKey) { 40 | return groupKey.split(Constants.GROUP_KEY_DELIMITER_TRANSLATION); 41 | } 42 | 43 | public static void urlEncode(String str, StringBuilder sb) { 44 | for (int idx = 0; idx < str.length(); ++idx) { 45 | char c = str.charAt(idx); 46 | if ('+' == c) { 47 | sb.append("%2B"); 48 | } else if ('%' == c) { 49 | sb.append("%25"); 50 | } else { 51 | sb.append(c); 52 | } 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/ThreadPoolService.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz; 2 | 3 | import cn.hippo4j.config.model.biz.threadpool.ThreadPoolQueryReqDTO; 4 | import cn.hippo4j.config.model.biz.threadpool.ThreadPoolRespDTO; 5 | import cn.hippo4j.config.model.biz.threadpool.ThreadPoolSaveOrUpdateReqDTO; 6 | import com.baomidou.mybatisplus.core.metadata.IPage; 7 | import cn.hippo4j.config.model.biz.threadpool.ThreadPoolDelReqDTO; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * Thread pool service. 13 | * 14 | * @author chen.ma 15 | * @date 2021/6/30 21:26 16 | */ 17 | public interface ThreadPoolService { 18 | 19 | /** 20 | * Query thread pool page. 21 | * 22 | * @param reqDTO 23 | * @return 24 | */ 25 | IPage queryThreadPoolPage(ThreadPoolQueryReqDTO reqDTO); 26 | 27 | /** 28 | * Get thread pool. 29 | * 30 | * @param reqDTO 31 | * @return 32 | */ 33 | ThreadPoolRespDTO getThreadPool(ThreadPoolQueryReqDTO reqDTO); 34 | 35 | /** 36 | * Get thread pool by item id. 37 | * 38 | * @param itemId 39 | * @return 40 | */ 41 | List getThreadPoolByItemId(String itemId); 42 | 43 | /** 44 | * Save or update thread pool config. 45 | * 46 | * @param identify 47 | * @param reqDTO 48 | */ 49 | void saveOrUpdateThreadPoolConfig(String identify, ThreadPoolSaveOrUpdateReqDTO reqDTO); 50 | 51 | /** 52 | * Delete pool. 53 | * 54 | * @param reqDTO 55 | */ 56 | void deletePool(ThreadPoolDelReqDTO reqDTO); 57 | 58 | /** 59 | * Alarm enable. 60 | * 61 | * @param id 62 | * @param isAlarm 63 | */ 64 | void alarmEnable(String id, Integer isAlarm); 65 | 66 | } 67 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/toolkit/BeanUtil.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.toolkit; 2 | 3 | import com.github.dozermapper.core.DozerBeanMapperBuilder; 4 | import com.github.dozermapper.core.Mapper; 5 | 6 | import java.util.*; 7 | 8 | /** 9 | * Bean util 10 | * 11 | * @author chen.ma 12 | * @date 2021/3/19 15:40 13 | */ 14 | public class BeanUtil { 15 | 16 | private BeanUtil() { 17 | 18 | } 19 | 20 | protected static Mapper BEAN_MAPPER_BUILDER; 21 | 22 | static { 23 | BEAN_MAPPER_BUILDER = DozerBeanMapperBuilder.buildDefault(); 24 | } 25 | 26 | public static T convert(S source, Class clazz) { 27 | return Optional.ofNullable(source) 28 | .map(each -> BEAN_MAPPER_BUILDER.map(each, clazz)) 29 | .orElse(null); 30 | } 31 | 32 | public static List convert(List sources, Class clazz) { 33 | return Optional.ofNullable(sources) 34 | .map(each -> { 35 | List targetList = new ArrayList(each.size()); 36 | each.stream() 37 | .forEach(item -> targetList.add(BEAN_MAPPER_BUILDER.map(item, clazz))); 38 | return targetList; 39 | }) 40 | .orElse(null); 41 | } 42 | 43 | public static Set convert(Set sources, Class clazz) { 44 | return Optional.ofNullable(sources) 45 | .map(each -> { 46 | Set targetSize = new HashSet(each.size()); 47 | each.stream() 48 | .forEach(item -> targetSize.add(BEAN_MAPPER_BUILDER.map(item, clazz))); 49 | return targetSize; 50 | }) 51 | .orElse(null); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/controller/PermissionController.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.controller; 2 | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; 4 | import cn.hippo4j.auth.model.biz.permission.PermissionRespDTO; 5 | import cn.hippo4j.auth.service.PermissionService; 6 | import cn.hippo4j.common.web.base.Result; 7 | import cn.hippo4j.common.web.base.Results; 8 | import lombok.AllArgsConstructor; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | /** 12 | * Permission controller. 13 | * 14 | * @author chen.ma 15 | * @date 2021/10/30 22:08 16 | */ 17 | @RestController 18 | @AllArgsConstructor 19 | @RequestMapping("/v1/auth/permissions") 20 | public class PermissionController { 21 | 22 | private final PermissionService permissionService; 23 | 24 | @GetMapping("/{pageNo}/{pageSize}") 25 | public Result> listPermission(@PathVariable("pageNo") int pageNo, @PathVariable("pageSize") int pageSize) { 26 | IPage resultPermissionPage = permissionService.listPermission(pageNo, pageSize); 27 | return Results.success(resultPermissionPage); 28 | } 29 | 30 | @PostMapping("/{role}/{resource}/{action}") 31 | public Result addPermission(@PathVariable("role") String role, @PathVariable("resource") String resource, @PathVariable("action") String action) { 32 | permissionService.addPermission(role, resource, action); 33 | return Results.success(); 34 | } 35 | 36 | @DeleteMapping("/{role}/{resource}/{action}") 37 | public Result deleteUser(@PathVariable("role") String role, @PathVariable("resource") String resource, @PathVariable("action") String action) { 38 | permissionService.deletePermission(role, resource, action); 39 | return Results.success(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/spi/DynamicTpServiceLoader.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.starter.spi; 2 | 3 | import java.util.*; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | import java.util.stream.Collectors; 6 | 7 | /** 8 | * Dynamic threadPool service loader. 9 | * 10 | * @author chen.ma 11 | * @date 2021/7/10 23:45 12 | */ 13 | public class DynamicTpServiceLoader { 14 | 15 | private static final Map, Collection> SERVICES = new ConcurrentHashMap(); 16 | 17 | public static void register(final Class serviceInterface) { 18 | if (!SERVICES.containsKey(serviceInterface)) { 19 | SERVICES.put(serviceInterface, load(serviceInterface)); 20 | } 21 | } 22 | 23 | private static Collection load(final Class serviceInterface) { 24 | Collection result = new LinkedList<>(); 25 | for (T each : ServiceLoader.load(serviceInterface)) { 26 | result.add(each); 27 | } 28 | return result; 29 | } 30 | 31 | public static Collection getSingletonServiceInstances(final Class service) { 32 | return (Collection) SERVICES.getOrDefault(service, Collections.emptyList()); 33 | } 34 | 35 | public static Collection newServiceInstances(final Class service) { 36 | return SERVICES.containsKey(service) ? SERVICES.get(service).stream().map(each -> (T) newServiceInstance(each.getClass())).collect(Collectors.toList()) : Collections.emptyList(); 37 | } 38 | 39 | private static Object newServiceInstance(final Class clazz) { 40 | try { 41 | return clazz.newInstance(); 42 | } catch (final InstantiationException | IllegalAccessException ex) { 43 | throw new ServiceLoaderInstantiationException(clazz, ex); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/service/impl/DashboardServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.service.impl; 2 | 3 | import cn.hippo4j.console.model.ChartInfo; 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; 5 | import cn.hippo4j.config.enums.DelEnum; 6 | import cn.hippo4j.config.mapper.ConfigInfoMapper; 7 | import cn.hippo4j.config.mapper.ItemInfoMapper; 8 | import cn.hippo4j.config.mapper.TenantInfoMapper; 9 | import cn.hippo4j.config.model.ConfigAllInfo; 10 | import cn.hippo4j.config.model.ItemInfo; 11 | import cn.hippo4j.config.model.TenantInfo; 12 | import cn.hippo4j.console.service.DashboardService; 13 | import lombok.AllArgsConstructor; 14 | import org.springframework.stereotype.Service; 15 | 16 | /** 17 | * Dashboard service impl. 18 | * 19 | * @author chen.ma 20 | * @date 2021/11/10 21:08 21 | */ 22 | @Service 23 | @AllArgsConstructor 24 | public class DashboardServiceImpl implements DashboardService { 25 | 26 | private final TenantInfoMapper tenantInfoMapper; 27 | 28 | private final ItemInfoMapper itemInfoMapper; 29 | 30 | private final ConfigInfoMapper configInfoMapper; 31 | 32 | @Override 33 | public ChartInfo getChartInfo() { 34 | Integer tenantCount = tenantInfoMapper.selectCount(Wrappers.lambdaQuery(TenantInfo.class).eq(TenantInfo::getDelFlag, DelEnum.NORMAL)); 35 | Integer itemCount = itemInfoMapper.selectCount(Wrappers.lambdaQuery(ItemInfo.class).eq(ItemInfo::getDelFlag, DelEnum.NORMAL)); 36 | Integer threadPoolCount = configInfoMapper.selectCount(Wrappers.lambdaQuery(ConfigAllInfo.class).eq(ConfigAllInfo::getDelFlag, DelEnum.NORMAL)); 37 | 38 | ChartInfo chartInfo = new ChartInfo(); 39 | chartInfo.setTenantCount(tenantCount) 40 | .setItemCount(itemCount) 41 | .setThreadPoolCount(threadPoolCount); 42 | return chartInfo; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/config/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.config; 2 | 3 | import cn.hippo4j.common.web.base.Result; 4 | import cn.hippo4j.common.web.base.Results; 5 | import cn.hippo4j.common.web.exception.ServiceException; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.util.StringUtils; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.RestControllerAdvice; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | 13 | /** 14 | * 全局异常捕获器. 15 | * 16 | * @author chen.ma 17 | * @date 2021/11/18 22:18 18 | */ 19 | @Slf4j 20 | @RestControllerAdvice 21 | public class GlobalExceptionHandler { 22 | 23 | @ExceptionHandler(value = {ServiceException.class}) 24 | public Result serviceException(HttpServletRequest request, ServiceException ex) { 25 | if (ex.getCause() != null) { 26 | log.error("[{}] {} [ex] {}", request.getMethod(), request.getRequestURL().toString(), ex.toString(), ex.getCause()); 27 | return Results.failure(ex); 28 | } 29 | 30 | log.info("[{}] {} [ex] {}", request.getMethod(), request.getRequestURL().toString(), ex.toString()); 31 | return Results.failure(ex); 32 | } 33 | 34 | @ExceptionHandler(value = Throwable.class) 35 | public Result defaultErrorHandler(HttpServletRequest request, Throwable throwable) { 36 | log.error("[{}] {} ", request.getMethod(), getUrl(request), throwable); 37 | return Results.failure(throwable); 38 | } 39 | 40 | private String getUrl(HttpServletRequest request) { 41 | if (StringUtils.isEmpty(request.getQueryString())) { 42 | return request.getRequestURL().toString(); 43 | } 44 | 45 | return request.getRequestURL().toString() + "?" + request.getQueryString(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/resources/static/static/js/chunk-91584750.a58b5769.js: -------------------------------------------------------------------------------- 1 | (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-91584750"],{"1db4":function(t,s,a){"use strict";a.r(s);var e=function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"wscn-http404-container"},[a("div",{staticClass:"wscn-http404"},[t._m(0),t._v(" "),a("div",{staticClass:"bullshit"},[a("div",{staticClass:"bullshit__oops"},[t._v("OOPS!")]),t._v(" "),t._m(1),t._v(" "),a("div",{staticClass:"bullshit__headline"},[t._v(t._s(t.message))]),t._v(" "),a("div",{staticClass:"bullshit__info"},[t._v("Please check that the URL you entered is correct, or click the button below to return to the homepage.")]),t._v(" "),a("a",{staticClass:"bullshit__return-home",attrs:{href:""}},[t._v("Back to home")])])])])},c=[function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("div",{staticClass:"pic-404"},[e("img",{staticClass:"pic-404__parent",attrs:{src:a("a36b"),alt:"404"}}),t._v(" "),e("img",{staticClass:"pic-404__child left",attrs:{src:a("26fc"),alt:"404"}}),t._v(" "),e("img",{staticClass:"pic-404__child mid",attrs:{src:a("26fc"),alt:"404"}}),t._v(" "),e("img",{staticClass:"pic-404__child right",attrs:{src:a("26fc"),alt:"404"}})])},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"bullshit__info"},[t._v("All rights reserved\n "),a("a",{staticStyle:{color:"#20a0ff"},attrs:{href:"https://wallstreetcn.com",target:"_blank"}},[t._v("wallstreetcn")])])}],i={name:"Page404",computed:{message:function(){return"The webmaster said that you can not enter this page..."}}},l=i,n=(a("35e7"),a("2877")),r=Object(n["a"])(l,e,c,!1,null,"26fcd89f",null);s["default"]=r.exports},"26fc":function(t,s,a){t.exports=a.p+"static/img/404_cloud.0f4bc32b.png"},"35e7":function(t,s,a){"use strict";a("c107")},a36b:function(t,s,a){t.exports=a.p+"static/img/404.a57b6f31.png"},c107:function(t,s,a){}}]); -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/LogRecordBizServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.service.biz.impl; 2 | 3 | import cn.hippo4j.config.mapper.LogRecordMapper; 4 | import cn.hippo4j.config.model.biz.log.LogRecordQueryReqDTO; 5 | import cn.hippo4j.config.model.biz.log.LogRecordRespDTO; 6 | import cn.hippo4j.config.service.biz.LogRecordBizService; 7 | import cn.hippo4j.config.toolkit.BeanUtil; 8 | import cn.hippo4j.tools.logrecord.model.LogRecordInfo; 9 | import cn.hutool.core.util.StrUtil; 10 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 11 | import com.baomidou.mybatisplus.core.metadata.IPage; 12 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; 13 | import lombok.AllArgsConstructor; 14 | import org.springframework.stereotype.Service; 15 | 16 | /** 17 | * 操作日志. 18 | * 19 | * @author chen.ma 20 | * @date 2021/11/17 21:50 21 | */ 22 | @Service 23 | @AllArgsConstructor 24 | public class LogRecordBizServiceImpl implements LogRecordBizService { 25 | 26 | private final LogRecordMapper logRecordMapper; 27 | 28 | @Override 29 | public IPage queryPage(LogRecordQueryReqDTO pageQuery) { 30 | LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(LogRecordInfo.class) 31 | .eq(StrUtil.isNotBlank(pageQuery.getBizNo()), LogRecordInfo::getBizNo, pageQuery.getBizNo()) 32 | .eq(StrUtil.isNotBlank(pageQuery.getCategory()), LogRecordInfo::getCategory, pageQuery.getCategory()) 33 | .eq(StrUtil.isNotBlank(pageQuery.getOperator()), LogRecordInfo::getOperator, pageQuery.getOperator()) 34 | .orderByDesc(LogRecordInfo::getCreateTime); 35 | IPage selectPage = logRecordMapper.selectPage(pageQuery, queryWrapper); 36 | return selectPage.convert(each -> BeanUtil.convert(each, LogRecordRespDTO.class)); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /hippo4j-console/src/main/java/cn/hippo4j/console/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.console.controller; 2 | 3 | import com.baomidou.mybatisplus.core.metadata.IPage; 4 | import cn.hippo4j.auth.model.biz.role.RoleRespDTO; 5 | import cn.hippo4j.auth.service.RoleService; 6 | import cn.hippo4j.common.web.base.Result; 7 | import cn.hippo4j.common.web.base.Results; 8 | import lombok.AllArgsConstructor; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Role controller. 15 | * 16 | * @author chen.ma 17 | * @date 2021/10/30 22:16 18 | */ 19 | @RestController 20 | @AllArgsConstructor 21 | @RequestMapping("/v1/auth/roles") 22 | public class RoleController { 23 | 24 | private final RoleService roleService; 25 | 26 | @GetMapping("/{pageNo}/{pageSize}") 27 | public Result> listUser(@PathVariable("pageNo") int pageNo, @PathVariable("pageSize") int pageSize) { 28 | IPage resultRolePage = roleService.listRole(pageNo, pageSize); 29 | return Results.success(resultRolePage); 30 | } 31 | 32 | @PostMapping("/{role}/{userName}") 33 | public Result addUser(@PathVariable("role") String role, @PathVariable("userName") String userName) { 34 | roleService.addRole(role, userName); 35 | return Results.success(); 36 | } 37 | 38 | @DeleteMapping("/{role}/{userName}") 39 | public Result deleteUser(@PathVariable("role") String role, @PathVariable("userName") String userName) { 40 | roleService.deleteRole(role, userName); 41 | return Results.success(); 42 | } 43 | 44 | @GetMapping("/search/{role}") 45 | public Result> searchUsersLikeUserName(@PathVariable("role") String role) { 46 | List resultRole = roleService.getRoleLike(role); 47 | return Results.success(resultRole); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /hippo4j-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | cn.hippo4j 8 | hippo4j-all 9 | ${revision} 10 | 11 | 12 | hippo4j-server 13 | jar 14 | 15 | ${project.artifactId} 16 | ${project.artifactId} 17 | 18 | 19 | true 20 | 21 | 22 | 23 | 24 | cn.hippo4j 25 | hippo4j-config 26 | 27 | 28 | 29 | cn.hippo4j 30 | hippo4j-console 31 | 32 | 33 | 34 | cn.hippo4j 35 | hippo4j-discovery 36 | 37 | 38 | 39 | 40 | ${project.artifactId} 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | 47 | 48 | repackage 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /hippo4j-config/src/main/java/cn/hippo4j/config/model/biz/threadpool/ThreadPoolRespDTO.java: -------------------------------------------------------------------------------- 1 | package cn.hippo4j.config.model.biz.threadpool; 2 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; 4 | import lombok.Data; 5 | 6 | import java.util.Date; 7 | 8 | /** 9 | * Thread pool resp dto. 10 | * 11 | * @author chen.ma 12 | * @date 2021/6/30 21:23 13 | */ 14 | @Data 15 | public class ThreadPoolRespDTO { 16 | 17 | /** 18 | * id 19 | */ 20 | private String id; 21 | 22 | /** 23 | * tenantId 24 | */ 25 | private String tenantId; 26 | 27 | /** 28 | * itemId 29 | */ 30 | private String itemId; 31 | 32 | /** 33 | * tpId 34 | */ 35 | private String tpId; 36 | 37 | /** 38 | * coreSize 39 | */ 40 | private Integer coreSize; 41 | 42 | /** 43 | * maxSize 44 | */ 45 | private Integer maxSize; 46 | 47 | /** 48 | * queueType 49 | */ 50 | private Integer queueType; 51 | 52 | /** 53 | * queueName 54 | */ 55 | private String queueName; 56 | 57 | /** 58 | * capacity 59 | */ 60 | private Integer capacity; 61 | 62 | /** 63 | * keepAliveTime 64 | */ 65 | private Integer keepAliveTime; 66 | 67 | /** 68 | * isAlarm 69 | */ 70 | private Integer isAlarm; 71 | 72 | /** 73 | * capacityAlarm 74 | */ 75 | private Integer capacityAlarm; 76 | 77 | /** 78 | * livenessAlarm 79 | */ 80 | private Integer livenessAlarm; 81 | 82 | /** 83 | * rejectedType 84 | */ 85 | private Integer rejectedType; 86 | 87 | /** 88 | * gmtCreate 89 | */ 90 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 91 | private Date gmtCreate; 92 | 93 | /** 94 | * gmtModified 95 | */ 96 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 97 | private Date gmtModified; 98 | } 99 | --------------------------------------------------------------------------------