Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pull #1

Merged
merged 356 commits into from
Sep 10, 2015
Merged
Changes from 1 commit
Commits
Show all changes
356 commits
Select commit Hold shift + click to select a range
0e1b825
add hystrix demo back.
calvin1978 Oct 15, 2013
04c0364
add hystrix demo back, and improve the usage to follow the layers
calvin1978 Oct 16, 2013
476de45
add hystrix demo back, and improve the usage to follow the layers
calvin1978 Oct 16, 2013
b33687f
add hystrix demo back, and improve the usage to follow the layers
calvin1978 Oct 16, 2013
e731912
add hystrix demo back, and improve the usage to follow the layers, ad…
calvin1978 Oct 16, 2013
cf46a4c
code format
calvin1978 Oct 16, 2013
be1bfe9
#286 add hystrix demo back, improve error handling
calvin1978 Oct 16, 2013
f969e4a
cleanup code
calvin1978 Oct 16, 2013
5115725
#286 add hystrix demo back, improve GUI
calvin1978 Oct 16, 2013
2a10ff0
#286 add hystrix demo back, improve GUI, 太久没做前台要了老命了。
calvin1978 Oct 16, 2013
40cc28c
jquery ajax用法升级至较新版
calvin1978 Oct 16, 2013
ba28d6d
页面美化
calvin1978 Oct 16, 2013
ff5a2cc
#286 add hystrix demo back, 继续要老命的界面美化,异常处理,并将Metrics采集放回UserService。
calvin1978 Oct 17, 2013
c415034
页面美化
calvin1978 Oct 17, 2013
cdaebd6
#286 add hystrix demo back, 最后一轮代码清理。
calvin1978 Oct 17, 2013
0a43c81
修复Common Logging不存在的bug,升级selenium 2.35->2.37.1
calvin1978 Oct 22, 2013
8e0bc04
修复Common Logging不存在的bug
calvin1978 Oct 22, 2013
c1729a8
页面美化, 函数rename
calvin1978 Oct 28, 2013
a74d32e
add error collector demo using logstash + ElasticSearch + Kibana.
Neway6655 Oct 29, 2013
1281b13
Merge pull request #290 from fbird/master
calvin1978 Oct 30, 2013
b834cb0
改进DateProvider用法
calvin1978 Nov 11, 2013
2ef384e
remove the complicated regex of the drop filter, because stackstrace …
Neway6655 Nov 11, 2013
493f08b
Tomcat打包可执行War包的Profile,但出来的包有找不到H2包的问题。
calvin1978 Oct 22, 2013
f0d697b
Merge pull request #296 from fbird/master
calvin1978 Nov 12, 2013
6542494
jmeter升级2.10,并修改变量定义的地方
calvin1978 Nov 11, 2013
5b72ac3
Quickstart 增加API 列表页面
calvin1978 Nov 21, 2013
d8679ac
update 3pp dependency
calvin1978 Nov 21, 2013
c7dc04e
#243 init
calvin1978 Nov 21, 2013
29c1b9a
fix dependency version error
calvin1978 Nov 22, 2013
33c65c9
#243 一个参考CodaHale的全新的Metrics Apia
calvin1978 Nov 29, 2013
e92ebdd
#243 一个参考CodaHale的全新的Metrics Api,基础计算部分完工,还剩报表部分
calvin1978 Dec 2, 2013
f1047cf
#243 metrics module, #243 一个参考CodaHale的全新的Metrics Api,add test and bu…
calvin1978 Dec 3, 2013
488b9da
#243 metrics module, #243 一个参考CodaHale的全新的Metrics Api,add test and bu…
calvin1978 Dec 3, 2013
d2843df
ignore the manual test
calvin1978 Dec 3, 2013
63f51e6
#243 metrics module, #243 对CodaHale的实现进行更深入的修改
calvin1978 Dec 5, 2013
dfc3103
#243 metrics module, Graphite不需要报告rate,它提供了自行计算的函数
calvin1978 Dec 6, 2013
a6f10ea
#243 metrics module, refactor
calvin1978 Dec 9, 2013
85a3e09
#243 metrics module, 在showcase中使用
calvin1978 Dec 9, 2013
25825b0
add other modules in showcase back
calvin1978 Dec 9, 2013
b96fa0f
update 3pp versions
calvin1978 Dec 10, 2013
d460d19
#243 metrics module, remove the rate in graphite again,
calvin1978 Dec 10, 2013
d228d98
minor update of 3pp versions
calvin1978 Nov 12, 2013
7c03f45
add README.txt in support dirs
calvin1978 Nov 12, 2013
de695b7
清理issues
calvin1978 Nov 12, 2013
9c6a07b
logstash move dir
calvin1978 Nov 12, 2013
c5e9b1a
#243 metrics module, remove mean rate in Counter
calvin1978 Dec 13, 2013
bd12f54
#243 metrics module, remove mean rate in Counter
calvin1978 Dec 13, 2013
1da5fb3
fix 3pp version
calvin1978 Dec 13, 2013
d149265
#243 metrics module, make clock default and other setting parameters
calvin1978 Dec 16, 2013
c0bcfc4
merge fbird's code
calvin1978 Dec 16, 2013
2aab34f
rename#243 metrics module, rename
calvin1978 Dec 16, 2013
ad6cf2f
1. upgrade logstash to version 1.3.1
Neway6655 Dec 16, 2013
4ab8704
Merge pull request #308 from fbird/master
calvin1978 Dec 16, 2013
a6192f6
Issue #307 maven-enforcer-plugin中的<exclude>org.springframework:3.0.*<…
calvin1978 Dec 16, 2013
1cc7512
Issue #307 maven-enforcer-plugin中的<exclude>org.springframework:3.0.*<…
calvin1978 Dec 17, 2013
cf588ac
Update pom.xml
sgq0085 Dec 23, 2013
41c0e48
Update pom.xml
sgq0085 Dec 23, 2013
6ee8745
Merge pull request #313 from sgq0085/patch-4
calvin1978 Dec 23, 2013
694c503
Merge pull request #312 from sgq0085/patch-3
calvin1978 Dec 23, 2013
30279b3
rename#243 metrics module, rename
calvin1978 Dec 26, 2013
cc90f75
rename#243 counter逻辑改为与statsd一样,每次发送时清零,但也保持一个长期的counter,另外,graphiteR…
calvin1978 Dec 26, 2013
ee96d83
rename#243 code refactor
calvin1978 Dec 27, 2013
d6526b8
Update schema.sql
xff8175 Jan 7, 2014
57d6b24
Merge pull request #319 from xff8175/patch-1
calvin1978 Jan 7, 2014
7c46831
Update schema.sql
sgq0085 Jan 8, 2014
89d9d87
logstash 文件重命名与注释修改
calvin1978 Jan 8, 2014
622efc0
logstash 文件重命名与注释修改
calvin1978 Jan 8, 2014
804e69d
logstash 文件重命名与注释修改
calvin1978 Jan 8, 2014
be81faa
logstash 修正日志文件格式
calvin1978 Jan 8, 2014
265b527
Merge pull request #320 from sgq0085/patch-5
calvin1978 Jan 9, 2014
daf16e5
add nosqlunit to test redis
calvin1978 Jan 15, 2014
17483bc
slight update
calvin1978 Jan 15, 2014
f502088
#323 合并SpringSide-Core 与 Spring-Test module
calvin1978 Jan 15, 2014
4c78c00
update deprecate method in selenium2
calvin1978 Jan 15, 2014
849506e
#322 默认不打开GraphiteReporter
calvin1978 Jan 15, 2014
2d6b89e
#323 合并SpringSide-Core 与 Spring-Test module
calvin1978 Jan 15, 2014
bb42deb
update official site
calvin1978 Jan 15, 2014
f1b2d42
update archetype
calvin1978 Jan 16, 2014
8da3f09
release SpringSide 4.2.0
calvin1978 Jan 16, 2014
8f44100
begin 4.3.0
calvin1978 Jan 16, 2014
a78733d
update 3pp version
calvin1978 Jan 16, 2014
f513211
#311 用assertJ简化assert编写
calvin1978 Jan 16, 2014
3d798b6
#311 用assertJ简化assert编写
calvin1978 Jan 17, 2014
e75af17
#314 使用NoSQL Unit的嵌入式Redis编写测试
calvin1978 Jan 17, 2014
8548b51
#309 Spring 4.0, update servlet to 3.0 for Spring 4.0 MockHttpRequest
calvin1978 Jan 17, 2014
15aa962
#309 Spring 4.0, update servlet to 3.0 for Spring 4.0 MockHttpRequest
calvin1978 Jan 17, 2014
585eb29
#309 Spring 4.0, update servlet to 3.0 for Spring 4.0 MockHttpRequest
calvin1978 Jan 17, 2014
6c8366c
#314 使用NoSQL Unit的嵌入式Redis编写测试, fix case
calvin1978 Jan 17, 2014
bc6ec05
fix cases for mybatis
calvin1978 Jan 17, 2014
8cd8965
updat travis to fail fast, if unit test error, stop test the project
calvin1978 Jan 17, 2014
7202262
rollback, ehcache 导致ut和ft不能一起跑
calvin1978 Jan 17, 2014
6df93c8
update firefox version in travis-ci
calvin1978 Jan 17, 2014
fe65249
#314 使用NoSQL Unit的嵌入式Redis编写测试, update the tempate return code to In…
calvin1978 Jan 17, 2014
e6f36ef
fix unstable test
calvin1978 Jan 17, 2014
dae36f3
#311 用assertJ简化assert编写, springside-core部分
calvin1978 Jan 17, 2014
9ad845d
fix copy-right
calvin1978 Jan 17, 2014
5a1eb2c
#311 用assertJ简化assert编写, springside-metrics部分
calvin1978 Jan 17, 2014
f5c354d
#311 用assertJ简化assert编写, showcase部分
calvin1978 Jan 17, 2014
c771be6
#309 Spring 4.0, 使用@RestController,不用每个方法都定义@ResponseBody
calvin1978 Jan 18, 2014
2478aa8
#309 Spring 4.0, 使用@RestController,update shcema version
calvin1978 Jan 18, 2014
cf622ff
#309 Spring 4.0, pom.xml里使用spring-framework-bom,不用再定义spring所有子模块的版本,并…
calvin1978 Jan 18, 2014
d1e96f4
#311 用assertJ简化assert编写, 将fail改为failBecauseExceptionWasNotThrown(exce…
calvin1978 Jan 18, 2014
62ab283
#327 try scalatest for BDD testing
calvin1978 Jan 20, 2014
c739871
update version of guava and hibernate-validator
calvin1978 Jan 21, 2014
e51b3cc
Issue #285 httpclient 4.3 变动,及其Fluent API演示
calvin1978 Jan 21, 2014
477c861
format pom.xml
calvin1978 Jan 21, 2014
a084177
Issue #285 httpclient 4.3 变动,增强FluentAPI的异常处理与注释
calvin1978 Jan 21, 2014
39c4e5f
Issue #285 httpclient 4.3 变动,polish
calvin1978 Jan 21, 2014
8688041
rollback Spring data jpa from 1.4.3->1.4.2, 因为在jetty按回车重启服务器时,会报not a…
Jan 23, 2014
7dd1244
#242 update jedisTemplate to support setNxEx
Jan 23, 2014
c32be7a
#327 try scalatest for BDD testing, 写完第一个用例,使用了selenium DSL, scalate…
Jan 24, 2014
a0efcfb
#327 try scalatest for BDD testing, polish
Jan 24, 2014
d934fec
#327 try scalatest for BDD testing, polish
Jan 24, 2014
4358cec
#327 try scalatest for BDD testing, polish
Jan 24, 2014
b6ac4c7
#243 metrics module, update showcase
Jan 24, 2014
59d56f1
update hibernate to 4.3.1
Jan 24, 2014
36827d4
#272 LogStash集中式日志处理演示 New Feature , polish
Jan 24, 2014
0ec03d9
#272 LogStash集中式日志处理演示 设置错误日志按日期输出
Jan 24, 2014
7494814
#327 try scalatest for BDD testing, fix the review comments
Jan 26, 2014
362d83f
code format
Jan 26, 2014
5fa0624
polish Utils
Jan 26, 2014
428ed55
polish by Sonar
Jan 26, 2014
ecc8c2a
polish
calvin1978 Jan 26, 2014
4342c21
update archetype
calvin1978 Jan 26, 2014
0572c2a
prepare for 4.2.1 Release
calvin1978 Jan 26, 2014
5c6c30f
update to yuicompressor to 2.4.8
Jan 27, 2014
8a9bbcf
update git ignores
Jan 27, 2014
f02781e
Merge remote-tracking branch 'origin/master'
Jan 27, 2014
43d1794
prepare for 4.3.0
Jan 28, 2014
0a8910d
add bdd-test.bat
Jan 28, 2014
64c14e5
update 3pp version, spring 4.0->4.0.1(bug fixing), jedis 2.2.1->2.3.0…
calvin1978 Feb 4, 2014
163f63f
同上,還有tomcat-jdbc 7.0.50->8.0.1
calvin1978 Feb 4, 2014
8c7dd29
#275 tomcat jdbc 连接超时问题: No operations allowed after connection closed.
calvin1978 Feb 4, 2014
b682f18
update 3pp, slf4j 1.7.4->1.7.5, jedis,logback
Feb 7, 2014
5c04af1
polish, 而且tomcat-jdbc 8.0 用jdk7编译,回退到7.x
Feb 7, 2014
7062065
Polish
Feb 8, 2014
0c9d290
upload internal JedisPool
Feb 8, 2014
6ab3005
change tcp input/output codec to 'line', because tcp input sometimes …
Neway6655 Feb 8, 2014
b989c99
refactoring about jedis pool
Feb 8, 2014
268b50d
rename
Feb 8, 2014
a5f2448
Merge pull request #331 from fbird/master
calvin1978 Feb 8, 2014
914300f
typo
calvin1978 Feb 7, 2014
54211cb
#332 refactoring the code to make it opensourceable.
calvin1978 Feb 8, 2014
aefa32f
#332 refactoring the code to make it opensourceable.
calvin1978 Feb 8, 2014
9a4fbb0
#332 rename
calvin1978 Feb 8, 2014
a92db01
rename
calvin1978 Feb 8, 2014
7051b6d
#332 endless refactoring
calvin1978 Feb 8, 2014
484941e
#332 endless refactoring
calvin1978 Feb 8, 2014
d9d30ec
#332 endless refactoring, don't use pool ,just use jedis for setinel
Feb 10, 2014
e004707
#332 polish
Feb 10, 2014
82dcc49
update the new log path
Feb 10, 2014
afb8531
#325 增加Logstash从业务日志进行统计的演示
Feb 11, 2014
7fba54f
#325 增加Logstash从业务日志进行统计的演示
Feb 18, 2014
9116ae8
#325 增加Logstash从业务日志进行统计的演示,分析日志内容分门别类到不同的counter
Feb 19, 2014
623c08c
#325 增加Logstash从业务日志进行统计的演示,update readme
Feb 19, 2014
3c9f98f
#325 增加Logstash从业务日志进行统计的演示,update readme
Feb 19, 2014
8bead7d
#325 增加Logstash从业务日志进行统计的演示,update readme
Feb 19, 2014
ed7d078
update 3pp minor version, spring 4.0.1->4.0.2, spring data jpa 1.4.2-…
Feb 20, 2014
c51036c
update archetype
calvin1978 Feb 20, 2014
a11fc4c
release SpringSide 4.2.2.GA
calvin1978 Feb 20, 2014
7c5b235
增加grafana的springside demo,白色风格,图里显示平均值和阀值线。
Feb 27, 2014
9a36ffe
#325 logstash增加分析日志中的内容,并发送到ElasticSearch的例子
Feb 27, 2014
722a79d
update 3pp versions
Mar 17, 2014
7930e23
Merge remote-tracking branch 'origin/master'
Mar 17, 2014
c923797
open cxf logging
Mar 17, 2014
3f6b788
rollback hibernate 5.1.0->5.0.3 for spring 兼容
calvin1978 Apr 14, 2014
2200072
springside-metrics 代码改进与添加注释
calvin1978 Apr 14, 2014
5afe60a
update 3pp versions
calvin1978 Apr 14, 2014
64f480b
Update list.jsp
HejiaHo Apr 29, 2014
b984b4b
升级3pp版本,并解决quickstart在jboss里缺少commons-codec的问题。
May 5, 2014
3b7cc45
fix httpcore artifact id error
May 7, 2014
1cbf7f8
fix httpcore artifact id error
May 7, 2014
a4f1dc9
update benmark parent class implementation
May 27, 2014
2557cef
update 3pp, but CXF 3.0 not included yet
Jun 5, 2014
3bd4475
Merge pull request #358 from HejiaHo/master
calvin1978 Jun 5, 2014
fd8d9cd
update to next minor version
calvin1978 Jun 5, 2014
aeaf06a
update README to add Travis-CI status
calvin1978 Jun 5, 2014
af0c471
update list.jsp to shortern the code
calvin1978 Jun 5, 2014
4b62432
run()函数改为catch Throwable,避免Throwable异常,终断scheduler以后的执行。
calvin1978 Jun 5, 2014
9da096b
#364 bug fixing,并含其他metrics演示的改进:
calvin1978 Jun 5, 2014
a46f2cc
store log file in /tmp, In Windows, it's the [Drive your application…
calvin1978 Jun 5, 2014
caed986
#325, 升级到logstash 1.4.1的使用。
Jun 6, 2014
ce277a8
Merge remote-tracking branch 'origin/master'
Jun 6, 2014
d582b3d
Merge remote-tracking branch 'origin/master'
Jun 13, 2014
1152471
Change Execution back to Timer
Jun 16, 2014
c0c9734
rename metrics package
Jun 16, 2014
f9a4736
add JMXExporter to spring-metrics
Jun 16, 2014
9f69899
修改Servlets.setFileDownloadHeader方法中文文件名有空格时被截断及IE下乱码问题
hzl7652 Jun 16, 2014
d368fc1
logstash修正1.4.1上的配置
Jun 17, 2014
630b678
Jedis 支持 客户端Sharding,Jedis提供的ShardingPool不能同时兼容Sentinel Pool,SpringSi…
Jun 18, 2014
9ca3f76
jedis add sharding feature
Jun 19, 2014
b0f8770
slight update
Jun 27, 2014
20fcb57
修复JedisShardedTemplateTest测试用例hashActions中的key命名错误
LuciferYang Jul 1, 2014
ed3a7f4
Merge pull request #374 from LuciferYang/master
calvin1978 Jul 3, 2014
aeac04f
添加用于生成新项目的Bash脚本
diguage Aug 6, 2014
9666141
增加核心模块“安装”所用的Bash脚本
diguage Aug 6, 2014
ac68e69
增加QuickStart示例中所用脚本的Bash版
diguage Aug 6, 2014
00da05f
增加Showcase所用脚本的Bash版
diguage Aug 6, 2014
6c60374
fix generate project failed
kennedy-han Aug 17, 2014
d84df3b
REST默认返回JSON格式
jtraviss Aug 20, 2014
9b7d7f8
Merge pull request #385 from kennedy-han/master
calvin1978 Sep 12, 2014
40413d6
Merge pull request #381 from diguage/master
calvin1978 Sep 12, 2014
575b369
Merge pull request #371 from hzl7652/upstream
calvin1978 Sep 12, 2014
a61d406
metrics update
Sep 12, 2014
20d6438
Merge branch 'master' of https://github.com/springside/springside4
Sep 12, 2014
4f46cbd
Merge branch 'master' of https://github.com/springside/springside4
Sep 12, 2014
85f705e
#393 移动redis代码到独立模块
Sep 13, 2014
a98f360
#393 新的Connection定义及Pool
Sep 13, 2014
897aff8
#393 add race condition when pool init and switch
Sep 13, 2014
3848557
#393 move the elector and scheduler to new package
Sep 13, 2014
f3d8434
#393 补充JedisTemplate和JedisSharedTemplate的方法
Sep 13, 2014
6af30e2
#393 增加Pipeline内运行的回调函数接口
Sep 13, 2014
aaa0833
#393 rollback race condition,only wait for init
Sep 14, 2014
1c1764e
#393 增加sharding key接口,支持一个Action里访问多个Key
Sep 14, 2014
1418b7b
#393 rename
Sep 14, 2014
f80eec4
将Bash脚本加上统一的后缀,增加两个Bash脚本
diguage Sep 18, 2014
2efeed0
增加Bash脚本的Bangsha信息
diguage Sep 18, 2014
029690f
Merge remote-tracking branch 'origin/master'
Oct 7, 2014
4cf86e3
update version for release
Oct 7, 2014
6d17cdd
Merge remote-tracking branch 'origin/master'
Oct 7, 2014
41c0e80
Merge pull request #396 from diguage/master
calvin1978 Oct 7, 2014
bf0ad78
fix compile error
Oct 7, 2014
e7b68e4
Merge remote-tracking branch 'origin/master'
Oct 7, 2014
7ed5da0
Merge pull request #387 from jtraviss/master
calvin1978 Oct 7, 2014
558cd3c
Merge remote-tracking branch 'origin/master'
Oct 7, 2014
7bcb464
update generate-project file version
Oct 7, 2014
9fbb219
update archetype
Oct 7, 2014
93d4fbb
netxt version
Oct 11, 2014
4a63d82
分拆springside-core 为 springside-utils 和 springside-core, 新的example1将只依…
Oct 11, 2014
eb5018f
#394 开始加入Spring Boot的演示
Oct 11, 2014
1073c07
#394 update Spring Boot demo
Oct 11, 2014
429cdce
#394 update Spring Boot demo的测试方法
Oct 12, 2014
f1e9557
#394 one more spring boot example demo adavanced feature
Oct 15, 2014
7bf465f
metrics improvment
Nov 10, 2014
7aa9697
[metrics]fix lastRate & meanRate long/double problem
Nov 21, 2014
5e0ae65
[metrics]fix lastRate & meanRate long/double problem
Nov 21, 2014
16bb5da
[metrics]fix lastRate & meanRate long/double problem
Nov 21, 2014
4b20ccd
Merge pull request #422 from jenning/master
calvin1978 Nov 21, 2014
26d543b
fix testcase
Nov 21, 2014
da72edb
手工merge pull request里的更新
Nov 21, 2014
a4e6d46
ignore some GUI test to let showcase test pass
Nov 21, 2014
f1a4295
update JedisPoolBuilder
Nov 21, 2014
6f23955
Metrics-Lib update,补完JMX Exporter的活
Nov 21, 2014
eb12098
[metrics module] 一系列改进,包括一些重命名,JMXExporter更完善,锁的改进,排序的改进等
Nov 21, 2014
66940a0
small upgrde for sprnigside-metrics
Dec 11, 2014
6349135
prepare to upload springside modules to Maven central repository
Dec 11, 2014
e501181
minor updates
Dec 25, 2014
a01cd0b
minor updates
Dec 25, 2014
6a788aa
change groupId to io.springside and fix some 3pp version problem
Dec 25, 2014
df81d06
update boot-service to spring-boot 1.2.1 and more simple
calvin1978 Jan 8, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add hystrix demo back, and improve the usage to follow the layers
calvin1978 committed Oct 16, 2013
commit b33687f03cb7cbc8c81716bfc47bd22e116a64e3
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
public class DependencyResourceController {
public static final int TIMEOUT = 15000;

private String status = "normal";
public static String status = "normal";

@Autowired
private AccountEffectiveService accountService;
Original file line number Diff line number Diff line change
@@ -16,11 +16,9 @@ public class GetUserCommand extends HystrixCommand<UserDTO> {
private Long id;

protected GetUserCommand(Setter config, RestTemplate restTemplate, Long id) {
// 配置Command
super(config);
// 传入

this.restTemplate = restTemplate;
// 传入请求参数
this.id = id;
}

Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springside.examples.showcase.webservice.rest.UserDTO;

@@ -15,17 +16,24 @@
import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
import com.netflix.hystrix.HystrixThreadPoolProperties;

/**
* 使用Hystrix 封装的Service。原来直接调用restTemplate改为调用Hystrix Command的封装.
*
* @author calvin
*/
@Service
public class UserService {

private static Logger logger = LoggerFactory.getLogger(UserService.class);

private Boolean runInNewThread = true;
private Setter config;
private RestTemplate restTemplate = new RestTemplate();
private boolean runInNewThread = true;

private Setter commandConfig;
private RestTemplate restTemplate;

public UserDTO getUser(Long id) throws Exception {

GetUserCommand command = new GetUserCommand(config, restTemplate, id);
GetUserCommand command = new GetUserCommand(commandConfig, restTemplate, id);

try {
return command.execute();
@@ -36,49 +44,47 @@ public UserDTO getUser(Long id) throws Exception {
}

/**
* 演示Command的各种配置项,构造RestTemplate.
* 演示Command的各种配置项, 并构造Thread-Safed的RestTemplate.
*/
@PostConstruct
private void init() {
// 初始化RestTemplate
restTemplate = new RestTemplate();

// 设置Command名称 //
config = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")).andCommandKey(
commandConfig = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup")).andCommandKey(
HystrixCommandKey.Factory.asKey("GetUserCommand"));

HystrixCommandProperties.Setter commandProperties = HystrixCommandProperties.Setter();
commandConfig.andCommandPropertiesDefaults(commandProperties);

// 设置短路计算规则 //
config.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
commandProperties
// 多少百分比的失败在rolling windows内发生,计算为短路。默认为50%,无改变。
.withCircuitBreakerErrorThresholdPercentage(50)
// 至少多少请求在rolling window内发生,才开始触发短路的计算,默认为20, 设为3方便演示。
.withCircuitBreakerRequestVolumeThreshold(3)
// rolling windows 长度,默认为20秒,改为60秒方便演示。同时相应改变桶的数量。
.withMetricsRollingStatisticalWindowInMilliseconds(60000)
.withMetricsRollingStatisticalWindowBuckets(60));
// rolling windows 长度,默认为20秒,改为180秒方便演示。同时相应改变桶的数量。
.withMetricsRollingStatisticalWindowInMilliseconds(180000)
.withMetricsRollingStatisticalWindowBuckets(180);

// 设置短路后的保护时间 //
config.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerSleepWindowInMilliseconds(20000));
// 设置短路后的保护时间 ,默认为5秒,改为20秒方便演示//
commandProperties.withCircuitBreakerSleepWindowInMilliseconds(20000);

// 设置超时与并发控制 //
if (runInNewThread) {
// 使用Hystrix线程池的异步执行方式
config.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
// 线程超时,默认为1秒,设为2秒方便演示
.withExecutionIsolationThreadTimeoutInMilliseconds(2000))
commandProperties.withExecutionIsolationThreadTimeoutInMilliseconds(2000);
// 线程池属性, 线程池大小,默认为10,无改变。待执行队列的大小,默认为5,无改变。
.andThreadPoolPropertiesDefaults(
HystrixThreadPoolProperties.Setter().withCoreSize(10).withQueueSizeRejectionThreshold(5));
commandConfig.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(10)
.withQueueSizeRejectionThreshold(5));
} else {
// 使用Invoker原有线程的方式, 设置使用信号量模式而不是默认的线程池模式,设置并发,默认为10,无改变
config.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(10));

// RestTemplate设置为10秒超时
((SimpleClientHttpRequestFactory) restTemplate.getRequestFactory()).setConnectTimeout(10000);

// 设置使用信号量模式而不是默认的线程池模式,设置并发,默认为10,无改变
commandProperties.withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(10);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.springside.examples.showcase.demos.hystrix.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springside.examples.showcase.demos.hystrix.service.UserService;
import org.springside.examples.showcase.webservice.rest.RestException;
import org.springside.examples.showcase.webservice.rest.UserDTO;

@Controller
public class HystrixDemoController {

private static Logger logger = LoggerFactory.getLogger(HystrixDemoController.class);

@Autowired
private UserService userService;

@RequestMapping(value = "/hystrix/user/{id}", method = RequestMethod.GET)
@ResponseBody
public UserDTO getUser(@PathVariable("id") Long id) {

try {
return userService.getUser(id);
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RestException(HttpStatus.SERVICE_UNAVAILABLE);
}
}

}
1 change: 1 addition & 0 deletions examples/showcase/src/main/webapp/WEB-INF/layouts/left.jsp
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
<div class="submenu">
<a id="web-tab" href="${ctx}/story/web">Web演示</a>
<a id="webservice-tab"href="${ctx}/story/webservice">WebService演示</a>
<a id="hystrix-tab" href="${ctx}/story/hystrix">JMX演示</a>
<a id="jmx-tab" href="${ctx}/story/jmx">JMX演示</a>
<a id="log-tab" href="${ctx}/story/log">日志高级演示</a>
<a id="monitor-tab" href="${ctx}/story/monitor">性能监控演示</a>
60 changes: 60 additions & 0 deletions examples/showcase/src/main/webapp/WEB-INF/views/story/hystrix.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="org.springside.examples.showcase.demos.hystrix.dependency.DependencyResourceController,com.netflix.hystrix.*,com.netflix.hystrix.HystrixCommandMetrics.HealthCounts,com.netflix.hystrix.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%! %>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
<title>Web Service高级演示</title>
<script>
$(document).ready(function() {
$("#hystrix-tab").addClass("active");
});
</script>
</head>

<body>
<h1>Hystrix 演示</h1>

<p><a href="https://github.com/Netflix/Hystrix" target="_blank">Netflix Hystrix</a> 是一个延迟与容错类库,通过独立访问远程系统、服务和第三方库的节点,在复杂的分布式系统里停止雪崩及提供恢复能力。</p>

<h2>演示操作</h2>
<ul>
<li>依赖资源当前状态为<%= DependencyResourceController.status %>:切换为<a href="${ctx}/hystrix/resource/status/normal">正常</a>、<a href="${ctx}/hystrix/resource/status/timeout">超时</a>、<a href="${ctx}/hystrix/resource/status/fail">失败</a>。</li>
<li>访问服务:<a href="${ctx}/hystrix/user/1" target="_blank">Hystrix服务</a>、<a href="${ctx}/hystrix/resource/1" target="_blank">依赖资源</a></li>
</ul>
<h2>主要用户故事</h2>
<ul>
<li> 在默认的正常状态,访问Hystrix服务和依赖资源,均返回正常结果。</li>
<li> 将资源状态切换为"超时",访问依赖资源,需要在15秒后才返回结果。</li>
<li> 访问Hystrix服务,2秒后超时,返回503。</li>
<li> 三次超时后满足短路条件(60秒滚动窗口内起码有3个请求,50%失败),再次刷新服务,立即返回503。</li>
<li> 10秒短路保护期内,所有访问都立即返回503,不会访问依赖资源。</li>
<li> 保护期过后,会放行一个请求,如果还是超时,则继续保持短路状态。如果成功则重置所有计数器。</li>
</ul>

<h2>其他用户故事</h2>
<ul>
<li> 将资源状态切换为"失败",访问依赖资源,立即返回500错误,访问Hystrix服务,即时返回503错误。</li>
<li> 默认使用Hystrix线程池模式,可修改代码使用调用线程池模式。</li>
</ul>

<h2>监控结果 </h2>
<form><input type="submit" value="刷新"/></form>
<%
HystrixCommandKey key = HystrixCommandKey.Factory.asKey("GetUserCommand");
HystrixCommandMetrics metrics = HystrixCommandMetrics.getInstance(key);
if (metrics!=null){
HealthCounts counts = metrics.getHealthCounts();
HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory.getInstance(key);


%>
<ul>
<li>是否短路:<%= circuitBreaker.isOpen() %></li>
<li>3分钟窗口内,请求:<%= counts.getTotalRequests()%>, 成功:<%= metrics.getRollingCount(HystrixRollingNumberEvent.SUCCESS) %>, 超时:<%= metrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT) %>,失败:<%= metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE) %>,短路:<%= metrics.getRollingCount(HystrixRollingNumberEvent.SHORT_CIRCUITED) %>, 失败百分比:<%= counts.getErrorPercentage() %>%
<li>50%延时:<%= metrics.getTotalTimePercentile(50) +"ms"%>,90%延时:<%= metrics.getTotalTimePercentile(90) +"ms"%>,100%延时:<%= metrics.getTotalTimePercentile(100) +"ms"%></li>
</ul>
<%} %>
</body>
</html>