public class SphO extends Object
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.SphU| Constructor and Description |
|---|
SphO() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
entry(Method method)
Checking all
Rules about the protected method. |
static boolean |
entry(Method method,
EntryType type)
Checking all
Rules about the protected method. |
static boolean |
entry(Method method,
EntryType type,
int count)
Checking all
Rules about the protected method. |
static boolean |
entry(Method method,
EntryType trafficType,
int batchCount,
Object... args)
Record statistics and perform rule checking for the given method resource.
|
static boolean |
entry(Method method,
int batchCount)
Checking all
Rules about the protected method. |
static boolean |
entry(String name)
Record statistics and perform rule checking for the given resource.
|
static boolean |
entry(String name,
EntryType type)
Record statistics and perform rule checking for the given resource.
|
static boolean |
entry(String name,
EntryType type,
int count)
Record statistics and perform rule checking for the given resource.
|
static boolean |
entry(String name,
EntryType trafficType,
int batchCount,
Object... args)
Record statistics and perform rule checking for the given resource.
|
static boolean |
entry(String name,
int batchCount)
Record statistics and perform rule checking for the given resource.
|
static void |
exit() |
static void |
exit(int count) |
static void |
exit(int count,
Object... args) |
public static boolean entry(String name)
name - the unique name of the protected resourcepublic static boolean entry(Method method)
Rules about the protected method.method - the protected methodpublic static boolean entry(Method method, int batchCount)
Rules about the protected method.method - the protected methodbatchCount - the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)public static boolean entry(String name, int batchCount)
name - the unique string for the resourcebatchCount - the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)public static boolean entry(Method method, EntryType type)
Rules 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 by SystemRulepublic static boolean entry(String name, EntryType type)
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 by SystemRulepublic static boolean entry(Method method, EntryType type, int count)
Rules 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 by SystemRulecount - the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)public static boolean entry(String name, EntryType type, int count)
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 by SystemRulecount - the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)public static boolean entry(String name, EntryType trafficType, int batchCount, Object... args)
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 by SystemRulebatchCount - the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)args - args for parameter flow control or customized slotspublic static boolean entry(Method method, EntryType trafficType, int batchCount, Object... args)
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 by SystemRulebatchCount - the amount of calls within the invocation (e.g. batchCount=2 means request for 2 tokens)args - args for parameter flow control or customized slotspublic static void exit(int count,
Object... args)
public static void exit(int count)
public static void exit()
Copyright © 2021 Alibaba Group. All rights reserved.