Skip to content

Commit

Permalink
Fixed Dashboard try to access Alipay domain https://kcart.alipay.com…
Browse files Browse the repository at this point in the history
…/web/bi.do?`

By upgrading G2 Lib to version 3.4.10

alibaba#522
  • Loading branch information
MickMo committed Mar 1, 2019
1 parent db16cca commit b18cdea
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 79 deletions.
21 changes: 17 additions & 4 deletions sentinel-dashboard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down Expand Up @@ -90,6 +86,13 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!--shrio依赖-->
<dependency>
Expand Down Expand Up @@ -174,6 +177,8 @@
</dependency>
</dependencies>



<build>
<finalName>sentinel-dashboard</finalName>
<plugins>
Expand Down Expand Up @@ -215,6 +220,14 @@
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.txt</include>
<include>*.xml</include>
<include>*.wsdl</include>
<include>reports/*</include>
<include>managerReports/*</include>
<include>mappers/*</include>
</includes>
</resource>

<resource>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<String> headersList = Arrays.asList("Name", "Value");
List<List<String>> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, String> allAuth = userService.findAllAuth();
return allAuth;
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,7 +13,7 @@
/**
* Created by Administrator on 2016/12/5 0005.
*/
@Repository
@Mapper
public interface UserDao {

User findByLoginname(@Param("loginname") String loginname);
Expand Down
43 changes: 20 additions & 23 deletions sentinel-dashboard/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions sentinel-dashboard/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
25 changes: 23 additions & 2 deletions sentinel-dashboard/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b18cdea

Please sign in to comment.