类 SphO
java.lang.Object
com.alibaba.csp.sentinel.SphO
Conceptually, physical or logical resource that need protection should be
surrounded by an entry. The requests to this resource will be blocked if any
criteria is met, eg. when any
Rule's threshold is exceeded. Once blocked,
SphO#entry() will return false.
To configure the criteria, we can use XXXRuleManager.loadRules() to add rules. eg.
FlowRuleManager.loadRules(List), DegradeRuleManager.loadRules(List),
SystemRuleManager.loadRules(List).
Following code is an example. "abc" represent a unique name for the
protected resource:
public void foo() {
if (SphO.entry("abc")) {
try {
// business logic
} finally {
SphO.exit(); // must exit()
}
} else {
// failed to enter the protected resource.
}
}
Make sure SphO.entry() and exit() be paired in the same thread,
otherwise ErrorEntryFreeException will be thrown.- 作者:
- jialiang.linjl, leyou, Eric Zhao
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleanChecking allRules about the protected method.static booleanChecking allRules about the protected method.static booleanChecking allRules about the protected method.static booleanChecking allRules about the protected method.static booleanRecord statistics and perform rule checking for the given method resource.static booleanRecord statistics and perform rule checking for the given resource.static booleanRecord statistics and perform rule checking for the given resource.static booleanRecord statistics and perform rule checking for the given resource.static booleanRecord statistics and perform rule checking for the given resource.static booleanRecord statistics and perform rule checking for the given resource.static voidexit()static voidexit(int count) static void
-
构造器详细资料
-
SphO
public SphO()
-
-
方法详细资料
-
entry
Record statistics and perform rule checking for the given resource.- 参数:
name- the unique name of the protected resource- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Checking allRules about the protected method.- 参数:
method- the protected method- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Checking allRules about the protected method.- 参数:
method- the protected methodbatchCount- the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Record statistics and perform rule checking for the given resource.- 参数:
name- the unique string for the resourcebatchCount- the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Checking allRules about the protected method.- 参数:
method- the protected methodtype- the resource is an inbound or an outbound method. This is used to mark whether it can be blocked when the system is unstable, only inbound traffic could be blocked bySystemRule- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Record statistics and perform rule checking for the given resource.- 参数:
name- the unique name for the protected resourcetype- the resource is an inbound or an outbound method. This is used to mark whether it can be blocked when the system is unstable, only inbound traffic could be blocked bySystemRule- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Checking allRules about the protected method.- 参数:
method- the protected methodtype- the resource is an inbound or an outbound method. This is used to mark whether it can be blocked when the system is unstable, only inbound traffic could be blocked bySystemRulecount- the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Record statistics and perform rule checking for the given resource.- 参数:
name- the unique name for the protected resourcetype- the resource is an inbound or an outbound method. This is used to mark whether it can be blocked when the system is unstable, only inbound traffic could be blocked bySystemRulecount- the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Record statistics and perform rule checking for the given resource.- 参数:
name- the unique name for the protected resourcetrafficType- the traffic type (inbound, outbound or internal). This is used to mark whether it can be blocked when the system is unstable, only inbound traffic could be blocked bySystemRulebatchCount- the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)args- args for parameter flow control or customized slots- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
entry
Record statistics and perform rule checking for the given method resource.- 参数:
method- the protected methodtrafficType- the traffic type (inbound, outbound or internal). This is used to mark whether it can be blocked when the system is unstable, only inbound traffic could be blocked bySystemRulebatchCount- the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)args- args for parameter flow control or customized slots- 返回:
- true if no rule's threshold is exceeded, otherwise return false.
-
exit
-
exit
public static void exit(int count) -
exit
public static void exit()
-