public class SphO extends Object
Rule's threshold is exceeded. Once blocked,
SphO#enter() 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 type,
int count,
Object... args)
Checking all
Rules about the protected method. |
static boolean |
entry(Method method,
int count)
Checking all
Rules about the protected method. |
static boolean |
entry(String name)
Checking all
Rules about the resource. |
static boolean |
entry(String name,
EntryType type)
Checking all
Rules about the resource. |
static boolean |
entry(String name,
EntryType type,
int count)
Checking all
Rules about the resource. |
static boolean |
entry(String name,
EntryType type,
int count,
Object... args)
Checking all
Rules about the resource. |
static boolean |
entry(String name,
int count)
Checking all
Rules about the resource. |
static void |
exit() |
static void |
exit(int count) |
static void |
exit(int count,
Object... args) |
public static boolean entry(String name)
Rules about the resource.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 count)
Rules about the protected method.method - the protected methodcount - tokens requiredpublic static boolean entry(String name, int count)
Rules about the resource.name - the unique string for the resourcecount - tokens requiredpublic 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)
Rules about the 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 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 - tokens requiredpublic static boolean entry(String name, EntryType type, int count)
Rules about the 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 by SystemRulecount - tokens requiredpublic static boolean entry(String name, EntryType type, int count, Object... args)
Rules about the 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 by SystemRulecount - tokens requiredargs - extra parameters.public static boolean entry(Method method, EntryType type, int count, Object... args)
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 - tokens requiredargs - the parameters of the method.public static void exit(int count,
Object... args)
public static void exit(int count)
public static void exit()
Copyright © 2019 Alibaba Group. All rights reserved.