From 0d803bbe68df942677c14b9dd8adcb65fa46aa73 Mon Sep 17 00:00:00 2001 From: fxz <2235602974@qq.com> Date: Fri, 15 Apr 2022 06:12:09 +0000 Subject: [PATCH] !1 up springbootadmin 2.6.6 * :arrow_up: up sentinel 1.8.4 --- pig-common/pig-common-bom/pom.xml | 38 ++++- .../sentinel/dashboard/auth/AuthAction.java | 8 +- .../sentinel/dashboard/auth/AuthService.java | 2 +- .../auth/AuthorizationInterceptor.java | 50 +------ .../auth/DefaultAuthorizationInterceptor.java | 75 ++++++++++ .../DefaultLoginAuthenticationFilter.java | 132 ++++++++++++++++++ .../dashboard/auth/FakeAuthServiceImpl.java | 10 +- .../auth/LoginAuthenticationFilter.java | 99 +------------ .../auth/SimpleWebAuthServiceImpl.java | 9 +- .../dashboard/client/SentinelApiClient.java | 58 +++++--- .../dashboard/config/AuthConfiguration.java | 59 ++++++++ .../dashboard/config/AuthProperties.java | 33 +++++ .../dashboard/config/DashboardConfig.java | 6 +- .../sentinel/dashboard/config/WebConfig.java | 10 +- .../dashboard/controller/AppController.java | 19 ++- .../controller/AuthorityRuleController.java | 26 ++-- .../controller/DegradeController.java | 23 ++- .../dashboard/controller/DemoController.java | 15 +- .../controller/FlowControllerV1.java | 35 +++-- .../controller/MachineRegistryController.java | 29 ++-- .../controller/MetricController.java | 18 ++- .../controller/ParamFlowRuleController.java | 51 ++++--- .../controller/ResourceController.java | 12 +- .../controller/SystemController.java | 16 ++- .../controller/VersionController.java | 1 + .../cluster/ClusterAssignController.java | 19 ++- .../cluster/ClusterConfigController.java | 27 ++-- .../gateway/GatewayFlowRuleController.java | 2 +- .../controller/v2/FlowControllerV2.java | 26 ++-- .../datasource/entity/ApplicationEntity.java | 4 +- .../datasource/entity/MachineEntity.java | 4 +- .../datasource/entity/MetricEntity.java | 0 .../entity/MetricPositionEntity.java | 0 .../entity/rule/AbstractRuleEntity.java | 5 +- .../entity/rule/DegradeRuleEntity.java | 4 +- .../entity/rule/FlowRuleEntity.java | 4 +- .../entity/rule/ParamFlowRuleEntity.java | 2 +- .../datasource/entity/rule/RuleEntity.java | 4 +- .../entity/rule/SystemRuleEntity.java | 0 .../sentinel/dashboard/discovery/AppInfo.java | 10 +- .../dashboard/discovery/AppManagement.java | 9 +- .../dashboard/discovery/MachineDiscovery.java | 0 .../dashboard/discovery/MachineInfo.java | 4 +- .../discovery/SimpleMachineDiscovery.java | 7 +- .../dashboard/domain/ResourceTreeNode.java | 4 +- .../csp/sentinel/dashboard/domain/Result.java | 0 .../cluster/ClusterAppFullAssignRequest.java | 4 +- .../ClusterAppSingleServerAssignRequest.java | 4 +- .../request/ClusterServerModifyRequest.java | 4 +- .../cluster/state/ClusterServerStateVO.java | 6 +- .../dashboard/domain/vo/MachineInfoVo.java | 4 +- .../dashboard/domain/vo/MetricVo.java | 4 +- .../dashboard/domain/vo/ResourceVo.java | 7 +- .../vo/gateway/api/ApiPredicateItemVo.java | 13 ++ .../dashboard/metric/MetricFetcher.java | 83 ++++++----- .../metric/InMemoryMetricsRepository.java | 6 +- .../rule/InMemAuthorityRuleStore.java | 7 +- .../rule/InMemDegradeRuleStore.java | 7 +- .../repository/rule/InMemFlowRuleStore.java | 5 +- .../rule/InMemParamFlowRuleStore.java | 5 +- .../repository/rule/InMemSystemRuleStore.java | 7 +- .../rule/InMemoryRuleRepositoryAdapter.java | 8 +- .../repository/rule/RuleRepository.java | 4 +- .../dashboard/rule/FlowRuleApiProvider.java | 18 +-- .../dashboard/rule/FlowRuleApiPublisher.java | 9 +- .../service/ClusterAssignService.java | 6 +- .../service/ClusterAssignServiceImpl.java | 23 +-- .../service/ClusterConfigService.java | 39 +++--- .../sentinel/dashboard/util/AsyncUtils.java | 6 +- .../dashboard/util/ClusterEntityUtils.java | 25 +++- .../sentinel/dashboard/util/MachineUtils.java | 4 +- .../sentinel/dashboard/util/VersionUtils.java | 13 +- .../src/main/webapp/resources/.gitignore | 0 .../src/main/webapp/resources/.jshintrc | 0 .../src/main/webapp/resources/README.md | 0 .../main/webapp/resources/app/scripts/app.js | 0 .../app/scripts/controllers/degrade.js | 0 .../app/scripts/controllers/flow_v1.js | 0 .../app/scripts/controllers/flow_v2.js | 0 .../resources/app/scripts/controllers/home.js | 0 .../app/scripts/controllers/identity.js | 0 .../app/scripts/controllers/machine.js | 0 .../resources/app/scripts/controllers/main.js | 0 .../app/scripts/controllers/metric.js | 0 .../app/scripts/controllers/system.js | 0 .../app/scripts/directives/header/header.html | 0 .../app/scripts/directives/header/header.js | 0 .../sidebar-search/sidebar-search.html | 0 .../sidebar/sidebar-search/sidebar-search.js | 0 .../scripts/directives/sidebar/sidebar.html | 0 .../app/scripts/directives/sidebar/sidebar.js | 0 .../resources/app/scripts/filters/filters.js | 0 .../resources/app/scripts/libs/treeTable.js | 0 .../app/scripts/services/appservice.js | 0 .../app/scripts/services/degrade_service.js | 0 .../app/scripts/services/flow_service_v1.js | 0 .../app/scripts/services/flow_service_v2.js | 0 .../app/scripts/services/identityservice.js | 0 .../app/scripts/services/machineservice.js | 0 .../app/scripts/services/metricservice.js | 0 .../app/scripts/services/systemservice.js | 0 .../main/webapp/resources/app/styles/main.css | 0 .../main/webapp/resources/app/styles/page.css | 0 .../webapp/resources/app/styles/timeline.css | 0 .../app/views/cluster_single_config.html | 0 .../resources/app/views/dashboard/home.html | 0 .../resources/app/views/dashboard/main.html | 0 .../webapp/resources/app/views/degrade.html | 0 .../cluster/cluster-client-config-dialog.html | 0 .../app/views/dialog/confirm-dialog.html | 0 .../app/views/dialog/degrade-rule-dialog.html | 0 .../app/views/dialog/flow-rule-dialog.html | 0 .../app/views/dialog/system-rule-dialog.html | 0 .../webapp/resources/app/views/flow_v1.html | 0 .../webapp/resources/app/views/flow_v2.html | 0 .../webapp/resources/app/views/identity.html | 0 .../webapp/resources/app/views/machine.html | 0 .../webapp/resources/app/views/metric.html | 0 .../resources/app/views/pagination.tpl.html | 0 .../webapp/resources/app/views/system.html | 0 .../main/webapp/resources/dist/css/app.css | 0 .../src/main/webapp/resources/dist/js/app.js | 0 .../webapp/resources/dist/js/app.vendor.js | 0 .../src/main/webapp/resources/gulpfile.js | 0 .../src/main/webapp/resources/index.htm | 2 + .../src/main/webapp/resources/index_dev.htm | 2 + .../main/webapp/resources/license-stat.csv | 0 .../src/main/webapp/resources/package.json | 0 128 files changed, 833 insertions(+), 461 deletions(-) create mode 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultAuthorizationInterceptor.java create mode 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java create mode 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthConfiguration.java create mode 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthProperties.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricPositionEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineDiscovery.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/Result.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.gitignore mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.jshintrc mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/README.md mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v1.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v2.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/home.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/machine.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/main.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/filters/filters.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/libs/treeTable.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/appservice.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degrade_service.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v1.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v2.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/identityservice.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/machineservice.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/metricservice.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/main.css mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/page.css mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/timeline.css mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_single_config.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/home.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/main.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/degrade.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-client-config-dialog.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/confirm-dialog.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/degrade-rule-dialog.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v1.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v2.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/identity.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/machine.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/metric.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/pagination.tpl.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/system.html mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/css/app.css mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/js/app.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/js/app.vendor.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/gulpfile.js mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/license-stat.csv mode change 100755 => 100644 pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/package.json diff --git a/pig-common/pig-common-bom/pom.xml b/pig-common/pig-common-bom/pom.xml index 3db04c37..7e1f5868 100644 --- a/pig-common/pig-common-bom/pom.xml +++ b/pig-common/pig-common-bom/pom.xml @@ -30,9 +30,10 @@ 1.4.2 1.1.1 7.1 - 1.0.3 + 1.0.4 2.0.2 2.3.5 + 1.8.4 @@ -197,6 +198,41 @@ pom import + + com.alibaba.csp + sentinel-core + ${sentinel.version} + pom + import + + + com.alibaba.csp + sentinel-web-servlet + ${sentinel.version} + pom + import + + + com.alibaba.csp + sentinel-transport-simple-http + ${sentinel.version} + pom + import + + + com.alibaba.csp + sentinel-parameter-flow-control + ${sentinel.version} + pom + import + + + com.alibaba.csp + sentinel-api-gateway-adapter-common + ${sentinel.version} + pom + import + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java index 0976bf10..9b3130e2 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthAction.java @@ -15,10 +15,14 @@ */ package com.alibaba.csp.sentinel.dashboard.auth; -import java.lang.annotation.*; +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; /** - * @author lkxiaolou + * @author lkxiaolou 无改动 * @since 1.7.1 */ @Retention(RetentionPolicy.RUNTIME) diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java index 2c60d8ff..fe7ee7f8 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthService.java @@ -16,7 +16,7 @@ package com.alibaba.csp.sentinel.dashboard.auth; /** - * Interface for authentication and authorization. + * Interface for authentication and authorization. 不需要改 * * @author Carpenter Lee * @since 1.5.0 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java index 816f9d85..b527ce7c 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/AuthorizationInterceptor.java @@ -15,59 +15,15 @@ */ package com.alibaba.csp.sentinel.dashboard.auth; -import com.alibaba.csp.sentinel.dashboard.domain.Result; -import com.alibaba.fastjson.JSON; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.lang.reflect.Method; - /** - * The web interceptor for privilege-based authorization. + * The web interceptor for privilege-based authorization. 不需要改 * * @author lkxiaolou + * @author wxq * @since 1.7.1 */ -@Component -public class AuthorizationInterceptor implements HandlerInterceptor { - - @Autowired - private AuthService authService; - - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) - throws Exception { - if (handler.getClass().isAssignableFrom(HandlerMethod.class)) { - Method method = ((HandlerMethod) handler).getMethod(); - - AuthAction authAction = method.getAnnotation(AuthAction.class); - if (authAction != null) { - AuthService.AuthUser authUser = authService.getAuthUser(request); - if (authUser == null) { - responseNoPrivilegeMsg(response, authAction.message()); - return false; - } - String target = request.getParameter(authAction.targetName()); - - if (!authUser.authTarget(target, authAction.value())) { - responseNoPrivilegeMsg(response, authAction.message()); - return false; - } - } - } - - return true; - } - - private void responseNoPrivilegeMsg(HttpServletResponse response, String message) throws IOException { - Result result = Result.ofFail(-1, message); - response.addHeader("Content-Type", "application/json;charset=UTF-8"); - response.getOutputStream().write(JSON.toJSONBytes(result)); - } +public interface AuthorizationInterceptor extends HandlerInterceptor { } diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultAuthorizationInterceptor.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultAuthorizationInterceptor.java new file mode 100644 index 00000000..56c537c0 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultAuthorizationInterceptor.java @@ -0,0 +1,75 @@ +/* + * 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.auth; + +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.fastjson.JSON; +import org.springframework.web.method.HandlerMethod; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.lang.reflect.Method; + +/** + * The web interceptor for privilege-based authorization. 不需要 + *

+ * move from old {@link AuthorizationInterceptor}. + * + * @author lkxiaolou + * @author wxq + * @since 1.7.1 + */ +public class DefaultAuthorizationInterceptor implements AuthorizationInterceptor { + + private final AuthService authService; + + public DefaultAuthorizationInterceptor(AuthService authService) { + this.authService = authService; + } + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + if (handler.getClass().isAssignableFrom(HandlerMethod.class)) { + Method method = ((HandlerMethod) handler).getMethod(); + + AuthAction authAction = method.getAnnotation(AuthAction.class); + if (authAction != null) { + AuthService.AuthUser authUser = authService.getAuthUser(request); + if (authUser == null) { + responseNoPrivilegeMsg(response, authAction.message()); + return false; + } + String target = request.getParameter(authAction.targetName()); + + if (!authUser.authTarget(target, authAction.value())) { + responseNoPrivilegeMsg(response, authAction.message()); + return false; + } + } + } + + return true; + } + + private void responseNoPrivilegeMsg(HttpServletResponse response, String message) throws IOException { + Result result = Result.ofFail(-1, message); + response.addHeader("Content-Type", "application/json;charset=UTF-8"); + response.getOutputStream().write(JSON.toJSONBytes(result)); + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java new file mode 100644 index 00000000..4a08e7cd --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/DefaultLoginAuthenticationFilter.java @@ -0,0 +1,132 @@ +/* + * 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.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; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +/** + *

+ * The Servlet filter for authentication. + *

+ * + *

+ * Note: some urls are excluded as they needn't auth, such as: + *

+ * + *

+ * The excluded urls and urlSuffixes could be configured in {@code application.properties} + * file. + * + * @author cdfive 不需要 + * @since 1.6.0 + */ +public class DefaultLoginAuthenticationFilter implements LoginAuthenticationFilter { + + private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher(); + + private static final String URL_SUFFIX_DOT = "."; + + /** + * 忽略鉴权的url + */ + @Value("#{'${auth.filter.exclude-urls}'.split(',')}") + private List authFilterExcludeUrls; + + /** + * 根据后缀不需要鉴权的url + */ + @Value("#{'${auth.filter.exclude-url-suffixes}'.split(',')}") + private List authFilterExcludeUrlSuffixes; + + /** + * Authentication using AuthService interface. + */ + private final AuthService authService; + + public DefaultLoginAuthenticationFilter(AuthService authService) { + this.authService = authService; + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + HttpServletRequest httpRequest = (HttpServletRequest) request; + + String servletPath = httpRequest.getServletPath(); + + // Exclude the urls which needn't auth + boolean authFilterExcludeMatch = authFilterExcludeUrls.stream() + .anyMatch(authFilterExcludeUrl -> PATH_MATCHER.match(authFilterExcludeUrl, servletPath)); + if (authFilterExcludeMatch) { + chain.doFilter(request, response); + return; + } + + // Exclude the urls with suffixes which needn't auth + for (String authFilterExcludeUrlSuffix : authFilterExcludeUrlSuffixes) { + if (StringUtils.isBlank(authFilterExcludeUrlSuffix)) { + continue; + } + + // Add . for url suffix so that we needn't add . in property file + if (!authFilterExcludeUrlSuffix.startsWith(URL_SUFFIX_DOT)) { + authFilterExcludeUrlSuffix = URL_SUFFIX_DOT + authFilterExcludeUrlSuffix; + } + + if (servletPath.endsWith(authFilterExcludeUrlSuffix)) { + chain.doFilter(request, response); + return; + } + } + + AuthService.AuthUser authUser = authService.getAuthUser(httpRequest); + + HttpServletResponse httpResponse = (HttpServletResponse) response; + if (authUser == null) { + // If auth fail, set response status code to 401 + httpResponse.setStatus(HttpStatus.UNAUTHORIZED.value()); + } + else { + chain.doFilter(request, response); + } + } + + @Override + public void destroy() { + + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java index 979ee565..73c568e1 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/FakeAuthServiceImpl.java @@ -15,7 +15,8 @@ */ package com.alibaba.csp.sentinel.dashboard.auth; -import org.springframework.stereotype.Component; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; @@ -25,9 +26,14 @@ import javax.servlet.http.HttpServletRequest; * @author Carpenter Lee * @since 1.5.0 */ -@Component public class FakeAuthServiceImpl implements AuthService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + public FakeAuthServiceImpl() { + this.logger.warn("there is no auth, use {} by implementation {}", AuthService.class, this.getClass()); + } + @Override public AuthUser getAuthUser(HttpServletRequest request) { return new AuthUserImpl(); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java index 1b63873d..b44f1119 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/LoginAuthenticationFilter.java @@ -15,18 +15,7 @@ */ 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.stereotype.Component; -import org.springframework.util.AntPathMatcher; - -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; +import javax.servlet.Filter; /** *

@@ -42,92 +31,14 @@ import java.util.List; *

  • machine registry: {@code /registry/machine}
  • *
  • static resources
  • * - * + *

    * The excluded urls and urlSuffixes could be configured in {@code application.properties} * file. * - * @author cdfive + * @author cdfive 不需要 + * @author wxq * @since 1.6.0 */ -@Component -public class LoginAuthenticationFilter implements Filter { - - private static final String URL_SUFFIX_DOT = "."; - - private static final AntPathMatcher PATH_MATCHER = new AntPathMatcher(); - - /** - * Some urls which needn't auth, such as /auth/login, /registry/machine and so on. - */ - @Value("#{'${auth.filter.exclude-urls}'.split(',')}") - private List authFilterExcludeUrls; - - /** - * Some urls with suffixes which needn't auth, such as htm, html, js and so on. - */ - @Value("#{'${auth.filter.exclude-url-suffixes}'.split(',')}") - private List authFilterExcludeUrlSuffixes; - - /** - * Authentication using AuthService interface. - */ - @Autowired - private AuthService authService; - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException { - HttpServletRequest httpRequest = (HttpServletRequest) request; - - String servletPath = httpRequest.getServletPath(); - - // Exclude the urls which needn't auth - if (authFilterExcludeUrls.stream().anyMatch(s -> PATH_MATCHER.match(s, servletPath))) { - chain.doFilter(request, response); - return; - } - if (authFilterExcludeUrls.contains(servletPath)) { - chain.doFilter(request, response); - return; - } - - // Exclude the urls with suffixes which needn't auth - for (String authFilterExcludeUrlSuffix : authFilterExcludeUrlSuffixes) { - if (StringUtils.isBlank(authFilterExcludeUrlSuffix)) { - continue; - } - - // Add . for url suffix so that we needn't add . in property file - if (!authFilterExcludeUrlSuffix.startsWith(URL_SUFFIX_DOT)) { - authFilterExcludeUrlSuffix = URL_SUFFIX_DOT + authFilterExcludeUrlSuffix; - } - - if (servletPath.endsWith(authFilterExcludeUrlSuffix)) { - chain.doFilter(request, response); - return; - } - } - - AuthService.AuthUser authUser = authService.getAuthUser(httpRequest); - - HttpServletResponse httpResponse = (HttpServletResponse) response; - if (authUser == null) { - // If auth fail, set response status code to 401 - httpResponse.setStatus(HttpStatus.UNAUTHORIZED.value()); - } - else { - chain.doFilter(request, response); - } - } - - @Override - public void destroy() { - - } +public interface LoginAuthenticationFilter extends Filter { } diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java index bf85b49e..6bcfb354 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/auth/SimpleWebAuthServiceImpl.java @@ -15,20 +15,13 @@ */ package com.alibaba.csp.sentinel.dashboard.auth; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; /** - * @author cdfive + * @author cdfive 不需要 * @since 1.6.0 */ -@Component -@Primary -@ConditionalOnProperty(name = "auth.enabled", matchIfMissing = true) public class SimpleWebAuthServiceImpl implements AuthService { public static final String WEB_SESSION_KEY = "session_sentinel_admin"; diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java old mode 100755 new mode 100644 index ac6885ae..f388681b --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/client/SentinelApiClient.java @@ -15,23 +15,28 @@ */ package com.alibaba.csp.sentinel.dashboard.client; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; + import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule; import com.alibaba.csp.sentinel.command.CommandConstants; -import com.alibaba.csp.sentinel.command.vo.NodeVo; import com.alibaba.csp.sentinel.config.SentinelConfig; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.command.vo.NodeVo; import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.ApiDefinitionEntity; import com.alibaba.csp.sentinel.dashboard.datasource.entity.gateway.GatewayFlowRuleEntity; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.*; -import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterClientInfoVO; -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.state.ClusterServerStateVO; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterStateSimpleEntity; import com.alibaba.csp.sentinel.dashboard.util.AsyncUtils; -import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; import com.alibaba.csp.sentinel.slots.block.Rule; import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule; import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; @@ -41,6 +46,22 @@ import com.alibaba.csp.sentinel.slots.system.SystemRule; import com.alibaba.csp.sentinel.util.AssertUtil; import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.RuleEntity; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterClientInfoVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterServerStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterStateSimpleEntity; +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.util.VersionUtils; + import org.apache.http.Consts; import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; @@ -63,15 +84,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.nio.charset.Charset; -import java.util.*; -import java.util.Map.Entry; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; - /** * Communicate with Sentinel client. * @@ -171,8 +183,8 @@ public class SentinelApiClient { } /** - * Check wheter target instance (identified by tuple of app-ip:port) supports the form - * of "xxxxx; xx=xx" in "Content-Type" header. + * Check whether target instance (identified by tuple of app-ip:port) supports the + * form of "xxxxx; xx=xx" in "Content-Type" header. * @param app target app name * @param ip target node's address * @param port target node's port @@ -520,7 +532,7 @@ public class SentinelApiClient { AssertUtil.notEmpty(ip, "Bad machine IP"); AssertUtil.isTrue(port > 0, "Bad machine port"); return fetchItemsAsync(ip, port, GET_PARAM_RULE_PATH, null, ParamFlowRule.class) - .thenApply(rules -> rules.stream().map(e -> ParamFlowRuleEntity.fromAuthorityRule(app, ip, port, e)) + .thenApply(rules -> rules.stream().map(e -> ParamFlowRuleEntity.fromParamFlowRule(app, ip, port, e)) .collect(Collectors.toList())); } catch (Exception e) { diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthConfiguration.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthConfiguration.java new file mode 100644 index 00000000..63ad89a2 --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthConfiguration.java @@ -0,0 +1,59 @@ +/* + * 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.config; + +import com.alibaba.csp.sentinel.dashboard.auth.*; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.http.HttpServletRequest; + +@Configuration +@EnableConfigurationProperties(AuthProperties.class) +public class AuthConfiguration { + + private final AuthProperties authProperties; + + public AuthConfiguration(AuthProperties authProperties) { + this.authProperties = authProperties; + } + + @Bean + @ConditionalOnMissingBean + public AuthService httpServletRequestAuthService() { + if (this.authProperties.isEnabled()) { + return new SimpleWebAuthServiceImpl(); + } + return new FakeAuthServiceImpl(); + } + + @Bean + @ConditionalOnMissingBean + public LoginAuthenticationFilter loginAuthenticationFilter( + AuthService httpServletRequestAuthService) { + return new DefaultLoginAuthenticationFilter(httpServletRequestAuthService); + } + + @Bean + @ConditionalOnMissingBean + public AuthorizationInterceptor authorizationInterceptor( + AuthService httpServletRequestAuthService) { + return new DefaultAuthorizationInterceptor(httpServletRequestAuthService); + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthProperties.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthProperties.java new file mode 100644 index 00000000..961a857c --- /dev/null +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/AuthProperties.java @@ -0,0 +1,33 @@ +/* + * 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.config; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "auth") +public class AuthProperties { + + private boolean enabled = true; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + +} diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java index 1684e5f2..d8040976 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/DashboardConfig.java +++ b/pig-visual/pig-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. diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java old mode 100755 new mode 100644 index 7f886ad4..7a1256d0 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/WebConfig.java @@ -15,11 +15,16 @@ */ 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; @@ -33,14 +38,11 @@ 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 */ -@Configuration(proxyBeanMethods = false) +@Configuration public class WebConfig implements WebMvcConfigurer { private final Logger logger = LoggerFactory.getLogger(WebConfig.class); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java old mode 100755 new mode 100644 index b372453b..aa99b366 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AppController.java @@ -15,19 +15,24 @@ */ 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.*; - -import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +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; /** * @author Carpenter Lee diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java index 1d14a88d..ddffaa70 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/AuthorityRuleController.java @@ -15,22 +15,32 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; +import java.util.Date; +import java.util.List; + import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; -import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; -import com.alibaba.csp.sentinel.dashboard.domain.Result; -import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; import com.alibaba.csp.sentinel.slots.block.RuleConstant; import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.Date; -import java.util.List; +import org.springframework.web.bind.annotation.DeleteMapping; +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.PutMapping; +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; /** * @author Eric Zhao diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java old mode 100755 new mode 100644 index 3c0cc843..6a23ea93 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DegradeController.java @@ -15,23 +15,32 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; +import java.util.Date; +import java.util.List; + import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; -import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; -import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; import com.alibaba.csp.sentinel.slots.block.RuleConstant; import com.alibaba.csp.sentinel.slots.block.degrade.circuitbreaker.CircuitBreakerStrategy; import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; +import com.alibaba.csp.sentinel.dashboard.domain.Result; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.Date; -import java.util.List; +import org.springframework.web.bind.annotation.DeleteMapping; +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.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * Controller regarding APIs of degrade rules. Refactored since 1.8.0. diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java old mode 100755 new mode 100644 index 0a620738..ae61723e --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/DemoController.java @@ -15,11 +15,9 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -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; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; @@ -27,8 +25,11 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -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; @Controller @RequestMapping(value = "/demo", produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java old mode 100755 new mode 100644 index 47d8d1c0..9f4594c9 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/FlowControllerV1.java @@ -15,25 +15,34 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; -import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; -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.MachineInfo; -import com.alibaba.csp.sentinel.dashboard.domain.Result; -import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; -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.*; - import java.util.Date; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.util.StringUtil; + +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.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +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; + /** * Flow rule controller. * diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java old mode 100755 new mode 100644 index 887659bb..6e293271 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MachineRegistryController.java @@ -16,10 +16,11 @@ package com.alibaba.csp.sentinel.dashboard.controller; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; -import com.alibaba.csp.sentinel.dashboard.discovery.MachineDiscovery; +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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +29,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import sun.net.util.IPAddressUtil; @Controller @RequestMapping(value = "/registry", produces = MediaType.APPLICATION_JSON_VALUE) @@ -43,20 +45,27 @@ public class MachineRegistryController { public Result receiveHeartBeat(String app, @RequestParam(value = "app_type", required = false, defaultValue = "0") Integer appType, Long version, String v, String hostname, String ip, Integer port) { - if (app == null) { - app = MachineDiscovery.UNKNOWN_APP_NAME; + if (StringUtil.isBlank(app) || app.length() > 256) { + return Result.ofFail(-1, "invalid appName"); } - if (ip == null) { - return Result.ofFail(-1, "ip can't be null"); + if (StringUtil.isBlank(ip) || ip.length() > 128) { + return Result.ofFail(-1, "invalid ip: " + ip); } - if (port == null) { - return Result.ofFail(-1, "port can't be null"); + if (!IPAddressUtil.isIPv4LiteralAddress(ip) && !IPAddressUtil.isIPv6LiteralAddress(ip)) { + return Result.ofFail(-1, "invalid ip: " + ip); + } + if (port == null || port < -1) { + return Result.ofFail(-1, "invalid port"); + } + if (hostname != null && hostname.length() > 256) { + return Result.ofFail(-1, "hostname too long"); } if (port == -1) { - logger.info("Receive heartbeat from " + ip + " but port not set yet"); + logger.warn("Receive heartbeat from " + ip + " but port not set yet"); return Result.ofFail(-1, "your port not set yet"); } - String sentinelVersion = StringUtil.isEmpty(v) ? "unknown" : v; + String sentinelVersion = StringUtil.isBlank(v) ? "unknown" : v; + version = version == null ? System.currentTimeMillis() : version; try { MachineInfo machineInfo = new MachineInfo(); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java old mode 100755 new mode 100644 index 18e6ecdb..32e6e962 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/MetricController.java @@ -15,11 +15,17 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.MetricEntity; +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.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; @@ -28,8 +34,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; +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; /** * @author leyou diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java index 4134d424..560c4664 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ParamFlowRuleController.java @@ -15,31 +15,40 @@ */ 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; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; -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.repository.rule.RuleRepository; -import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; -import com.alibaba.csp.sentinel.slots.block.RuleConstant; -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.*; - import java.util.Date; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; +import com.alibaba.csp.sentinel.dashboard.client.CommandNotFoundException; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService; +import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; +import com.alibaba.csp.sentinel.slots.block.RuleConstant; +import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.ParamFlowRuleEntity; +import com.alibaba.csp.sentinel.dashboard.domain.Result; +import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; +import com.alibaba.csp.sentinel.dashboard.util.VersionUtils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +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.PutMapping; +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; + /** * @author Eric Zhao * @since 0.2.1 @@ -111,7 +120,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) { @@ -183,7 +192,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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java old mode 100755 new mode 100644 index ad9148c6..da8988e3 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/ResourceController.java @@ -15,12 +15,17 @@ */ 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.client.SentinelApiClient; + import com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; 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; @@ -28,9 +33,6 @@ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java old mode 100755 new mode 100644 index 58323f02..ac23dea5 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SystemController.java @@ -15,14 +15,19 @@ */ package com.alibaba.csp.sentinel.dashboard.controller; +import java.util.Date; +import java.util.List; + import com.alibaba.csp.sentinel.dashboard.auth.AuthAction; import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType; -import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; -import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; -import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.repository.rule.RuleRepository; import com.alibaba.csp.sentinel.util.StringUtil; + +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; +import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient; +import com.alibaba.csp.sentinel.dashboard.domain.Result; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -30,9 +35,6 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; -import java.util.List; - /** * @author leyou(lihao) */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java index ada7f51d..892a9eeb 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/VersionController.java @@ -17,6 +17,7 @@ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java index 42c306f8..6b43aa04 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterAssignController.java @@ -15,19 +15,24 @@ */ package com.alibaba.csp.sentinel.dashboard.controller.cluster; -import com.alibaba.csp.sentinel.dashboard.domain.Result; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; +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.cluster.ClusterAppAssignResultVO; import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppSingleServerAssignRequest; import com.alibaba.csp.sentinel.dashboard.service.ClusterAssignService; -import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.csp.sentinel.dashboard.domain.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.Collections; -import java.util.Set; +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; /** * @author Eric Zhao diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java index f55dae83..96b94963 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/cluster/ClusterConfigController.java @@ -15,11 +15,18 @@ */ 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.datasource.entity.SentinelVersion; import com.alibaba.csp.sentinel.dashboard.discovery.AppManagement; -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 com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; 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; @@ -30,17 +37,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.util.StringUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.csp.sentinel.dashboard.domain.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ExecutionException; +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; /** * @author Eric Zhao diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java index 016d4f39..0638982c 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/gateway/GatewayFlowRuleController.java @@ -36,9 +36,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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java old mode 100755 new mode 100644 index c655071d..6df62602 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/v2/FlowControllerV2.java @@ -15,23 +15,33 @@ */ package com.alibaba.csp.sentinel.dashboard.controller.v2; +import java.util.Date; +import java.util.List; + 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.util.StringUtil; + import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.FlowRuleEntity; -import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.repository.rule.InMemoryRuleRepositoryAdapter; import com.alibaba.csp.sentinel.dashboard.rule.DynamicRuleProvider; import com.alibaba.csp.sentinel.dashboard.rule.DynamicRulePublisher; -import com.alibaba.csp.sentinel.util.StringUtil; +import com.alibaba.csp.sentinel.dashboard.domain.Result; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.web.bind.annotation.*; - -import java.util.Date; -import java.util.List; +import org.springframework.web.bind.annotation.DeleteMapping; +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.PutMapping; +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; /** * Flow rule controller (v2). @@ -127,7 +137,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); @@ -152,7 +162,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) { if (id == null || id <= 0) { diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java old mode 100755 new mode 100644 index 953c7849..cebe93ce --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/ApplicationEntity.java @@ -15,10 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity; -import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; - import java.util.Date; +import com.alibaba.csp.sentinel.dashboard.discovery.AppInfo; + /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java old mode 100755 new mode 100644 index 79d8a7ff..037be22d --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MachineEntity.java @@ -15,10 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity; -import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; - import java.util.Date; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricEntity.java old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricPositionEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/MetricPositionEntity.java old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java index 43fb72f7..9e5213b3 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/AbstractRuleEntity.java @@ -15,10 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; -import com.alibaba.csp.sentinel.slots.block.AbstractRule; - import java.util.Date; +import com.alibaba.csp.sentinel.slots.block.AbstractRule; +import com.alibaba.csp.sentinel.slots.block.Rule; + /** * @author Eric Zhao * @since 0.2.1 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java old mode 100755 new mode 100644 index 4804f0e2..1be3746d --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/DegradeRuleEntity.java @@ -15,10 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; -import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; - import java.util.Date; +import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule; + /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java old mode 100755 new mode 100644 index c83cb8ce..e7b4e738 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/FlowRuleEntity.java @@ -15,11 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; +import java.util.Date; + import com.alibaba.csp.sentinel.slots.block.flow.ClusterFlowConfig; import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; -import java.util.Date; - /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java index b5a2977d..c90ef913 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/ParamFlowRuleEntity.java @@ -38,7 +38,7 @@ public class ParamFlowRuleEntity extends AbstractRuleEntity { this.rule = rule; } - public static ParamFlowRuleEntity fromAuthorityRule(String app, String ip, Integer port, ParamFlowRule rule) { + public static ParamFlowRuleEntity fromParamFlowRule(String app, String ip, Integer port, ParamFlowRule rule) { ParamFlowRuleEntity entity = new ParamFlowRuleEntity(rule); entity.setApp(app); entity.setIp(ip); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java old mode 100755 new mode 100644 index 52d7e0f6..40ac6a0e --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/RuleEntity.java @@ -15,10 +15,10 @@ */ package com.alibaba.csp.sentinel.dashboard.datasource.entity.rule; -import com.alibaba.csp.sentinel.slots.block.Rule; - import java.util.Date; +import com.alibaba.csp.sentinel.slots.block.Rule; + /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/datasource/entity/rule/SystemRuleEntity.java old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java old mode 100755 new mode 100644 index 463412c8..3c69fd8b --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppInfo.java @@ -15,11 +15,15 @@ */ package com.alibaba.csp.sentinel.dashboard.discovery; -import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; - -import java.util.*; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Optional; +import java.util.Iterator; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import com.alibaba.csp.sentinel.dashboard.config.DashboardConfig; + public class AppInfo { private String app = ""; diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java old mode 100755 new mode 100644 index 7733a516..79f4ad24 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/AppManagement.java @@ -15,14 +15,15 @@ */ package com.alibaba.csp.sentinel.dashboard.discovery; +import java.util.List; +import java.util.Set; + +import javax.annotation.PostConstruct; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; -import java.util.List; -import java.util.Set; - @Component public class AppManagement implements MachineDiscovery { diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineDiscovery.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineDiscovery.java old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java old mode 100755 new mode 100644 index 2b4a080b..8d390180 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/MachineInfo.java +++ b/pig-visual/pig-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 = ""; diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java old mode 100755 new mode 100644 index 5d06c5f9..f437358c --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/discovery/SimpleMachineDiscovery.java @@ -15,9 +15,6 @@ */ 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; @@ -25,6 +22,10 @@ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java old mode 100755 new mode 100644 index bb6dead7..eb289c81 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/ResourceTreeNode.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/Result.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/Result.java old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java index 2e096080..629f0566 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppFullAssignRequest.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java index 3b5b2ac9..63aa1c35 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/ClusterAppSingleServerAssignRequest.java +++ b/pig-visual/pig-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 com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; - import java.util.Set; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; + /** * @author Eric Zhao * @since 1.4.1 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java index 02c96c27..216ab8fa 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/request/ClusterServerModifyRequest.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java index dbd61607..1eabe4e3 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/cluster/state/ClusterServerStateVO.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java old mode 100755 new mode 100644 index 65a7fd95..8378198a --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MachineInfoVo.java +++ b/pig-visual/pig-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 */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java old mode 100755 new mode 100644 index cdd5040e..68211955 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/MetricVo.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java old mode 100755 new mode 100644 index 4fd4c2c0..512c3486 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/ResourceVo.java @@ -15,12 +15,13 @@ */ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java index a11cd7c1..52300d95 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/domain/vo/gateway/api/ApiPredicateItemVo.java @@ -23,8 +23,21 @@ package com.alibaba.csp.sentinel.dashboard.domain.vo.gateway.api; */ public class ApiPredicateItemVo { + /** + * The pattern for matching url. + */ private String pattern; + /** + * The matching Strategy in url. Constants are defined in class + * SentinelGatewayConstants.\ + * + *

    + */ private Integer matchStrategy; public String getPattern() { diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java old mode 100755 new mode 100644 index 8adb2309..768f303d --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/metric/MetricFetcher.java @@ -15,6 +15,26 @@ */ 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; @@ -22,9 +42,10 @@ 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; @@ -40,14 +61,6 @@ 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. * @@ -84,7 +97,7 @@ public class MetricFetcher { @SuppressWarnings("PMD.ThreadPoolCreationRule") private ScheduledExecutorService fetchScheduleService = Executors.newScheduledThreadPool(1, - new NamedThreadFactory("sentinel-dashboard-metrics-fetch-task")); + new NamedThreadFactory("sentinel-dashboard-metrics-fetch-task", true)); private ExecutorService fetchService; @@ -96,11 +109,11 @@ public class MetricFetcher { int queueSize = 2048; RejectedExecutionHandler handler = new DiscardPolicy(); fetchService = new ThreadPoolExecutor(cores, cores, keepAliveTime, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue<>(queueSize), new NamedThreadFactory("sentinel-dashboard-metrics-fetchService"), - handler); + new ArrayBlockingQueue<>(queueSize), + new NamedThreadFactory("sentinel-dashboard-metrics-fetchService", true), handler); fetchWorker = new ThreadPoolExecutor(cores, cores, keepAliveTime, TimeUnit.MILLISECONDS, - new ArrayBlockingQueue<>(queueSize), new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker"), - handler); + new ArrayBlockingQueue<>(queueSize), + new NamedThreadFactory("sentinel-dashboard-metrics-fetchWorker", true), handler); IOReactorConfig ioConfig = IOReactorConfig.custom().setConnectTimeout(3000).setSoTimeout(3000) .setIoThreadCount(Runtime.getRuntime().availableProcessors() * 2).build(); @@ -249,7 +262,7 @@ public class MetricFetcher { catch (Exception e) { logger.info(msg + " metric, wait http client error:", e); } - long cost = System.currentTimeMillis() - start; + // long cost = System.currentTimeMillis() - start; // logger.info("finished " + msg + " metric for " + app + ", time intervalMs [" + // startTime + ", " + endTime // + "], total machines=" + machines.size() + ", dead=" + dead + ", fetch @@ -268,7 +281,7 @@ public class MetricFetcher { lastFetchMs = lastFetchMs / 1000 * 1000; long endTime = lastFetchMs + FETCH_INTERVAL_SECOND * 1000; if (endTime > now - 1000 * 2) { - // to near + // too near return; } // update last_fetch in advance. @@ -336,26 +349,24 @@ public class MetricFetcher { * aggregation metrics by app_resource_timeSecond, ignore ip and port. */ String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp()); - MetricEntity entity = map.get(key); - if (entity != null) { - entity.addPassQps(node.getPassQps()); - entity.addBlockQps(node.getBlockQps()); - entity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps()); - entity.addExceptionQps(node.getExceptionQps()); - entity.addCount(1); - } - else { - entity = new MetricEntity(); - entity.setApp(machine.getApp()); - entity.setTimestamp(new Date(node.getTimestamp())); - entity.setPassQps(node.getPassQps()); - entity.setBlockQps(node.getBlockQps()); - entity.setRtAndSuccessQps(node.getRt(), node.getSuccessQps()); - entity.setExceptionQps(node.getExceptionQps()); - entity.setCount(1); - entity.setResource(node.getResource()); - map.put(key, entity); - } + + MetricEntity metricEntity = map.computeIfAbsent(key, s -> { + MetricEntity initMetricEntity = new MetricEntity(); + initMetricEntity.setApp(machine.getApp()); + initMetricEntity.setTimestamp(new Date(node.getTimestamp())); + initMetricEntity.setPassQps(0L); + initMetricEntity.setBlockQps(0L); + initMetricEntity.setRtAndSuccessQps(0, 0L); + initMetricEntity.setExceptionQps(0L); + initMetricEntity.setCount(0); + initMetricEntity.setResource(node.getResource()); + return initMetricEntity; + }); + metricEntity.addPassQps(node.getPassQps()); + metricEntity.addBlockQps(node.getBlockQps()); + metricEntity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps()); + metricEntity.addExceptionQps(node.getExceptionQps()); + metricEntity.addCount(1); } catch (Exception e) { logger.warn("handleBody line exception, machine: {}, line: {}", machine.toLogString(), line); diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java index 684ffc2c..c6eb22fd 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java @@ -20,7 +20,11 @@ import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.TimeUtil; import org.springframework.stereotype.Component; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantReadWriteLock; diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java index 422e0e61..176577e4 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemAuthorityRuleStore.java @@ -15,11 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; -import org.springframework.stereotype.Component; - import java.util.concurrent.atomic.AtomicLong; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.AuthorityRuleEntity; + +import org.springframework.stereotype.Component; + /** * In-memory storage for authority rules. * diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java old mode 100755 new mode 100644 index 7891924d..84ef0896 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemDegradeRuleStore.java @@ -15,11 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; -import org.springframework.stereotype.Component; - import java.util.concurrent.atomic.AtomicLong; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.DegradeRuleEntity; + +import org.springframework.stereotype.Component; + /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java old mode 100755 new mode 100644 index c54fdb2d..2010b65f --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemFlowRuleStore.java @@ -15,11 +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; +import org.springframework.stereotype.Component; /** * Store {@link FlowRuleEntity} in memory. diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java index 6ca20401..bf764d19 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemParamFlowRuleStore.java @@ -15,11 +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; +import org.springframework.stereotype.Component; /** * @author Eric Zhao diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java old mode 100755 new mode 100644 index 7a4e9433..a97b6e9a --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemSystemRuleStore.java @@ -15,11 +15,12 @@ */ package com.alibaba.csp.sentinel.dashboard.repository.rule; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; -import org.springframework.stereotype.Component; - import java.util.concurrent.atomic.AtomicLong; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.rule.SystemRuleEntity; + +import org.springframework.stereotype.Component; + /** * @author leyou */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java old mode 100755 new mode 100644 index 2e6e15cf..b97b297e --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java old mode 100755 new mode 100644 index 26f19d42..aa3bc2a2 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/RuleRepository.java +++ b/pig-visual/pig-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 com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; - import java.util.List; +import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; + /** * Interface to store and find rules. * diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java index c5bf9fc8..95e1e810 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiProvider.java @@ -15,18 +15,20 @@ */ package com.alibaba.csp.sentinel.dashboard.rule; -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 org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - 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.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; + /** * @author Eric Zhao */ diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java index a5d8ac83..74987ec1 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/rule/FlowRuleApiPublisher.java @@ -15,17 +15,18 @@ */ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java index 26be98d7..bd9c88aa 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignService.java +++ b/pig-visual/pig-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 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; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterAppAssignResultVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.request.ClusterAppAssignMap; + /** * @author Eric Zhao * @since 1.4.1 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java index 1635e8d6..c9e34fc1 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterAssignServiceImpl.java @@ -15,7 +15,21 @@ */ 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; @@ -23,21 +37,12 @@ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java index d1cf10ff..5ba46ddb 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/service/ClusterConfigService.java @@ -15,31 +15,32 @@ */ 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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java index b7372b27..fdd98b2e 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/AsyncUtils.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java index c43e92d6..5b2b4f70 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java @@ -15,13 +15,23 @@ */ package com.alibaba.csp.sentinel.dashboard.util; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.alibaba.csp.sentinel.cluster.ClusterStateManager; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.ConnectionGroupVO; -import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.*; import com.alibaba.csp.sentinel.util.StringUtil; -import java.util.*; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ClusterGroupEntity; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.ConnectionGroupVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterClientStateWrapVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.AppClusterServerStateWrapVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterClientStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterServerStateVO; +import com.alibaba.csp.sentinel.dashboard.domain.cluster.state.ClusterUniversalStatePairVO; /** * @author Eric Zhao @@ -107,7 +117,8 @@ public final class ClusterEntityUtils { if (mode == ClusterStateManager.CLUSTER_SERVER) { String serverAddress = getIp(ip); int port = stateVO.getState().getServer().getPort(); - map.computeIfAbsent(serverAddress, v -> new ClusterGroupEntity().setBelongToApp(true) + String targetAddress = serverAddress + ":" + port; + map.computeIfAbsent(targetAddress, v -> new ClusterGroupEntity().setBelongToApp(true) .setMachineId(ip + '@' + stateVO.getCommandPort()).setIp(ip).setPort(port)); } } @@ -120,8 +131,8 @@ public final class ClusterEntityUtils { if (StringUtil.isBlank(targetServer) || targetPort == null || targetPort <= 0) { continue; } - - ClusterGroupEntity group = map.computeIfAbsent(targetServer, v -> new ClusterGroupEntity() + String targetAddress = targetServer + ":" + targetPort; + ClusterGroupEntity group = map.computeIfAbsent(targetAddress, v -> new ClusterGroupEntity() .setBelongToApp(true).setMachineId(targetServer).setIp(targetServer).setPort(targetPort)); group.getClientSet().add(ip + '@' + stateVO.getCommandPort()); } diff --git a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java index c124aee0..c21b781d 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/MachineUtils.java +++ b/pig-visual/pig-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/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java index cbc6f9e9..e7524c4f 100644 --- a/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java +++ b/pig-visual/pig-sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/VersionUtils.java @@ -15,10 +15,11 @@ */ package com.alibaba.csp.sentinel.dashboard.util; -import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; +import java.util.Optional; + import com.alibaba.csp.sentinel.util.StringUtil; -import java.util.Optional; +import com.alibaba.csp.sentinel.dashboard.datasource.entity.SentinelVersion; /** * Util class for parsing version. @@ -30,16 +31,16 @@ public final class VersionUtils { /** * Parse version of Sentinel from raw string. - * @param versionFull version string + * @param verStr version string * @return parsed {@link SentinelVersion} if the version is valid; empty if there is * something wrong with the format */ - public static Optional parseVersion(String s) { - if (StringUtil.isBlank(s)) { + public static Optional parseVersion(String verStr) { + if (StringUtil.isBlank(verStr)) { return Optional.empty(); } try { - String versionFull = s; + String versionFull = verStr; SentinelVersion version = new SentinelVersion(); // postfix diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.gitignore b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.gitignore old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.jshintrc b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/.jshintrc old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/README.md b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/README.md old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/app.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/degrade.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v1.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v1.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v2.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/flow_v2.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/home.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/home.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/identity.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/machine.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/machine.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/main.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/main.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/system.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/header/header.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar-search/sidebar-search.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/directives/sidebar/sidebar.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/filters/filters.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/filters/filters.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/libs/treeTable.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/libs/treeTable.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/appservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/appservice.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degrade_service.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/degrade_service.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v1.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v1.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v2.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/flow_service_v2.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/identityservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/identityservice.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/machineservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/machineservice.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/metricservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/metricservice.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/scripts/services/systemservice.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/main.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/main.css old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/page.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/page.css old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/timeline.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/styles/timeline.css old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_single_config.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/cluster_single_config.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/home.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/home.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/main.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dashboard/main.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/degrade.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/degrade.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-client-config-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/cluster/cluster-client-config-dialog.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/confirm-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/confirm-dialog.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/degrade-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/degrade-rule-dialog.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/flow-rule-dialog.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/dialog/system-rule-dialog.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v1.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v1.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v2.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/flow_v2.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/identity.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/identity.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/machine.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/machine.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/metric.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/metric.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/pagination.tpl.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/pagination.tpl.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/system.html b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/app/views/system.html old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/css/app.css b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/css/app.css old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/js/app.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/js/app.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/js/app.vendor.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/dist/js/app.vendor.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/gulpfile.js b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/gulpfile.js old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm old mode 100755 new mode 100644 index 3c833412..24482898 --- a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index.htm @@ -10,6 +10,8 @@ + + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm old mode 100755 new mode 100644 index a2a85efc..51131681 --- a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm +++ b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/index_dev.htm @@ -10,6 +10,8 @@ + + diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/license-stat.csv b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/license-stat.csv old mode 100755 new mode 100644 diff --git a/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/package.json b/pig-visual/pig-sentinel-dashboard/src/main/webapp/resources/package.json old mode 100755 new mode 100644