From 107a38b097ded0f63da9259ab61a8efca21853f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Thu, 6 Jun 2024 09:52:49 +0800 Subject: [PATCH] update sentinel 1.8.6 => 1.8.8 --- ruoyi-common/ruoyi-common-alibaba-bom/pom.xml | 2 +- ruoyi-visual/ruoyi-sentinel-dashboard/pom.xml | 2 +- .../dashboard/DashboardApplication.java | 1 - .../sentinel/dashboard/auth/AuthAction.java | 6 +- .../DefaultLoginAuthenticationFilter.java | 1 - .../dashboard/config/DashboardConfig.java | 16 +- .../sentinel/dashboard/config/WebConfig.java | 8 +- .../dashboard/controller/AppController.java | 21 +- .../dashboard/controller/DemoController.java | 15 +- .../controller/MachineRegistryController.java | 4 +- .../controller/MetricController.java | 18 +- .../controller/ParamFlowRuleController.java | 5 +- .../controller/ResourceController.java | 12 +- .../controller/VersionController.java | 1 - .../cluster/ClusterAssignController.java | 19 +- .../cluster/ClusterConfigController.java | 27 +- .../gateway/GatewayFlowRuleController.java | 2 +- .../controller/v2/FlowControllerV2.java | 5 +- .../dashboard/discovery/MachineInfo.java | 16 +- .../discovery/SimpleMachineDiscovery.java | 7 +- .../dashboard/domain/ResourceTreeNode.java | 4 +- .../cluster/ClusterAppFullAssignRequest.java | 4 +- .../ClusterAppSingleServerAssignRequest.java | 4 +- .../request/ClusterServerModifyRequest.java | 4 +- .../cluster/state/ClusterServerStateVO.java | 6 +- .../dashboard/domain/vo/MachineInfoVo.java | 10 +- .../dashboard/domain/vo/MetricVo.java | 4 +- .../dashboard/domain/vo/ResourceVo.java | 7 +- .../dashboard/entity/ApplicationEntity.java | 106 ++++++ .../dashboard/entity/MachineEntity.java | 125 ++++++ .../dashboard/entity/MetricEntity.java | 219 +++++++++++ .../entity/MetricPositionEntity.java | 121 ++++++ .../dashboard/entity/SentinelVersion.java | 129 +++++++ .../entity/gateway/ApiDefinitionEntity.java | 209 +++++++++++ .../gateway/ApiPredicateItemEntity.java | 79 ++++ .../entity/gateway/GatewayFlowRuleEntity.java | 355 ++++++++++++++++++ .../gateway/GatewayParamFlowItemEntity.java | 95 +++++ .../entity/rule/AbstractRuleEntity.java | 112 ++++++ .../entity/rule/AuthorityRuleEntity.java | 63 ++++ .../entity/rule/DegradeRuleEntity.java | 203 ++++++++++ .../dashboard/entity/rule/FlowRuleEntity.java | 250 ++++++++++++ .../entity/rule/ParamFlowRuleEntity.java | 121 ++++++ .../dashboard/entity/rule/RuleEntity.java | 40 ++ .../entity/rule/SystemRuleEntity.java | 159 ++++++++ .../dashboard/metric/MetricFetcher.java | 31 +- .../metric/InMemoryMetricsRepository.java | 6 +- .../rule/InMemAuthorityRuleStore.java | 5 +- .../rule/InMemDegradeRuleStore.java | 5 +- .../repository/rule/InMemFlowRuleStore.java | 5 +- .../rule/InMemParamFlowRuleStore.java | 5 +- .../repository/rule/InMemSystemRuleStore.java | 5 +- .../rule/InMemoryRuleRepositoryAdapter.java | 8 +- .../repository/rule/RuleRepository.java | 4 +- .../dashboard/rule/FlowRuleApiProvider.java | 12 +- .../dashboard/rule/FlowRuleApiPublisher.java | 9 +- .../service/ClusterAssignService.java | 6 +- .../service/ClusterAssignServiceImpl.java | 23 +- .../service/ClusterConfigService.java | 39 +- .../sentinel/dashboard/util/AsyncUtils.java | 6 +- .../sentinel/dashboard/util/MachineUtils.java | 4 +- .../sentinel/dashboard/util/VersionUtils.java | 13 +- .../src/main/webapp/resources/README.md | 8 +- .../src/main/webapp/resources/README_zh.md | 8 +- .../app/scripts/directives/header/header.html | 4 + 64 files changed, 2569 insertions(+), 254 deletions(-) create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/ApplicationEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MachineEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricPositionEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/SentinelVersion.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiDefinitionEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiPredicateItemEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayFlowRuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayParamFlowItemEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AbstractRuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AuthorityRuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/DegradeRuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/FlowRuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/ParamFlowRuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/RuleEntity.java create mode 100644 ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/SystemRuleEntity.java diff --git a/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml b/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml index cdf993653..d26db93b0 100644 --- a/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml +++ b/ruoyi-common/ruoyi-common-alibaba-bom/pom.xml @@ -16,7 +16,7 @@ 2.2.0-SNAPSHOT 2023.0.1.0 - 1.8.6 + 1.8.8 1.7.1 2.3.2 3.2.11 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/pom.xml b/ruoyi-visual/ruoyi-sentinel-dashboard/pom.xml index 0edd10770..9ad640d31 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/pom.xml +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/pom.xml @@ -13,7 +13,7 @@ jar - 1.8.6 + 1.8.8 4.0.1 2.7.18 2021.0.7 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/DashboardApplication.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/DashboardApplication.java index f74864626..be4492170 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/DashboardApplication.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/DashboardApplication.java @@ -16,7 +16,6 @@ package com.alibaba.csp.sentinel.dashboard; import com.alibaba.csp.sentinel.init.InitExecutor; - import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java index f521c04df..13b6faa40 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java @@ -15,11 +15,7 @@ */ package com.alibaba.csp.sentinel.dashboard.auth; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * @author lkxiaolou diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java index 774dab36f..b2d033e06 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java @@ -16,7 +16,6 @@ package com.alibaba.csp.sentinel.dashboard.auth; import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.util.AntPathMatcher; diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java index 92e0608ec..5d8d9ca77 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java @@ -15,13 +15,13 @@ */ package com.alibaba.csp.sentinel.dashboard.config; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.springframework.lang.NonNull; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + /** *

Dashboard local config support.

*

@@ -65,7 +65,7 @@ public class DashboardConfig { public static final String CONFIG_AUTO_REMOVE_MACHINE_MILLIS = "sentinel.dashboard.autoRemoveMachineMillis"; private static final ConcurrentMap cacheMap = new ConcurrentHashMap<>(); - + @NonNull private static String getConfig(String name) { // env @@ -121,19 +121,19 @@ public class DashboardConfig { public static int getHideAppNoMachineMillis() { return getConfigInt(CONFIG_HIDE_APP_NO_MACHINE_MILLIS, 0, 60000); } - + public static int getRemoveAppNoMachineMillis() { return getConfigInt(CONFIG_REMOVE_APP_NO_MACHINE_MILLIS, 0, 120000); } - + public static int getAutoRemoveMachineMillis() { return getConfigInt(CONFIG_AUTO_REMOVE_MACHINE_MILLIS, 0, 300000); } - + public static int getUnhealthyMachineMillis() { return getConfigInt(CONFIG_UNHEALTHY_MACHINE_MILLIS, DEFAULT_MACHINE_HEALTHY_TIMEOUT_MS, 30000); } - + public static void clearCache() { cacheMap.clear(); } diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java index 92e51e54a..3f3fc60c7 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java @@ -15,16 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.config; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter; import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager; import com.alibaba.csp.sentinel.dashboard.auth.AuthorizationInterceptor; import com.alibaba.csp.sentinel.dashboard.auth.LoginAuthenticationFilter; import com.alibaba.csp.sentinel.util.StringUtil; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +33,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import javax.annotation.PostConstruct; import javax.servlet.Filter; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * @author leyou diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java index 635489661..e105a0b27 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java @@ -15,24 +15,19 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.domain.vo.MachineInfoVo; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; /** * @author Carpenter Lee @@ -66,7 +61,7 @@ public class AppController { Collections.sort(list, Comparator.comparing(MachineInfo::getApp).thenComparing(MachineInfo::getIp).thenComparingInt(MachineInfo::getPort)); return Result.ofSuccess(MachineInfoVo.fromMachineInfoList(list)); } - + @RequestMapping(value = "/{app}/machine/remove.json") public Result removeMachineById( @PathVariable("app") String app, diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java index cb4fb67a9..9e1168dd7 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java @@ -15,9 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -import java.util.Random; -import java.util.concurrent.TimeUnit; - +import com.alibaba.csp.sentinel.Entry; +import com.alibaba.csp.sentinel.EntryType; +import com.alibaba.csp.sentinel.SphU; +import com.alibaba.csp.sentinel.context.ContextUtil; +import com.alibaba.csp.sentinel.slots.block.BlockException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; @@ -25,11 +27,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import com.alibaba.csp.sentinel.Entry; -import com.alibaba.csp.sentinel.EntryType; -import com.alibaba.csp.sentinel.SphU; -import com.alibaba.csp.sentinel.context.ContextUtil; -import com.alibaba.csp.sentinel.slots.block.BlockException; +import java.util.Random; +import java.util.concurrent.TimeUnit; @Controller @RequestMapping(value = "/demo", produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java index 53e5c024b..d6a362e56 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java @@ -16,11 +16,9 @@ package com.alibaba.csp.sentinel.dashboard.controller; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; -import com.alibaba.csp.sentinel.util.StringUtil; - import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; import com.alibaba.csp.sentinel.dashboard.domain.Result; - +import com.alibaba.csp.sentinel.util.StringUtil; import org.apache.http.conn.util.InetAddressUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java index ab90c0fc5..122ddc29b 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java @@ -15,17 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; -import java.util.concurrent.ConcurrentHashMap; - +import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.domain.vo.MetricVo; import com.alibaba.csp.sentinel.dashboard.repository.metric.MetricsRepository; +import com.alibaba.csp.sentinel.util.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,10 +28,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import com.alibaba.csp.sentinel.util.StringUtil; - -import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; -import com.alibaba.csp.sentinel.dashboard.domain.vo.MetricVo; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; /** * @author leyou diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java index 25577992d..0071dc41c 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java @@ -16,7 +16,6 @@ package com.alibaba.csp.sentinel.dashboard.controller; import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; -import com.alibaba.csp.sentinel.dashboard.auth.AuthService; import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; import com.alibaba.csp.sentinel.dashboard.client.CommandNotFoundException; import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; @@ -113,7 +112,7 @@ public class ParamFlowRuleController { } @PostMapping("/rule") - @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + @AuthAction(PrivilegeType.WRITE_RULE) public Result apiAddParamFlowRule(@RequestBody ParamFlowRuleEntity entity) { Result checkResult = checkEntityInternal(entity); if (checkResult != null) { @@ -182,7 +181,7 @@ public class ParamFlowRuleController { } @PutMapping("/rule/{id}") - @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + @AuthAction(PrivilegeType.WRITE_RULE) public Result apiUpdateParamFlowRule(@PathVariable("id") Long id, @RequestBody ParamFlowRuleEntity entity) { if (id == null || id <= 0) { diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java index 70382c7ea..79ac2b1dd 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java @@ -15,17 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -import java.util.List; -import java.util.stream.Collectors; - -import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.command.vo.NodeVo; - -import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.domain.vo.ResourceVo; - +import com.alibaba.csp.sentinel.util.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -33,6 +28,9 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.stream.Collectors; + /** * @author Carpenter Lee */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java index 69d66ea13..a8d01ab85 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java @@ -17,7 +17,6 @@ package com.alibaba.csp.sentinel.dashboard.controller; import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.util.StringUtil; - import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java index dc2e14f5b..2f85f5393 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java @@ -15,24 +15,19 @@ */ package com.alibaba.csp.sentinel.dashboard.controller.cluster; -import java.util.Collections; -import java.util.Set; - -import com.alibaba.csp.sentinel.util.StringUtil; - -import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppFullAssignRequest; +import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppFullAssignRequest; import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppSingleServerAssignRequest; import com.alibaba.csp.sentinel.dashboard.service.ClusterAssignService; -import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.util.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.Collections; +import java.util.Set; /** * @author Eric Zhao diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java index e9b9aed0e..468c79d60 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java @@ -15,18 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.controller.cluster; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ExecutionException; - import com.alibaba.csp.sentinel.cluster.ClusterStateManager; import com.alibaba.csp.sentinel.dashboard.client.CommandNotFoundException; -import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; -import com.alibaba.csp.sentinel.util.StringUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterClientModifyRequest; import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterModifyRequest; import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterServerModifyRequest; @@ -37,17 +30,17 @@ import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalS import com.alibaba.csp.sentinel.dashboard.service.ClusterConfigService; import com.alibaba.csp.sentinel.dashboard.util.ClusterEntityUtils; import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; -import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ExecutionException; /** * @author Eric Zhao diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java index b0a53e733..3a0542b43 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java @@ -37,9 +37,9 @@ import java.util.Arrays; import java.util.Date; import java.util.List; -import static com.alibaba.csp.sentinel.slots.block.RuleConstant.*; import static com.alibaba.csp.sentinel.adapter.gateway.common.SentinelGatewayConstants.*; import static com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity.*; +import static com.alibaba.csp.sentinel.slots.block.RuleConstant.*; /** * Gateway flow rule Controller for manage gateway flow rules. diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java index bf7300ce9..2ab097a8b 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java @@ -16,7 +16,6 @@ package com.alibaba.csp.sentinel.dashboard.controller.v2; import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; -import com.alibaba.csp.sentinel.dashboard.auth.AuthService; import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.dashboard.domain.Result; @@ -125,7 +124,7 @@ public class FlowControllerV2 { } @PostMapping("/rule") - @AuthAction(value = AuthService.PrivilegeType.WRITE_RULE) + @AuthAction(value = PrivilegeType.WRITE_RULE) public Result apiAddFlowRule(@RequestBody FlowRuleEntity entity) { Result checkResult = checkEntityInternal(entity); @@ -149,7 +148,7 @@ public class FlowControllerV2 { } @PutMapping("/rule/{id}") - @AuthAction(AuthService.PrivilegeType.WRITE_RULE) + @AuthAction(PrivilegeType.WRITE_RULE) public Result apiUpdateFlowRule(@PathVariable("id") Long id, @RequestBody FlowRuleEntity entity) { diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java index afcc81243..f8ef292c6 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java @@ -15,11 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.discovery; -import java.util.Objects; - import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; import com.alibaba.csp.sentinel.util.StringUtil; +import java.util.Objects; + public class MachineInfo implements Comparable { private String app = ""; @@ -90,7 +90,7 @@ public class MachineInfo implements Comparable { public long getHeartbeatVersion() { return heartbeatVersion; } - + public void setHeartbeatVersion(long heartbeatVersion) { this.heartbeatVersion = heartbeatVersion; } @@ -103,15 +103,15 @@ public class MachineInfo implements Comparable { this.version = version; return this; } - + public boolean isHealthy() { long delta = System.currentTimeMillis() - lastHeartbeat; return delta < DashboardConfig.getUnhealthyMachineMillis(); } - + /** * whether dead should be removed - * + * * @return */ public boolean isDead() { @@ -121,11 +121,11 @@ public class MachineInfo implements Comparable { } return false; } - + public long getLastHeartbeat() { return lastHeartbeat; } - + public void setLastHeartbeat(long lastHeartbeat) { this.lastHeartbeat = lastHeartbeat; } diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java index a4ab83acd..681b88469 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java @@ -15,6 +15,9 @@ */ package com.alibaba.csp.sentinel.dashboard.discovery; +import com.alibaba.csp.sentinel.util.AssertUtil; +import org.springframework.stereotype.Component; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -22,10 +25,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import com.alibaba.csp.sentinel.util.AssertUtil; - -import org.springframework.stereotype.Component; - /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java index be576160c..767683fd4 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java @@ -15,13 +15,13 @@ */ package com.alibaba.csp.sentinel.dashboard.domain; +import com.alibaba.csp.sentinel.command.vo.NodeVo; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import com.alibaba.csp.sentinel.command.vo.NodeVo; - /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java index 96a3dc933..255e2c5f2 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java @@ -15,11 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.cluster; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; + import java.util.List; import java.util.Set; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; - /** * @author Eric Zhao * @since 1.4.1 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java index f9d9bbc0e..f58f94826 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java @@ -15,10 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.cluster; -import java.util.Set; - import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; +import java.util.Set; + /** * @author Eric Zhao * @since 1.4.1 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java index 9389f693f..344640c6a 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java @@ -15,11 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.cluster.request; -import java.util.Set; - import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; +import java.util.Set; + /** * @author Eric Zhao * @since 1.4.0 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java index a76a7ff06..eeebda0d7 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java @@ -15,13 +15,13 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.cluster.state; -import java.util.List; -import java.util.Set; - import com.alibaba.csp.sentinel.dashboard.domain.cluster.ConnectionGroupVO; import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; +import java.util.List; +import java.util.Set; + /** * @author Eric Zhao * @since 1.4.0 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java index 66428c142..481347ba7 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java @@ -15,11 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.vo; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + import java.util.ArrayList; import java.util.List; -import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; - /** * @author leyou */ @@ -91,15 +91,15 @@ public class MachineInfoVo { public long getLastHeartbeat() { return lastHeartbeat; } - + public void setLastHeartbeat(long lastHeartbeat) { this.lastHeartbeat = lastHeartbeat; } - + public void setHeartbeatVersion(long heartbeatVersion) { this.heartbeatVersion = heartbeatVersion; } - + public long getHeartbeatVersion() { return heartbeatVersion; } diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java index af64941ee..d5b47618d 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java @@ -15,12 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.vo; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; + import java.util.ArrayList; import java.util.Collection; import java.util.List; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; - /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java index a8ffe24e9..d3e16c744 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java @@ -15,13 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.domain.vo; +import com.alibaba.csp.sentinel.command.vo.NodeVo; +import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; + import java.util.ArrayList; import java.util.List; -import com.alibaba.csp.sentinel.command.vo.NodeVo; - -import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; - /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/ApplicationEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/ApplicationEntity.java new file mode 100644 index 000000000..1b254d444 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/ApplicationEntity.java @@ -0,0 +1,106 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity; + +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; + +import java.util.Date; + +/** + * @author leyou + */ +public class ApplicationEntity { + + private Long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + private Integer appType; + private String activeConsole; + private Date lastFetch; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Integer getAppType() { + return appType; + } + + public void setAppType(Integer appType) { + this.appType = appType; + } + + public String getActiveConsole() { + return activeConsole; + } + + public Date getLastFetch() { + return lastFetch; + } + + public void setLastFetch(Date lastFetch) { + this.lastFetch = lastFetch; + } + + public void setActiveConsole(String activeConsole) { + this.activeConsole = activeConsole; + } + + public AppInfo toAppInfo() { + return new AppInfo(app, appType); + } + + @Override + public String toString() { + return "ApplicationEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", activeConsole='" + activeConsole + '\'' + + ", lastFetch=" + lastFetch + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MachineEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MachineEntity.java new file mode 100644 index 000000000..eccd96050 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MachineEntity.java @@ -0,0 +1,125 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity; + +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + +import java.util.Date; + +/** + * @author leyou + */ +public class MachineEntity { + private Long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + private String ip; + private String hostname; + private Date timestamp; + private Integer port; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public MachineInfo toMachineInfo() { + MachineInfo machineInfo = new MachineInfo(); + + machineInfo.setApp(app); + machineInfo.setHostname(hostname); + machineInfo.setIp(ip); + machineInfo.setPort(port); + machineInfo.setLastHeartbeat(timestamp.getTime()); + machineInfo.setHeartbeatVersion(timestamp.getTime()); + + return machineInfo; + } + + @Override + public String toString() { + return "MachineEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", hostname='" + hostname + '\'' + + ", timestamp=" + timestamp + + ", port=" + port + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricEntity.java new file mode 100644 index 000000000..c9f136b5c --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricEntity.java @@ -0,0 +1,219 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity; + +import java.util.Date; + +/** + * @author leyou + */ +public class MetricEntity { + private Long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + /** + * 监控信息的时间戳 + */ + private Date timestamp; + private String resource; + private Long passQps; + private Long successQps; + private Long blockQps; + private Long exceptionQps; + + /** + * summary rt of all success exit qps. + */ + private double rt; + + /** + * 本次聚合的总条数 + */ + private int count; + + private int resourceCode; + + public static MetricEntity copyOf(MetricEntity oldEntity) { + MetricEntity entity = new MetricEntity(); + entity.setId(oldEntity.getId()); + entity.setGmtCreate(oldEntity.getGmtCreate()); + entity.setGmtModified(oldEntity.getGmtModified()); + entity.setApp(oldEntity.getApp()); + entity.setTimestamp(oldEntity.getTimestamp()); + entity.setResource(oldEntity.getResource()); + entity.setPassQps(oldEntity.getPassQps()); + entity.setBlockQps(oldEntity.getBlockQps()); + entity.setSuccessQps(oldEntity.getSuccessQps()); + entity.setExceptionQps(oldEntity.getExceptionQps()); + entity.setRt(oldEntity.getRt()); + entity.setCount(oldEntity.getCount()); + return entity; + } + + public synchronized void addPassQps(Long passQps) { + this.passQps += passQps; + } + + public synchronized void addBlockQps(Long blockQps) { + this.blockQps += blockQps; + } + + public synchronized void addExceptionQps(Long exceptionQps) { + this.exceptionQps += exceptionQps; + } + + public synchronized void addCount(int count) { + this.count += count; + } + + public synchronized void addRtAndSuccessQps(double avgRt, Long successQps) { + this.rt += avgRt * successQps; + this.successQps += successQps; + } + + /** + * {@link #rt} = {@code avgRt * successQps} + * + * @param avgRt average rt of {@code successQps} + * @param successQps + */ + public synchronized void setRtAndSuccessQps(double avgRt, Long successQps) { + this.rt = avgRt * successQps; + this.successQps = successQps; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + this.resourceCode = resource.hashCode(); + } + + public Long getPassQps() { + return passQps; + } + + public void setPassQps(Long passQps) { + this.passQps = passQps; + } + + public Long getBlockQps() { + return blockQps; + } + + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; + } + + public Long getExceptionQps() { + return exceptionQps; + } + + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; + } + + public double getRt() { + return rt; + } + + public void setRt(double rt) { + this.rt = rt; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } + + public int getResourceCode() { + return resourceCode; + } + + public Long getSuccessQps() { + return successQps; + } + + public void setSuccessQps(Long successQps) { + this.successQps = successQps; + } + + @Override + public String toString() { + return "MetricEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", timestamp=" + timestamp + + ", resource='" + resource + '\'' + + ", passQps=" + passQps + + ", blockQps=" + blockQps + + ", successQps=" + successQps + + ", exceptionQps=" + exceptionQps + + ", rt=" + rt + + ", count=" + count + + ", resourceCode=" + resourceCode + + '}'; + } + +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricPositionEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricPositionEntity.java new file mode 100644 index 000000000..91a586b9d --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/MetricPositionEntity.java @@ -0,0 +1,121 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity; + +import java.util.Date; + +/** + * @author leyou + */ +public class MetricPositionEntity { + private long id; + private Date gmtCreate; + private Date gmtModified; + private String app; + private String ip; + /** + * Sentinel在该应用上使用的端口 + */ + private int port; + + /** + * 机器名,冗余字段 + */ + private String hostname; + + /** + * 上一次拉取的最晚时间戳 + */ + private Date lastFetch; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getHostname() { + return hostname; + } + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + public Date getLastFetch() { + return lastFetch; + } + + public void setLastFetch(Date lastFetch) { + this.lastFetch = lastFetch; + } + + @Override + public String toString() { + return "MetricPositionEntity{" + + "id=" + id + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", hostname='" + hostname + '\'' + + ", lastFetch=" + lastFetch + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/SentinelVersion.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/SentinelVersion.java new file mode 100644 index 000000000..c52cc2318 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/SentinelVersion.java @@ -0,0 +1,129 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class SentinelVersion { + private int majorVersion; + private int minorVersion; + private int fixVersion; + private String postfix; + + public SentinelVersion() { + this(0, 0, 0); + } + + public SentinelVersion(int major, int minor, int fix) { + this(major, minor, fix, null); + } + + public SentinelVersion(int major, int minor, int fix, String postfix) { + this.majorVersion = major; + this.minorVersion = minor; + this.fixVersion = fix; + this.postfix = postfix; + } + + /** + * 000, 000, 000 + */ + public int getFullVersion() { + return majorVersion * 1000000 + minorVersion * 1000 + fixVersion; + } + + public int getMajorVersion() { + return majorVersion; + } + + public SentinelVersion setMajorVersion(int majorVersion) { + this.majorVersion = majorVersion; + return this; + } + + public int getMinorVersion() { + return minorVersion; + } + + public SentinelVersion setMinorVersion(int minorVersion) { + this.minorVersion = minorVersion; + return this; + } + + public int getFixVersion() { + return fixVersion; + } + + public SentinelVersion setFixVersion(int fixVersion) { + this.fixVersion = fixVersion; + return this; + } + + public String getPostfix() { + return postfix; + } + + public SentinelVersion setPostfix(String postfix) { + this.postfix = postfix; + return this; + } + + public boolean greaterThan(SentinelVersion version) { + if (version == null) { + return true; + } + return getFullVersion() > version.getFullVersion(); + } + + public boolean greaterOrEqual(SentinelVersion version) { + if (version == null) { + return true; + } + return getFullVersion() >= version.getFullVersion(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + + SentinelVersion that = (SentinelVersion)o; + + if (getFullVersion() != that.getFullVersion()) { return false; } + return postfix != null ? postfix.equals(that.postfix) : that.postfix == null; + } + + @Override + public int hashCode() { + int result = majorVersion; + result = 31 * result + minorVersion; + result = 31 * result + fixVersion; + result = 31 * result + (postfix != null ? postfix.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "SentinelVersion{" + + "majorVersion=" + majorVersion + + ", minorVersion=" + minorVersion + + ", fixVersion=" + fixVersion + + ", postfix='" + postfix + '\'' + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiDefinitionEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiDefinitionEntity.java new file mode 100644 index 000000000..e45682e02 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiDefinitionEntity.java @@ -0,0 +1,209 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition; +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem; +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.Rule; + +import java.util.Date; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Set; + +/** + * Entity for {@link ApiDefinition}. + * + * @author cdfive + * @since 1.7.0 + */ +public class ApiDefinitionEntity implements RuleEntity { + + private Long id; + private String app; + private String ip; + private Integer port; + + private Date gmtCreate; + private Date gmtModified; + + private String apiName; + private Set predicateItems; + + public static ApiDefinitionEntity fromApiDefinition(String app, String ip, Integer port, ApiDefinition apiDefinition) { + ApiDefinitionEntity entity = new ApiDefinitionEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setApiName(apiDefinition.getApiName()); + + Set predicateItems = new LinkedHashSet<>(); + entity.setPredicateItems(predicateItems); + + Set apiPredicateItems = apiDefinition.getPredicateItems(); + if (apiPredicateItems != null) { + for (ApiPredicateItem apiPredicateItem : apiPredicateItems) { + com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity itemEntity = new com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity(); + predicateItems.add(itemEntity); + ApiPathPredicateItem pathPredicateItem = (ApiPathPredicateItem) apiPredicateItem; + itemEntity.setPattern(pathPredicateItem.getPattern()); + itemEntity.setMatchStrategy(pathPredicateItem.getMatchStrategy()); + } + } + + return entity; + } + + public ApiDefinition toApiDefinition() { + ApiDefinition apiDefinition = new ApiDefinition(); + apiDefinition.setApiName(apiName); + + Set apiPredicateItems = new LinkedHashSet<>(); + apiDefinition.setPredicateItems(apiPredicateItems); + + if (predicateItems != null) { + for (com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiPredicateItemEntity predicateItem : predicateItems) { + ApiPathPredicateItem apiPredicateItem = new ApiPathPredicateItem(); + apiPredicateItems.add(apiPredicateItem); + apiPredicateItem.setMatchStrategy(predicateItem.getMatchStrategy()); + apiPredicateItem.setPattern(predicateItem.getPattern()); + } + } + + return apiDefinition; + } + + public ApiDefinitionEntity() { + + } + + public ApiDefinitionEntity(String apiName, Set predicateItems) { + this.apiName = apiName; + this.predicateItems = predicateItems; + } + + public String getApiName() { + return apiName; + } + + public void setApiName(String apiName) { + this.apiName = apiName; + } + + public Set getPredicateItems() { + return predicateItems; + } + + public void setPredicateItems(Set predicateItems) { + this.predicateItems = predicateItems; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public Rule toRule() { + return null; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + ApiDefinitionEntity entity = (ApiDefinitionEntity) o; + return Objects.equals(id, entity.id) && + Objects.equals(app, entity.app) && + Objects.equals(ip, entity.ip) && + Objects.equals(port, entity.port) && + Objects.equals(gmtCreate, entity.gmtCreate) && + Objects.equals(gmtModified, entity.gmtModified) && + Objects.equals(apiName, entity.apiName) && + Objects.equals(predicateItems, entity.predicateItems); + } + + @Override + public int hashCode() { + return Objects.hash(id, app, ip, port, gmtCreate, gmtModified, apiName, predicateItems); + } + + @Override + public String toString() { + return "ApiDefinitionEntity{" + + "id=" + id + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", apiName='" + apiName + '\'' + + ", predicateItems=" + predicateItems + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiPredicateItemEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiPredicateItemEntity.java new file mode 100644 index 000000000..6be3a05f6 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/ApiPredicateItemEntity.java @@ -0,0 +1,79 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateItem; + +import java.util.Objects; + +/** + * Entity for {@link ApiPredicateItem}. + * + * @author cdfive + * @since 1.7.0 + */ +public class ApiPredicateItemEntity { + + private String pattern; + + private Integer matchStrategy; + + public ApiPredicateItemEntity() { + } + + public ApiPredicateItemEntity(String pattern, int matchStrategy) { + this.pattern = pattern; + this.matchStrategy = matchStrategy; + } + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public Integer getMatchStrategy() { + return matchStrategy; + } + + public void setMatchStrategy(Integer matchStrategy) { + this.matchStrategy = matchStrategy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + ApiPredicateItemEntity that = (ApiPredicateItemEntity) o; + return Objects.equals(pattern, that.pattern) && + Objects.equals(matchStrategy, that.matchStrategy); + } + + @Override + public int hashCode() { + return Objects.hash(pattern, matchStrategy); + } + + @Override + public String toString() { + return "ApiPredicateItemEntity{" + + "pattern='" + pattern + '\'' + + ", matchStrategy=" + matchStrategy + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayFlowRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayFlowRuleEntity.java new file mode 100644 index 000000000..a901567c3 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayFlowRuleEntity.java @@ -0,0 +1,355 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule; +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayParamFlowItem; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayParamFlowItemEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.Rule; + +import java.util.Date; +import java.util.Objects; + +/** + * Entity for {@link GatewayFlowRule}. + * + * @author cdfive + * @since 1.7.0 + */ +public class GatewayFlowRuleEntity implements RuleEntity { + + /**间隔单位*/ + /**0-秒*/ + public static final int INTERVAL_UNIT_SECOND = 0; + /**1-分*/ + public static final int INTERVAL_UNIT_MINUTE = 1; + /**2-时*/ + public static final int INTERVAL_UNIT_HOUR = 2; + /**3-天*/ + public static final int INTERVAL_UNIT_DAY = 3; + + private Long id; + private String app; + private String ip; + private Integer port; + + private Date gmtCreate; + private Date gmtModified; + + private String resource; + private Integer resourceMode; + + private Integer grade; + private Double count; + private Long interval; + private Integer intervalUnit; + + private Integer controlBehavior; + private Integer burst; + + private Integer maxQueueingTimeoutMs; + + private GatewayParamFlowItemEntity paramItem; + + public static Long calIntervalSec(Long interval, Integer intervalUnit) { + switch (intervalUnit) { + case INTERVAL_UNIT_SECOND: + return interval; + case INTERVAL_UNIT_MINUTE: + return interval * 60; + case INTERVAL_UNIT_HOUR: + return interval * 60 * 60; + case INTERVAL_UNIT_DAY: + return interval * 60 * 60 * 24; + default: + break; + } + + throw new IllegalArgumentException("Invalid intervalUnit: " + intervalUnit); + } + + public static Object[] parseIntervalSec(Long intervalSec) { + if (intervalSec % (60 * 60 * 24) == 0) { + return new Object[] {intervalSec / (60 * 60 * 24), INTERVAL_UNIT_DAY}; + } + + if (intervalSec % (60 * 60 ) == 0) { + return new Object[] {intervalSec / (60 * 60), INTERVAL_UNIT_HOUR}; + } + + if (intervalSec % 60 == 0) { + return new Object[] {intervalSec / 60, INTERVAL_UNIT_MINUTE}; + } + + return new Object[] {intervalSec, INTERVAL_UNIT_SECOND}; + } + + public GatewayFlowRule toGatewayFlowRule() { + GatewayFlowRule rule = new GatewayFlowRule(); + rule.setResource(resource); + rule.setResourceMode(resourceMode); + + rule.setGrade(grade); + rule.setCount(count); + rule.setIntervalSec(calIntervalSec(interval, intervalUnit)); + + rule.setControlBehavior(controlBehavior); + + if (burst != null) { + rule.setBurst(burst); + } + + if (maxQueueingTimeoutMs != null) { + rule.setMaxQueueingTimeoutMs(maxQueueingTimeoutMs); + } + + if (paramItem != null) { + GatewayParamFlowItem ruleItem = new GatewayParamFlowItem(); + rule.setParamItem(ruleItem); + ruleItem.setParseStrategy(paramItem.getParseStrategy()); + ruleItem.setFieldName(paramItem.getFieldName()); + ruleItem.setPattern(paramItem.getPattern()); + + if (paramItem.getMatchStrategy() != null) { + ruleItem.setMatchStrategy(paramItem.getMatchStrategy()); + } + } + + return rule; + } + + public static GatewayFlowRuleEntity fromGatewayFlowRule(String app, String ip, Integer port, GatewayFlowRule rule) { + GatewayFlowRuleEntity entity = new GatewayFlowRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + + entity.setResource(rule.getResource()); + entity.setResourceMode(rule.getResourceMode()); + + entity.setGrade(rule.getGrade()); + entity.setCount(rule.getCount()); + Object[] intervalSecResult = parseIntervalSec(rule.getIntervalSec()); + entity.setInterval((Long) intervalSecResult[0]); + entity.setIntervalUnit((Integer) intervalSecResult[1]); + + entity.setControlBehavior(rule.getControlBehavior()); + entity.setBurst(rule.getBurst()); + entity.setMaxQueueingTimeoutMs(rule.getMaxQueueingTimeoutMs()); + + GatewayParamFlowItem paramItem = rule.getParamItem(); + if (paramItem != null) { + GatewayParamFlowItemEntity itemEntity = new GatewayParamFlowItemEntity(); + entity.setParamItem(itemEntity); + itemEntity.setParseStrategy(paramItem.getParseStrategy()); + itemEntity.setFieldName(paramItem.getFieldName()); + itemEntity.setPattern(paramItem.getPattern()); + itemEntity.setMatchStrategy(paramItem.getMatchStrategy()); + } + + return entity; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + @Override + public Rule toRule() { + return null; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + public GatewayParamFlowItemEntity getParamItem() { + return paramItem; + } + + public void setParamItem(GatewayParamFlowItemEntity paramItem) { + this.paramItem = paramItem; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getResourceMode() { + return resourceMode; + } + + public void setResourceMode(Integer resourceMode) { + this.resourceMode = resourceMode; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Long getInterval() { + return interval; + } + + public void setInterval(Long interval) { + this.interval = interval; + } + + public Integer getIntervalUnit() { + return intervalUnit; + } + + public void setIntervalUnit(Integer intervalUnit) { + this.intervalUnit = intervalUnit; + } + + public Integer getControlBehavior() { + return controlBehavior; + } + + public void setControlBehavior(Integer controlBehavior) { + this.controlBehavior = controlBehavior; + } + + public Integer getBurst() { + return burst; + } + + public void setBurst(Integer burst) { + this.burst = burst; + } + + public Integer getMaxQueueingTimeoutMs() { + return maxQueueingTimeoutMs; + } + + public void setMaxQueueingTimeoutMs(Integer maxQueueingTimeoutMs) { + this.maxQueueingTimeoutMs = maxQueueingTimeoutMs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + GatewayFlowRuleEntity that = (GatewayFlowRuleEntity) o; + return Objects.equals(id, that.id) && + Objects.equals(app, that.app) && + Objects.equals(ip, that.ip) && + Objects.equals(port, that.port) && + Objects.equals(gmtCreate, that.gmtCreate) && + Objects.equals(gmtModified, that.gmtModified) && + Objects.equals(resource, that.resource) && + Objects.equals(resourceMode, that.resourceMode) && + Objects.equals(grade, that.grade) && + Objects.equals(count, that.count) && + Objects.equals(interval, that.interval) && + Objects.equals(intervalUnit, that.intervalUnit) && + Objects.equals(controlBehavior, that.controlBehavior) && + Objects.equals(burst, that.burst) && + Objects.equals(maxQueueingTimeoutMs, that.maxQueueingTimeoutMs) && + Objects.equals(paramItem, that.paramItem); + } + + @Override + public int hashCode() { + return Objects.hash(id, app, ip, port, gmtCreate, gmtModified, resource, resourceMode, grade, count, interval, intervalUnit, controlBehavior, burst, maxQueueingTimeoutMs, paramItem); + } + + @Override + public String toString() { + return "GatewayFlowRuleEntity{" + + "id=" + id + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", port=" + port + + ", gmtCreate=" + gmtCreate + + ", gmtModified=" + gmtModified + + ", resource='" + resource + '\'' + + ", resourceMode=" + resourceMode + + ", grade=" + grade + + ", count=" + count + + ", interval=" + interval + + ", intervalUnit=" + intervalUnit + + ", controlBehavior=" + controlBehavior + + ", burst=" + burst + + ", maxQueueingTimeoutMs=" + maxQueueingTimeoutMs + + ", paramItem=" + paramItem + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayParamFlowItemEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayParamFlowItemEntity.java new file mode 100644 index 000000000..cc29bb95a --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/gateway/GatewayParamFlowItemEntity.java @@ -0,0 +1,95 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.gateway; + +import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayParamFlowItem; + +import java.util.Objects; + +/** + * Entity for {@link GatewayParamFlowItem}. + * + * @author cdfive + * @since 1.7.0 + */ +public class GatewayParamFlowItemEntity { + + private Integer parseStrategy; + + private String fieldName; + + private String pattern; + + private Integer matchStrategy; + + public Integer getParseStrategy() { + return parseStrategy; + } + + public void setParseStrategy(Integer parseStrategy) { + this.parseStrategy = parseStrategy; + } + + public String getFieldName() { + return fieldName; + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public Integer getMatchStrategy() { + return matchStrategy; + } + + public void setMatchStrategy(Integer matchStrategy) { + this.matchStrategy = matchStrategy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { return true; } + if (o == null || getClass() != o.getClass()) { return false; } + GatewayParamFlowItemEntity that = (GatewayParamFlowItemEntity) o; + return Objects.equals(parseStrategy, that.parseStrategy) && + Objects.equals(fieldName, that.fieldName) && + Objects.equals(pattern, that.pattern) && + Objects.equals(matchStrategy, that.matchStrategy); + } + + @Override + public int hashCode() { + return Objects.hash(parseStrategy, fieldName, pattern, matchStrategy); + } + + @Override + public String toString() { + return "GatewayParamFlowItemEntity{" + + "parseStrategy=" + parseStrategy + + ", fieldName='" + fieldName + '\'' + + ", pattern='" + pattern + '\'' + + ", matchStrategy=" + matchStrategy + + '}'; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AbstractRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AbstractRuleEntity.java new file mode 100644 index 000000000..30f9c17bd --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AbstractRuleEntity.java @@ -0,0 +1,112 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.AbstractRule; + +import java.util.Date; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public abstract class AbstractRuleEntity implements RuleEntity { + + protected Long id; + + protected String app; + protected String ip; + protected Integer port; + + protected T rule; + + private Date gmtCreate; + private Date gmtModified; + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public AbstractRuleEntity setApp(String app) { + this.app = app; + return this; + } + + @Override + public String getIp() { + return ip; + } + + public AbstractRuleEntity setIp(String ip) { + this.ip = ip; + return this; + } + + @Override + public Integer getPort() { + return port; + } + + public AbstractRuleEntity setPort(Integer port) { + this.port = port; + return this; + } + + public T getRule() { + return rule; + } + + public AbstractRuleEntity setRule(T rule) { + this.rule = rule; + return this; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public AbstractRuleEntity setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + return this; + } + + public Date getGmtModified() { + return gmtModified; + } + + public AbstractRuleEntity setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + return this; + } + + @Override + public T toRule() { + return rule; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AuthorityRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AuthorityRuleEntity.java new file mode 100644 index 000000000..d10f628d5 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/AuthorityRuleEntity.java @@ -0,0 +1,63 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AbstractRuleEntity; +import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class AuthorityRuleEntity extends AbstractRuleEntity { + + public AuthorityRuleEntity() { + } + + public AuthorityRuleEntity(AuthorityRule authorityRule) { + AssertUtil.notNull(authorityRule, "Authority rule should not be null"); + this.rule = authorityRule; + } + + public static AuthorityRuleEntity fromAuthorityRule(String app, String ip, Integer port, AuthorityRule rule) { + AuthorityRuleEntity entity = new AuthorityRuleEntity(rule); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + return entity; + } + + @JsonIgnore + @JSONField(serialize = false) + public String getLimitApp() { + return rule.getLimitApp(); + } + + @JsonIgnore + @JSONField(serialize = false) + public String getResource() { + return rule.getResource(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getStrategy() { + return rule.getStrategy(); + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/DegradeRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/DegradeRuleEntity.java new file mode 100644 index 000000000..2b68c33e2 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/DegradeRuleEntity.java @@ -0,0 +1,203 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; + +import java.util.Date; + +/** + * @author leyou + */ +public class DegradeRuleEntity implements RuleEntity { + + private Long id; + private String app; + + private String ip; + private Integer port; + + private String resource; + private String limitApp; + private Double count; + private Integer timeWindow; + private Integer grade; + private Integer minRequestAmount; + private Double slowRatioThreshold; + private Integer statIntervalMs; + + private Date gmtCreate; + private Date gmtModified; + + public static DegradeRuleEntity fromDegradeRule(String app, String ip, Integer port, DegradeRule rule) { + DegradeRuleEntity entity = new DegradeRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setResource(rule.getResource()); + entity.setLimitApp(rule.getLimitApp()); + entity.setCount(rule.getCount()); + entity.setTimeWindow(rule.getTimeWindow()); + entity.setGrade(rule.getGrade()); + entity.setMinRequestAmount(rule.getMinRequestAmount()); + entity.setSlowRatioThreshold(rule.getSlowRatioThreshold()); + entity.setStatIntervalMs(rule.getStatIntervalMs()); + return entity; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public String getLimitApp() { + return limitApp; + } + + public void setLimitApp(String limitApp) { + this.limitApp = limitApp; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Integer getTimeWindow() { + return timeWindow; + } + + public void setTimeWindow(Integer timeWindow) { + this.timeWindow = timeWindow; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Integer getMinRequestAmount() { + return minRequestAmount; + } + + public DegradeRuleEntity setMinRequestAmount(Integer minRequestAmount) { + this.minRequestAmount = minRequestAmount; + return this; + } + + public Double getSlowRatioThreshold() { + return slowRatioThreshold; + } + + public DegradeRuleEntity setSlowRatioThreshold(Double slowRatioThreshold) { + this.slowRatioThreshold = slowRatioThreshold; + return this; + } + + public Integer getStatIntervalMs() { + return statIntervalMs; + } + + public DegradeRuleEntity setStatIntervalMs(Integer statIntervalMs) { + this.statIntervalMs = statIntervalMs; + return this; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public DegradeRule toRule() { + DegradeRule rule = new DegradeRule(); + rule.setResource(resource); + rule.setLimitApp(limitApp); + rule.setCount(count); + rule.setTimeWindow(timeWindow); + rule.setGrade(grade); + if (minRequestAmount != null) { + rule.setMinRequestAmount(minRequestAmount); + } + if (slowRatioThreshold != null) { + rule.setSlowRatioThreshold(slowRatioThreshold); + } + if (statIntervalMs != null) { + rule.setStatIntervalMs(statIntervalMs); + } + + return rule; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/FlowRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/FlowRuleEntity.java new file mode 100644 index 000000000..1ca816dae --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/FlowRuleEntity.java @@ -0,0 +1,250 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.block.flow.ClusterFlowConfig; +import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; + +import java.util.Date; + +/** + * @author leyou + */ +public class FlowRuleEntity implements RuleEntity { + + private Long id; + private String app; + private String ip; + private Integer port; + private String limitApp; + private String resource; + /** + * 0为线程数;1为qps + */ + private Integer grade; + private Double count; + /** + * 0为直接限流;1为关联限流;2为链路限流 + ***/ + private Integer strategy; + private String refResource; + /** + * 0. default, 1. warm up, 2. rate limiter + */ + private Integer controlBehavior; + private Integer warmUpPeriodSec; + /** + * max queueing time in rate limiter behavior + */ + private Integer maxQueueingTimeMs; + + private boolean clusterMode; + /** + * Flow rule config for cluster mode. + */ + private ClusterFlowConfig clusterConfig; + + private Date gmtCreate; + private Date gmtModified; + + public static FlowRuleEntity fromFlowRule(String app, String ip, Integer port, FlowRule rule) { + FlowRuleEntity entity = new FlowRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setLimitApp(rule.getLimitApp()); + entity.setResource(rule.getResource()); + entity.setGrade(rule.getGrade()); + entity.setCount(rule.getCount()); + entity.setStrategy(rule.getStrategy()); + entity.setRefResource(rule.getRefResource()); + entity.setControlBehavior(rule.getControlBehavior()); + entity.setWarmUpPeriodSec(rule.getWarmUpPeriodSec()); + entity.setMaxQueueingTimeMs(rule.getMaxQueueingTimeMs()); + entity.setClusterMode(rule.isClusterMode()); + entity.setClusterConfig(rule.getClusterConfig()); + return entity; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + public String getLimitApp() { + return limitApp; + } + + public void setLimitApp(String limitApp) { + this.limitApp = limitApp; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public Integer getGrade() { + return grade; + } + + public void setGrade(Integer grade) { + this.grade = grade; + } + + public Double getCount() { + return count; + } + + public void setCount(Double count) { + this.count = count; + } + + public Integer getStrategy() { + return strategy; + } + + public void setStrategy(Integer strategy) { + this.strategy = strategy; + } + + public String getRefResource() { + return refResource; + } + + public void setRefResource(String refResource) { + this.refResource = refResource; + } + + public Integer getControlBehavior() { + return controlBehavior; + } + + public void setControlBehavior(Integer controlBehavior) { + this.controlBehavior = controlBehavior; + } + + public Integer getWarmUpPeriodSec() { + return warmUpPeriodSec; + } + + public void setWarmUpPeriodSec(Integer warmUpPeriodSec) { + this.warmUpPeriodSec = warmUpPeriodSec; + } + + public Integer getMaxQueueingTimeMs() { + return maxQueueingTimeMs; + } + + public void setMaxQueueingTimeMs(Integer maxQueueingTimeMs) { + this.maxQueueingTimeMs = maxQueueingTimeMs; + } + + public boolean isClusterMode() { + return clusterMode; + } + + public FlowRuleEntity setClusterMode(boolean clusterMode) { + this.clusterMode = clusterMode; + return this; + } + + public ClusterFlowConfig getClusterConfig() { + return clusterConfig; + } + + public FlowRuleEntity setClusterConfig(ClusterFlowConfig clusterConfig) { + this.clusterConfig = clusterConfig; + return this; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public FlowRule toRule() { + FlowRule flowRule = new FlowRule(); + flowRule.setCount(this.count); + flowRule.setGrade(this.grade); + flowRule.setResource(this.resource); + flowRule.setLimitApp(this.limitApp); + flowRule.setRefResource(this.refResource); + flowRule.setStrategy(this.strategy); + if (this.controlBehavior != null) { + flowRule.setControlBehavior(controlBehavior); + } + if (this.warmUpPeriodSec != null) { + flowRule.setWarmUpPeriodSec(warmUpPeriodSec); + } + if (this.maxQueueingTimeMs != null) { + flowRule.setMaxQueueingTimeMs(maxQueueingTimeMs); + } + flowRule.setClusterMode(clusterMode); + flowRule.setClusterConfig(clusterConfig); + return flowRule; + } + +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/ParamFlowRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/ParamFlowRuleEntity.java new file mode 100644 index 000000000..64418be40 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/ParamFlowRuleEntity.java @@ -0,0 +1,121 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AbstractRuleEntity; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowClusterConfig; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowItem; +import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowRule; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.fastjson.annotation.JSONField; +import com.fasterxml.jackson.annotation.JsonIgnore; + +import java.util.List; + +/** + * @author Eric Zhao + * @since 0.2.1 + */ +public class ParamFlowRuleEntity extends AbstractRuleEntity { + + public ParamFlowRuleEntity() { + } + + public ParamFlowRuleEntity(ParamFlowRule rule) { + AssertUtil.notNull(rule, "Authority rule should not be null"); + this.rule = rule; + } + + public static ParamFlowRuleEntity fromParamFlowRule(String app, String ip, Integer port, ParamFlowRule rule) { + ParamFlowRuleEntity entity = new ParamFlowRuleEntity(rule); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + return entity; + } + + @JsonIgnore + @JSONField(serialize = false) + public String getLimitApp() { + return rule.getLimitApp(); + } + + @JsonIgnore + @JSONField(serialize = false) + public String getResource() { + return rule.getResource(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getGrade() { + return rule.getGrade(); + } + + @JsonIgnore + @JSONField(serialize = false) + public Integer getParamIdx() { + return rule.getParamIdx(); + } + + @JsonIgnore + @JSONField(serialize = false) + public double getCount() { + return rule.getCount(); + } + + @JsonIgnore + @JSONField(serialize = false) + public List getParamFlowItemList() { + return rule.getParamFlowItemList(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getControlBehavior() { + return rule.getControlBehavior(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getMaxQueueingTimeMs() { + return rule.getMaxQueueingTimeMs(); + } + + @JsonIgnore + @JSONField(serialize = false) + public int getBurstCount() { + return rule.getBurstCount(); + } + + @JsonIgnore + @JSONField(serialize = false) + public long getDurationInSec() { + return rule.getDurationInSec(); + } + + @JsonIgnore + @JSONField(serialize = false) + public boolean isClusterMode() { + return rule.isClusterMode(); + } + + @JsonIgnore + @JSONField(serialize = false) + public ParamFlowClusterConfig getClusterConfig() { + return rule.getClusterConfig(); + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/RuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/RuleEntity.java new file mode 100644 index 000000000..c1ca3c425 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/RuleEntity.java @@ -0,0 +1,40 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.slots.block.Rule; + +import java.util.Date; + +/** + * @author leyou + */ +public interface RuleEntity { + + Long getId(); + + void setId(Long id); + + String getApp(); + + String getIp(); + + Integer getPort(); + + Date getGmtCreate(); + + Rule toRule(); +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/SystemRuleEntity.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/SystemRuleEntity.java new file mode 100644 index 000000000..e735b3065 --- /dev/null +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/entity/rule/SystemRuleEntity.java @@ -0,0 +1,159 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.csp.sentinel.dashboard.entity.rule; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.slots.system.SystemRule; + +import java.util.Date; + +/** + * @author leyou + */ +public class SystemRuleEntity implements RuleEntity { + + private Long id; + + private String app; + private String ip; + private Integer port; + private Double highestSystemLoad; + private Long avgRt; + private Long maxThread; + private Double qps; + private Double highestCpuUsage; + + private Date gmtCreate; + private Date gmtModified; + + public static SystemRuleEntity fromSystemRule(String app, String ip, Integer port, SystemRule rule) { + SystemRuleEntity entity = new SystemRuleEntity(); + entity.setApp(app); + entity.setIp(ip); + entity.setPort(port); + entity.setHighestSystemLoad(rule.getHighestSystemLoad()); + entity.setHighestCpuUsage(rule.getHighestCpuUsage()); + entity.setAvgRt(rule.getAvgRt()); + entity.setMaxThread(rule.getMaxThread()); + entity.setQps(rule.getQps()); + return entity; + } + + @Override + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + @Override + public Long getId() { + return id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Override + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public Double getHighestSystemLoad() { + return highestSystemLoad; + } + + public void setHighestSystemLoad(Double highestSystemLoad) { + this.highestSystemLoad = highestSystemLoad; + } + + public Long getAvgRt() { + return avgRt; + } + + public void setAvgRt(Long avgRt) { + this.avgRt = avgRt; + } + + public Long getMaxThread() { + return maxThread; + } + + public void setMaxThread(Long maxThread) { + this.maxThread = maxThread; + } + + public Double getQps() { + return qps; + } + + public void setQps(Double qps) { + this.qps = qps; + } + + public Double getHighestCpuUsage() { + return highestCpuUsage; + } + + public void setHighestCpuUsage(Double highestCpuUsage) { + this.highestCpuUsage = highestCpuUsage; + } + + @Override + public Date getGmtCreate() { + return gmtCreate; + } + + public void setGmtCreate(Date gmtCreate) { + this.gmtCreate = gmtCreate; + } + + public Date getGmtModified() { + return gmtModified; + } + + public void setGmtModified(Date gmtModified) { + this.gmtModified = gmtModified; + } + + @Override + public SystemRule toRule() { + SystemRule rule = new SystemRule(); + rule.setHighestSystemLoad(highestSystemLoad); + rule.setAvgRt(avgRt); + rule.setMaxThread(maxThread); + rule.setQps(qps); + rule.setHighestCpuUsage(highestCpuUsage); + return rule; + } +} diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java index 13bd4db5d..3c3d4a48c 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java @@ -15,26 +15,6 @@ */ package com.alibaba.csp.sentinel.dashboard.metric; -import java.net.ConnectException; -import java.net.SocketTimeoutException; -import java.nio.charset.Charset; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.RejectedExecutionHandler; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - import com.alibaba.csp.sentinel.Constants; import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory; import com.alibaba.csp.sentinel.config.SentinelConfig; @@ -42,10 +22,9 @@ import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.repository.metric.MetricsRepository; import com.alibaba.csp.sentinel.node.metric.MetricNode; import com.alibaba.csp.sentinel.util.StringUtil; - -import com.alibaba.csp.sentinel.dashboard.repository.metric.MetricsRepository; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.concurrent.FutureCallback; @@ -61,6 +40,14 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.net.ConnectException; +import java.net.SocketTimeoutException; +import java.nio.charset.Charset; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy; +import java.util.concurrent.atomic.AtomicLong; + /** * Fetch metric of machines. * diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java index 4afeb0ccb..a3a5e214f 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java @@ -20,11 +20,7 @@ import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.TimeUtil; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java index bbeb88891..ff0d1bdfb 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java @@ -15,12 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import java.util.concurrent.atomic.AtomicLong; - import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; - import org.springframework.stereotype.Component; +import java.util.concurrent.atomic.AtomicLong; + /** * In-memory storage for authority rules. * diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java index 0b9bf7e1a..453c49437 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java @@ -15,12 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import java.util.concurrent.atomic.AtomicLong; - import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; - import org.springframework.stereotype.Component; +import java.util.concurrent.atomic.AtomicLong; + /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java index c5a2a347d..43a065d1b 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java @@ -15,13 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import java.util.concurrent.atomic.AtomicLong; - import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.slots.block.flow.ClusterFlowConfig; - import org.springframework.stereotype.Component; +import java.util.concurrent.atomic.AtomicLong; + /** * Store {@link FlowRuleEntity} in memory. * diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java index 5a82f1387..4d3753e01 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java @@ -15,13 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import java.util.concurrent.atomic.AtomicLong; - import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowClusterConfig; - import org.springframework.stereotype.Component; +import java.util.concurrent.atomic.AtomicLong; + /** * @author Eric Zhao * @since 0.2.1 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java index 8d3949b41..dae6ceaeb 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java @@ -15,12 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import java.util.concurrent.atomic.AtomicLong; - import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; - import org.springframework.stereotype.Component; +import java.util.concurrent.atomic.AtomicLong; + /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java index 08d623cc3..35f12dc75 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java @@ -15,15 +15,15 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.util.AssertUtil; + import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; -import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; -import com.alibaba.csp.sentinel.util.AssertUtil; - /** * @author leyou */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java index 266c2fab6..44d3ebc1c 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java @@ -15,10 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import java.util.List; - import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import java.util.List; + /** * Interface to store and find rules. * diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java index 9f9ce5cc1..e2a44b4f7 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java @@ -15,20 +15,18 @@ */ package com.alibaba.csp.sentinel.dashboard.rule; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; import com.alibaba.csp.sentinel.util.StringUtil; - -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + /** * @author Eric Zhao */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java index 9afbcf346..59a49a4cc 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java @@ -15,18 +15,17 @@ */ package com.alibaba.csp.sentinel.dashboard.rule; -import java.util.List; -import java.util.Set; - import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; import com.alibaba.csp.sentinel.util.StringUtil; - -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Set; + /** * @author Eric Zhao * @since 1.4.0 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java index 79a796ed5..e0749b68d 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java @@ -15,12 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.service; -import java.util.List; -import java.util.Set; - import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; +import java.util.List; +import java.util.Set; + /** * @author Eric Zhao * @since 1.4.1 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java index 494e7afdb..ac9798fcb 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java @@ -15,21 +15,7 @@ */ package com.alibaba.csp.sentinel.dashboard.service; -import java.util.HashSet; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - import com.alibaba.csp.sentinel.cluster.ClusterStateManager; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; -import com.alibaba.csp.sentinel.util.AssertUtil; -import com.alibaba.csp.sentinel.util.function.Tuple2; - import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; @@ -37,12 +23,21 @@ import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientCon import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; import com.alibaba.csp.sentinel.dashboard.util.MachineUtils; +import com.alibaba.csp.sentinel.util.AssertUtil; +import com.alibaba.csp.sentinel.util.function.Tuple2; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + /** * @author Eric Zhao * @since 1.4.1 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java index 1691deb01..f723ed71d 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java @@ -15,32 +15,31 @@ */ package com.alibaba.csp.sentinel.dashboard.service; +import com.alibaba.csp.sentinel.cluster.ClusterStateManager; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterClientModifyRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterServerModifyRequest; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterClientStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStateVO; +import com.alibaba.csp.sentinel.dashboard.util.AsyncUtils; +import com.alibaba.csp.sentinel.dashboard.util.ClusterEntityUtils; +import com.alibaba.csp.sentinel.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -import com.alibaba.csp.sentinel.cluster.ClusterStateManager; -import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; -import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; -import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterServerModifyRequest; -import com.alibaba.csp.sentinel.dashboard.util.AsyncUtils; -import com.alibaba.csp.sentinel.dashboard.util.ClusterEntityUtils; -import com.alibaba.csp.sentinel.util.StringUtil; - -import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterClientModifyRequest; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterClientStateVO; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStateVO; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ClusterClientConfig; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerFlowConfig; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.config.ServerTransportConfig; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - /** * @author Eric Zhao * @since 1.4.0 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java index 9881cdace..55b676a3c 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java @@ -15,15 +15,15 @@ */ package com.alibaba.csp.sentinel.dashboard.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.List; import java.util.Objects; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * @author Eric Zhao * @since 1.4.1 diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java index 5b3073cfe..7413d2670 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java @@ -15,11 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.util; -import java.util.Optional; - import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.function.Tuple2; +import java.util.Optional; + /** * @author Eric Zhao */ diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java index 71b9ac275..711eed62a 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java @@ -15,11 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.util; -import java.util.Optional; - +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; import com.alibaba.csp.sentinel.util.StringUtil; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import java.util.Optional; /** * Util class for parsing version. @@ -43,7 +42,7 @@ public final class VersionUtils { try { String versionFull = verStr; SentinelVersion version = new SentinelVersion(); - + // postfix int index = versionFull.indexOf("-"); if (index == 0) { @@ -55,11 +54,11 @@ public final class VersionUtils { } else if (index > 0) { version.setPostfix(versionFull.substring(index + 1)); } - + if (index >= 0) { versionFull = versionFull.substring(0, index); } - + // x.x.x int segment = 0; int[] ver = new int[3]; @@ -75,7 +74,7 @@ public final class VersionUtils { versionFull = versionFull.substring(index + 1); segment ++; } - + if (ver[0] < 1) { // Wrong format, return empty. return Optional.empty(); diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README.md b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README.md index 20f0de67f..d2a85311a 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README.md +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README.md @@ -12,22 +12,22 @@ ## Install Packages -``` +```shell npm install ``` ## Start Development -``` +```shell npm start ``` ## Build for production -``` +```shell npm run build ``` ## Credit -- [sb-admin-angular](https://github.com/start-angular/sb-admin-angular) \ No newline at end of file +- [sb-admin-angular](https://github.com/start-angular/sb-admin-angular) diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README_zh.md b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README_zh.md index 48dae7450..e089b02be 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README_zh.md +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/README_zh.md @@ -12,22 +12,22 @@ ## 安装依赖 -``` +```shell npm i ``` ## 开始本地开发 -``` +```shell npm start ``` ## 构建前端资源 -``` +```shell npm run build ``` ## Credit -- [sb-admin-angular](https://github.com/start-angular/sb-admin-angular) \ No newline at end of file +- [sb-admin-angular](https://github.com/start-angular/sb-admin-angular) diff --git a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html index 4584e89ba..b72294da5 100644 --- a/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html +++ b/ruoyi-visual/ruoyi-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html @@ -4,6 +4,10 @@ Sentinel 控制台 {{dashboardVersion}}