Commit Graph

310 Commits

Author SHA1 Message Date
Lynx 6f2f844726
Fix the problem that requests will never be blocked when slowRatioThreshold = 100% (#1779) 2020-11-05 20:35:09 +08:00
Jason Joo d510eb6cd3
test: Fix overrunning test `FlowRuleManagerTest.testLoadAndGetRules` (#1823)
Signed-off-by: Jason Joo <hblzxsj@163.com>
2020-10-29 14:22:36 +08:00
Weihua c00f946813 Fix potential concurrency issue when updating flow rules (#1783) 2020-10-09 09:54:02 +08:00
nickChenyx cc2d1a69a9
Optimize logging statements using placeholder (#1736)
* Optimize logging statements using placeholder to avoid unnecessary concatenation (issue #1735)
2020-09-17 20:42:01 +08:00
yunfeiyanggzq 473cc84262 Add concurrency token request/release operation in TokenService
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
2020-09-16 11:40:14 +08:00
yunfeiyanggzq 75f138821d Add attributes of cluster concurrency limiting in ClusterFlowConfig
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
2020-09-16 11:38:58 +08:00
M4Y 10aa39f822
doc: Fix typo in code comments (#1721) 2020-09-10 22:59:45 +08:00
mikawudi d5eb5f473f
Pre-calculate intervalInSecond in LeapArray to reduce redundant calculation (#1700) 2020-08-27 19:47:35 +08:00
ZhiQiang Gu b91305a903
Fix typo in CircuitBreakingIntegrationTest (#1688)
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
2020-08-21 15:10:53 +08:00
Eric Zhao e58267012d Bump version to 1.8.1-SNAPSHOT
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-21 14:36:49 +08:00
Eric Zhao d17bf8c7cc Bump version to 1.8.0
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-20 19:47:20 +08:00
Eric Zhao 125996d4d1 Add RuntimeException converting method in BlockException and polish logic for validation
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-20 10:22:07 +08:00
Eric Zhao a88288715a Refactor extended MetricExtension interface (matching events in Sentinel)
- Unify the extended interface as a few event handlers: onPass, onBlocked, onComplete and onError
- Polish related code

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-19 10:23:20 +08:00
Bill Yip 8643dac943
Add extended interface for metric extension hook to support distinguishing traffic type (#1665)
- Add EntryType args to all hook methods
2020-08-18 16:55:30 +08:00
Eric Zhao dae4621e6e Refactor exit handler mechanism of Entry
- Rename: whenComplete -> whenTerminate
- Execute the exit handler directly after the onExit hook of all slots

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-18 16:42:58 +08:00
Eric Zhao 55e038cc33 Polish CircuitBreaker interface and update comments
- Only carry context in tryPass/onComplete method (this might be generic in upcoming versions)

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-18 15:31:35 +08:00
Jason Joo ee2772b513
Fix the bug of circuit breaker half-open state transformation when request is blocked by upcoming rules (#1645)
* Refactor the workflow to fix the bug that circuit breaker may remain half-open state forever when the request is blocked by upcoming rules: revert the state change in exit handler (as a temporary workaround)
* Add exit handler in Entry as a per-invocation hook.
2020-08-18 11:04:48 +08:00
M4Y 10c92e69a2
Optimize the order of slots in ProcessorSlot SPI config (#1649) 2020-08-17 10:38:24 +08:00
Peine c5da3faad9
Polish boolean checking in test cases and dashboard (#1664) 2020-08-12 20:34:22 +08:00
Eric Zhao a18ef7cbfa Remove deprecated passCheck() in Rule and polish interface
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-08-05 10:42:15 +08:00
Eric Zhao 07b811196b Update test cases for circuit breaking
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-07-30 19:00:13 +08:00
Eric Zhao c0c27c86b7 Refactor degrade hierarchy with new circuit breaker mechanism and improve strategy
* Add `CircuitBreaker` abstraction (with half-open state) and add circuit breaker state change event observer support.
* Improve circuit breaking strategy (avg RT → slow request ratio) and make statistics of each rule dependent (to support arbitrary statistic interval).
* Add simple "trial" mechanism (aka. half-open).
* Refactor mechanism of metric recording and state change handling for circuit breakers: record RT and error when requests have completed (i.e. `onExit`, based on #1420).

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-07-30 19:00:13 +08:00
ZhiQiang Gu bd29e046e1
Add unit test for logging/TokenBucket (#1504)
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
2020-05-29 15:57:38 +08:00
于玉桔 6b86721b36
Support setting class-level defaultFallback for annotation extension (#1493) 2020-05-29 13:49:00 +08:00
ZhiQiang Gu 2e64d33085
test: Add test cases for Tuple2 (#1501)
Signed-off-by: yunfeiyanggzq <yunfeiyang@buaa.edu.cn>
2020-05-25 13:44:54 +08:00
pleasecheckhere2016 5523fd0d42
Add exceptionPredicate in Tracer for customized exception filtering logic (#1496) 2020-05-21 15:17:19 +08:00
Eric Zhao 99d4355318 Polish code comments of the fundamental Sph/SphO/SphU class
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-05-11 17:45:48 +08:00
Eric Zhao 516e36fd83 Polish Tracer with entry.setError(ex) mechanism
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-04-28 10:11:17 +08:00
Eric Zhao 7f3165740a Refactor the mechanism of recording error in Entry and StatisticSlot
* Also polish related complete callbacks

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-04-28 10:11:17 +08:00
Eric Zhao 7f0771df5c
Update resolving logic of project name and polish SentinelConfig (#1437)
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-04-27 15:05:03 +08:00
Lin.Liang b716bed370
Support setting project.name via the properties file and deprecate legacy config path (#1412) 2020-04-26 21:06:32 +08:00
johnli 5e9cfb0deb
fix: Tracer does not trace exception to DefaultNode (#1068) 2020-04-26 20:48:39 +08:00
haifeng 04a1d065dd
Fix the bug of misplaced locks in ContextUtil and ClusterNode (#1429)
- which may lead to IllegalMonitorStateException in unlock() when unchecked error occurs during lock()
2020-04-26 10:58:27 +08:00
Eric Zhao a0196b6b00 Bump version to 1.8.0-SNAPSHOT
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-04-13 20:19:22 +08:00
Eric Zhao 6a7ec708bc Bump version to 1.7.2
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-04-08 09:42:02 +08:00
cdfive e1435974c6
Set default log level of JDK logging to INFO and polish code of SpiLoader (#1365)
* Improve log info in SpiLoader, improve comment and test case
* Use error level in catch block, init ArrayList with capacity and improve add item to list
2020-04-03 15:46:25 +08:00
Jason Joo 49e60a3e51
Force modifyRule command handler to fail if an incompatible old fastjson found (#1377)
* Note that this is only a temporary solution.
2020-04-03 15:32:42 +08:00
cdfive be4d058bf8
refactor: Make the ProcessorSlot itself as SPI and deprecate legacy slot chain builder (#411)
* Make slots loaded by SPI, mark all slots with @SpiOrder from -10000 to -1000, improve comment
* Reserve gateway and param slot chain builder (just extends DefaultSlotChainBuilder) and mark them as @Deprecated
2020-03-26 12:38:01 +08:00
于玉桔 670b2cb764
Improve standard output message in LogBase (#1357) 2020-03-25 21:17:14 +08:00
Eric Zhao 87f95adc2e Fix timezone problem of sentinel-block.log
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-03-19 14:54:40 +08:00
Eric Zhao eed77cafc2
Polish placeholders in logging content to slf4j convention (#1342)
* Polish placeholders in logging content to "{}"

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-03-17 11:11:54 +08:00
Eric Zhao e4769293dc
Move CommandCenterLog to sentinel-transport-common and polish related code (#1341)
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-03-16 22:30:29 +08:00
Eric Zhao 624d19d4ce
Polish logging SPI related code and add general JUL adapter for Logger SPI (#1338)
* Move the legacy JUL methods from LogBase to BaseJulLogger.
* Add a JavaLoggingAdapter as the general JUL adapter for the Logger SPI, which makes it convenient to use (as the default logger).
* Add LoggerSpiProvider to resolve Logger SPI.
* Polish the logback demo.

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2020-03-16 10:00:46 +08:00
tianhao 6e0d116751 calculate process cpu usage to support application running in container environment 2020-03-06 17:15:22 +08:00
xue8 5f203aa79f
Flexible loggers' support through SPI mechanism with name `com.alibaba.csp.sentinel.log.Logger` (#1265)
* There are two types of logger for command center and common modules specified by  annotation of `LogTarget`
* Add implementing examples in `sentinel-demo/sentinel-demo-log-logback`
* All implementations should support placeholder '{}'
2020-02-21 11:24:00 +08:00
cdfive c1ff9135ee
Fix NPE in Tracer when context size exceeds the limit (#1293) 2020-02-21 09:21:30 +08:00
Eric Zhao 87142ce512 Bump version to 1.7.2-SNAPSHOT
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-12-25 11:19:07 +08:00
Eric Zhao 9c909e3631 Bump version to 1.7.1
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-12-24 20:05:23 +08:00
Eric Zhao e9d730cc39 test: Fix unstable test cases in MetricExitCallbackTest
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-12-24 19:54:46 +08:00
fangwentong 0e110c68ea Fix the logic of getting maxSuccessQps in StatisticNode (#1196) 2019-12-20 13:57:53 +08:00
Eric Zhao a63c1841ee Support setting config file path via system env and improve error handling in SentinelConfigLoader
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-12-18 19:00:52 +08:00
Eric Zhao c70565167f
refactor: Get the max allowed RT directly from SentinelConfig.statisticMaxRt() (#1173)
- to avoid the dependency chain: Constants -> SentinelConfig

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-11-21 17:03:10 +08:00
于玉桔 24f8d75601 Fix the incorrect logic of handling the end separator of the log directory in LogBase (#1172) 2019-11-21 13:37:50 +08:00
Eric Zhao 72a58f7ea7 Add Consumer functional interface in sentinel-core utils
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-11-20 13:55:26 +08:00
Eric Zhao 9705f54611 Bump version to 1.7.1-SNAPSHOT
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-11-12 11:08:14 +08:00
Eric Zhao 8cdf1de854 Bump version to 1.7.0
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-11-11 21:12:58 +08:00
Eric Zhao 6bb2de8750 Support classification for Sentinel resources
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-11-06 21:00:08 +08:00
Eric Zhao cf5b955f12 Improve AssertUtil for collection checking
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-11-05 17:51:56 +08:00
Eric Zhao 74a40aa285
Improve Node and Metric interface to support conditional metric retrieval (#1115)
* Add detailsOnCondition method in Metric interface to filter MetricNode within the time condition.
* Add rawMetricsInMin method in Node interface, which will retrieve and generate metric items from the min-level sliding window on condition.
* Add test cases for detailsOnCondition.

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-10-25 16:03:07 +08:00
Eric Zhao b0905547ff Use ServiceLoaderUtil to create SPI ServiceLoader
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-10-23 19:20:53 +08:00
Eric Zhao 8d5654f727 Add ServiceLoaderUtil to improve SPI classloader mechanism and update SpiLoader
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-10-23 19:20:53 +08:00
wangyb dbf1f97dde Fix the cluster rule checking logic in FlowRuleUtil#checkClusterField() (#1105) 2019-10-22 20:28:21 +08:00
Eric Zhao 826447bc82
Fix the bug that resource name displayed in ClusterNode-related command APIs for SphU.entry(method) is incorrect (#1078)
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-10-11 15:15:07 +08:00
windWheel 4e55a6a749 Optimize the slot order in DefaultSlotChainBuilder (#1056) 2019-09-23 09:45:22 +08:00
Eric Zhao 8b40981fca
Improve SystemRuleManager and refactor checking logic of maxCpuUsage strategy (#1050)
- The BBR period for maxCpuUsage strategy is deprecated. Now Sentinel will just check the CPU usage value, which could avert surge of CPU usage quickly
- Improve SystemRuleManager and SystemStatusListener
- Add some test cases

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-09-19 16:36:12 +08:00
Eric Zhao 9ff6e47bb0
Add concrete exception message in AsyncEntry#cleanCurrentEntryInLocal (#1047)
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-09-19 09:38:07 +08:00
于玉桔 1253471078 Code refinement for JDK-picked classes (#1014) 2019-08-26 22:34:28 +08:00
aq0706 56c73698cb Support reading files with customized charset in ConfigUtil (#961) 2019-08-08 15:14:36 +08:00
Lin.Liang 61c8397e48 Fix temp file problem in log test cases (#908) 2019-07-16 09:41:44 +08:00
Lin.Liang 326dd4434d Fix the compatibility problem of ConfigUtil for Windows environment (#903) 2019-07-10 19:21:13 +08:00
Eric Zhao 90662a423b Code refinement for Sentinel config classes
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-07-08 23:06:07 +08:00
Lin.Liang ff33de199a Support arbitrary configuration properties file path for Sentinel (#804)
- Support customized log and configuration properties directory
2019-07-08 19:06:54 +08:00
yidadi c14e3296cb Refine the methods and variable name in SlotChainProvider (#871) 2019-06-27 16:50:43 +08:00
Braavos dca4440d40 Add unit tests for com.alibaba.csp.sentinel.eagleeye.EagleEyeCoreUtils (#854) 2019-06-24 09:28:08 +08:00
cdfive 8661d9abc1 Add support for logging into console for common logs (#836)
* Add a ConsoleHandler to support logging into stdout and stderr.
* Add a `csp.sentinel.log.output.type` property to configure for output type of record logs (only a temporary design)
* Add millisecond to the format of CspFormatter
2019-06-19 09:46:13 +08:00
Eric Zhao 00f116e344 Refine the DegradeRule and add validating logic for the two new attributes
- improvement of #789

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-06-17 20:38:02 +08:00
Lin.Liang 2eecd3ac6a Make the value of RT_MAX_EXCEED_N in DegradeRule configurable (#789)
- Add two attributes in DegradeRule: rtSlowRequestAmount and minRequestAmount
2019-06-14 17:42:03 +08:00
Lin.Liang e6e27c6faa Make maxParamByteSize configurable in ParamFlowRequestDataWriter of cluster client module and fix bugs (#823) 2019-06-13 22:38:26 +08:00
kexianjun 0176f0ead3 Use calculateTimeIdx to calculate array idx in LeapArray#getPreviousWindow (#723)
* also some code cleanup
2019-06-06 06:02:44 +08:00
Lin.Liang ee38587a6e Remove redundant operation when adding child node in NodeSelectorSlot (#794) 2019-06-04 18:02:43 +08:00
Lin.Liang 3a9e2629b7 Replace AtomicInteger with LongAdder for curThreadNum of StatisticNode (#747) 2019-06-04 17:51:36 +08:00
Eric Zhao f8ebbbccf4 Bump version to 1.7.0-SNAPSHOT
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-05-25 15:07:19 +08:00
Eric Zhao 3d2c33ef1d Bump version to 1.6.1 (release)
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-05-23 09:49:15 +08:00
Carpenter Lee f3e705c5f3 Add exceptionsToTrace and exceptionsToIgnore support in Tracer (#766)
Signed-off-by: Carpenter Lee <hooleeucas@163.com>
2019-05-22 10:06:03 +08:00
Eric Zhao 54da16d304 Refactor FlowRuleChecker to improve code reuse
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-05-22 09:47:41 +08:00
yikangfeng 4ec0462e31 Add getCpuUsageThreshold() method in SystemRuleManager (#770) 2019-05-21 16:00:46 +08:00
Carpenter Lee 18d8b4c8a7
Add CPU usage and system load to metric (#749)
Signed-off-by: Carpenter Lee <hooleeucas@163.com>
2019-05-10 14:20:00 +08:00
Eric Zhao 6e4560845c Update SENTINEL_VERSION constant to 1.6.1
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-05-06 13:46:03 +08:00
Carpenter Lee a2683383d1
[Feature]Add an extension to Sentinel internal statistics (#730)
Add Sentinel MetricExtension, which provides extension to Sentinel internal statistics.
This extension provides callbacks when a request passes rule checking, 
blocked by flow control, successfully end or exception occurred. 
Accompanied by these events, response time and current thread number 
will be recorded too.

Signed-off-by: Carpenter Lee <hooleeucas@163.com>
2019-05-06 10:55:42 +08:00
Jason Joo ecf4822ae1 Make SentinelConfig.loadProps() thread-safe using CopyOnWriteArraySet (#706) 2019-04-25 20:00:44 +08:00
Eric Zhao 346e9b274e Bump version to 1.6.1-SNAPSHOT
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-25 09:38:59 +08:00
Eric Zhao b1345f751f Bump version to 1.6.0 (release)
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-24 20:42:32 +08:00
Eric Zhao 82578e1fdf
Refactor and improve fallback support for @SentinelResource annotation (#693)
- Refactor the semantics and logic for blockHandler and fallback
- Add `fallbackClass` support for fallback in global classes
- Add `defaultFallback` support
- Update test cases and demo

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-23 23:17:03 +08:00
Eric Zhao bb4fde58b8 Add appType property field in SentinelConfig
- The `appType` can be retrieved from `csp.sentinel.app.type` field. It's useful to identify the service type (e.g. API gateway).

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-23 21:06:31 +08:00
Eric Zhao c316211faf Add loadInstanceList support for SpiLoader
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-22 11:13:38 +08:00
yikangfeng 08611fae0f Add exceptionsToIgnore configuration support in @SentinelResource annotation (#683) 2019-04-21 15:57:12 +08:00
zhaixiaoxiang cb9335126c test: Fix unstable test cases in OccupiableBucketLeapArrayTest (#687) 2019-04-20 22:28:38 +08:00
Eric Zhao 7d344dcb95 Improve AbstractTimeBasedTest in sentinel-core
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-20 21:04:20 +08:00
Eric Zhao 79211f055c Add @SpiOrder annotation and update SPI loader for loading SPI with highest precedence
Signed-off-by: Eric Zhao <sczyh16@gmail.com>
2019-04-17 14:47:09 +08:00
jason 73f166e258 Make ClusterNodeTest.testGetOrCreateOriginNodeMultiThread stable 2019-04-12 10:42:08 +08:00