From b18cdea2e53feff0a5a81ff937b2fd0de6e25be8 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 1 Mar 2019 16:52:52 +0800 Subject: [PATCH] Fixed Dashboard try to access Alipay domain `https://kcart.alipay.com/web/bi.do?` By upgrading G2 Lib to version 3.4.10 https://github.com/alibaba/Sentinel/issues/522 --- sentinel-dashboard/pom.xml | 21 +++++++-- .../dashboard/config/db/DataSourceConfig.java | 38 ---------------- .../config/mybatis/MyBatisConfig.java | 2 +- .../controller/SentinelTestController.java | 41 ++++++++++++++++++ .../sentinel/dashboard/dao/user/UserDao.java | 3 +- .../src/main/resources/application.properties | 43 +++++++++---------- .../src/main/resources/banner.txt | 20 ++++----- .../src/main/resources/bootstrap.yml | 25 ++++++++++- 8 files changed, 114 insertions(+), 79 deletions(-) create mode 100644 sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SentinelTestController.java diff --git a/sentinel-dashboard/pom.xml b/sentinel-dashboard/pom.xml index df8f10c691..0506f74ae8 100755 --- a/sentinel-dashboard/pom.xml +++ b/sentinel-dashboard/pom.xml @@ -48,10 +48,6 @@ - - org.springframework.boot - spring-boot-starter-log4j2 - org.springframework.boot spring-boot-starter-web @@ -90,6 +86,13 @@ mybatis-spring-boot-starter 1.3.1 + + org.springframework.cloud + spring-cloud-dependencies + Camden.SR5 + pom + import + @@ -174,6 +177,8 @@ + + sentinel-dashboard @@ -215,6 +220,14 @@ src/main/resources + + *.txt + *.xml + *.wsdl + reports/* + managerReports/* + mappers/* + diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/db/DataSourceConfig.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/db/DataSourceConfig.java index 20b1eb229d..60209bac0a 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/db/DataSourceConfig.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/db/DataSourceConfig.java @@ -1,19 +1,13 @@ package com.alibaba.csp.sentinel.dashboard.config.db; -import com.alibaba.csp.sentinel.dashboard.util.wuga.Board; -import com.alibaba.csp.sentinel.dashboard.util.wuga.Table; -import com.zaxxer.hikari.HikariConfigMXBean; import com.zaxxer.hikari.HikariDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.sql.DataSource; -import java.util.Arrays; -import java.util.List; /** * Config DataSource @@ -34,41 +28,9 @@ public class DataSourceConfig { * @return DataSource */ @Bean - @ConfigurationProperties(prefix = "hikaricp") public DataSource dataSource() { HikariDataSource build = DataSourceBuilder.create().type(HikariDataSource.class).build(); -// printDataSourceConfig(build); return build; } - /** - * Print Out the Current HikariCP Configuration. - * - * @param build HikariDataSource - */ - private void printDataSourceConfig(HikariDataSource build) { - HikariConfigMXBean hikariConfigMXBean = build.getHikariConfigMXBean(); - - StringBuilder infoTable = new StringBuilder(); - infoTable.append("\n" + "========== START =============== HikariCP-Config =============== START =========="); - - List headersList = Arrays.asList("Name", "Value"); - List> rowsList = Arrays.asList( - Arrays.asList("PoolName", hikariConfigMXBean.getPoolName() + ""), - Arrays.asList("ValidationTimeout", hikariConfigMXBean.getValidationTimeout() + ""), - Arrays.asList("ConnectionTimeout", hikariConfigMXBean.getConnectionTimeout() + ""), - Arrays.asList("IdleTimeout", hikariConfigMXBean.getIdleTimeout() + ""), - Arrays.asList("", ""), - Arrays.asList("LeakDetectionThreshold", hikariConfigMXBean.getLeakDetectionThreshold() + ""), - Arrays.asList("MaximumPoolSize", hikariConfigMXBean.getMaximumPoolSize() + ""), - Arrays.asList("MinimumIdle", hikariConfigMXBean.getMinimumIdle() + ""), - Arrays.asList("MaxLifetime", hikariConfigMXBean.getMaxLifetime() + "") - ); - Board board = new Board(75); - infoTable.append("\n" + board.setInitialBlock(new Table(board, 75, headersList, rowsList).tableToBlocks()).build().getPreview()); - - infoTable.append("=========== END ================ HikariCP-Config ================ END ==========="); - - logger.info(infoTable.toString()); - } } diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/mybatis/MyBatisConfig.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/mybatis/MyBatisConfig.java index 00dd20cced..18628a98ef 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/mybatis/MyBatisConfig.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/config/mybatis/MyBatisConfig.java @@ -24,7 +24,7 @@ **/ @Configuration @EnableTransactionManagement -@MapperScan(value = {"com.alibaba.csp.sentinel.dashboard.dao"}) +//@MapperScan(value = {"com.alibaba.csp.sentinel.dashboard.dao"}) public class MyBatisConfig implements TransactionManagementConfigurer { @Autowired DataSource dataSource; diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SentinelTestController.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SentinelTestController.java new file mode 100644 index 0000000000..8870511638 --- /dev/null +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/controller/SentinelTestController.java @@ -0,0 +1,41 @@ +package com.alibaba.csp.sentinel.dashboard.controller; + +import com.alibaba.csp.sentinel.dashboard.service.user.UserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.Map; + +@SuppressWarnings("CheckStyle") +@Controller +public class SentinelTestController { + + @Autowired + UserService userService; + private static final Logger logger = LoggerFactory.getLogger(SentinelTestController.class); + + @RequestMapping(value = "/cmpp-api/external/sentinelTest") + @ResponseBody + public String acceptOrderV3() throws + InterruptedException { + //0.0-1.0 + int v = (int) (150 + (Math.random()) * (300 - 150)); + Thread.sleep(v); + return "finished"; + } + + @RequestMapping(value = "/Test2") + @ResponseBody + public Map acceptOrderV32() throws + InterruptedException { + Map allAuth = userService.findAllAuth(); + return allAuth; + } +} + + + diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/dao/user/UserDao.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/dao/user/UserDao.java index 6bd3a07778..dd39967f40 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/dao/user/UserDao.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/dao/user/UserDao.java @@ -3,6 +3,7 @@ import com.alibaba.csp.sentinel.dashboard.bean.Roles; import com.alibaba.csp.sentinel.dashboard.bean.User; +import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; @@ -12,7 +13,7 @@ /** * Created by Administrator on 2016/12/5 0005. */ -@Repository +@Mapper public interface UserDao { User findByLoginname(@Param("loginname") String loginname); diff --git a/sentinel-dashboard/src/main/resources/application.properties b/sentinel-dashboard/src/main/resources/application.properties index 6fc345f27f..6ba847da62 100755 --- a/sentinel-dashboard/src/main/resources/application.properties +++ b/sentinel-dashboard/src/main/resources/application.properties @@ -9,27 +9,24 @@ logging.file=${user.home}/logs/csp/sentinel-dashboard.log logging.pattern.console= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n logging.pattern.file= %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n - -###################################jdbc.properties################################## -#HikariCP will attempt to resolve a driver through the DriverManager based solely on the jdbcUrl -#hikaricp.driverClassName=oracle.jdbc.driver.OracleDriver -hikaricp.jdbcUrl=jdbc:mysql://10.250.0.67:3306/ec?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai -hikaricp.username=ec -hikaricp.password=ec123$%^ -hikaricp.connectionTestQuery=SELECT 1 FROM DUAL +spring.datasource.hikari.jdbc-url=jdbc:mysql://10.250.0.67:3306/ec?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai +spring.datasource.hikari.username=ec +spring.datasource.hikari.password=ec123$%^ #Pool Configuration -hikaricp.poolName=CMPP_Develop_Pool -hikaricp.connectionTimeout=60000 -hikaricp.minimumIdle=1 -hikaricp.maximumPoolSize=25 -hikaricp.idleTimeout=6000 -hikaricp.cachePrepStmts=true -hikaricp.prepStmtCacheSize=25 -hikaricp.prepStmtCacheSqlLimit=2048 -hikaricp.useServerPrepStmts=true -hikaricp.useLocalSessionState=true -hikaricp.rewriteBatchedStatements=true -hikaricp.cacheResultSetMetadata=true -hikaricp.cacheServerConfiguration=true -hikaricp.elideSetAutoCommits=true -hikaricp.maintainTimeStats=false +spring.datasource.hikari.pool-name=CMPP_Develop_Pool +spring.datasource.hikari.connection-timeout=60000 +spring.datasource.hikari.minimum-idle=1 +spring.datasource.hikari.maximum-pool-size=25 +spring.datasource.hikari.idle-timeout=6000 + +#spring.datasource.hikari.data-source-properties. +spring.datasource.hikari.data-source-properties.cachePrepStmts=true +spring.datasource.hikari.data-source-properties.prepStmtCacheSize=25 +spring.datasource.hikari.data-source-properties.prepStmtCacheSqlLimit=2048 +spring.datasource.hikari.data-source-properties.useServerPrepStmts=true +spring.datasource.hikari.data-source-properties.useLocalSessionState=true +spring.datasource.hikari.data-source-properties.rewriteBatchedStatements=true +spring.datasource.hikari.data-source-properties.cacheResultSetMetadata=true +spring.datasource.hikari.data-source-properties.cacheServerConfiguration=true +spring.datasource.hikari.data-source-properties.elideSetAutoCommits=true +spring.datasource.hikari.data-source-properties.maintainTimeStats=false \ No newline at end of file diff --git a/sentinel-dashboard/src/main/resources/banner.txt b/sentinel-dashboard/src/main/resources/banner.txt index 8f63277f63..b8e4a3e2f7 100644 --- a/sentinel-dashboard/src/main/resources/banner.txt +++ b/sentinel-dashboard/src/main/resources/banner.txt @@ -9,18 +9,18 @@ ${AnsiColor.BRIGHT_BLUE} \:\ \ /:/ / \::/ / \::/ / \:\ \ /:/ / \/__/ \/__/ \:\__\ /:/ / - \/__/ \/__/ CMPP Sentinel Power by CMIC - ___ ___ ___ ___ ___ ___ ___ - /\ \ /\ \ /\__\ /\ \ ___ /\__\ /\ \ /\__\ - /::\ \ /::\ \ /::| | \:\ \ /\ \ /::| | /::\ \ /:/ / - /:/\ \ \ /:/\:\ \ /:|:| | \:\ \ \:\ \ /:|:| | /:/\:\ \ /:/ / -_\:\~\ \ \ /::\~\:\ \ /:/|:| |__ /::\ \ /::\__\ /:/|:| |__ /::\~\:\ \ /:/ / + \/__/ \/__/ CMPP Sentinel,Power by CMIC + ___ ___ ___ ___ ___ ___ ___ + /\ \ /\ \ /\__\ /\ \ ___ /\__\ /\ \ /\__\ + /::\ \ /::\ \ /::| | \:\ \ /\ \ /::| | /::\ \ /:/ / + /:/\ \ \ /:/\:\ \ /:|:| | \:\ \ \:\ \ /:|:| | /:/\:\ \ /:/ / + _\:\~\ \ \ /::\~\:\ \ /:/|:| |__ /::\ \ /::\__\ /:/|:| |__ /::\~\:\ \ /:/ / /\ \:\ \ \__\ /:/\:\ \:\__\ /:/ |:| /\__\ /:/\:\__\ __/:/\/__/ /:/ |:| /\__\ /:/\:\ \:\__\ /:/__/ \:\ \:\ \/__/ \:\~\:\ \/__/ \/__|:|/:/ / /:/ \/__/ /\/:/ / \/__|:|/:/ / \:\~\:\ \/__/ \:\ \ -\:\ \:\__\ \:\ \:\__\ |:/:/ / /:/ / \::/__/ |:/:/ / \:\ \:\__\ \:\ \ - \:\/:/ / \:\ \/__/ |::/ / \/__/ \:\__\ |::/ / \:\ \/__/ \:\ \ - \::/ / \:\__\ /:/ / \/__/ /:/ / \:\__\ \:\__\ - \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ + \:\ \:\__\ \:\ \:\__\ |:/:/ / /:/ / \::/__/ |:/:/ / \:\ \:\__\ \:\ \ + \:\/:/ / \:\ \/__/ |::/ / \/__/ \:\__\ |::/ / \:\ \/__/ \:\ \ + \::/ / \:\__\ /:/ / \/__/ /:/ / \:\__\ \:\__\ + \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ ${AnsiColor.BRIGHT_GREEN} Application Version: ${application.version}${application.formatted-version} Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version} diff --git a/sentinel-dashboard/src/main/resources/bootstrap.yml b/sentinel-dashboard/src/main/resources/bootstrap.yml index c9a6507bba..a9b2c663ca 100644 --- a/sentinel-dashboard/src/main/resources/bootstrap.yml +++ b/sentinel-dashboard/src/main/resources/bootstrap.yml @@ -1,2 +1,23 @@ -mybatis: - mapper-locations: classpath:mappers/*.xml #这里是mapper的配置文件 +spring: + datasource: + url: jdbc:mysql://10.250.0.67:3306/ec?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai + username: ec + password: ec123$%^ + #Pool Configuration + hikari: + poolName: CMPP_Develop_Pool + connectionTimeout: 60000 + minimumIdle: 1 + maximumPoolSize: 25 + idleTimeout: 6000 + data-source-properties: + cachePrepStmts: true + prepStmtCacheSize: 25 + prepStmtCacheSqlLimit: 2048 + useServerPrepStmts: true + useLocalSessionState: true + rewriteBatchedStatements: true + cacheResultSetMetadata: true + cacheServerConfiguration: true + elideSetAutoCommits: true + maintainTimeStats: false \ No newline at end of file