/** * Checking all {@link Rule}s about the protected method. * * @param method the protected method * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded. */ public static Entry entry(Method method) throws BlockException { return Env.sph.entry(method, EntryType.OUT, 1, OBJECTS0); }
/** * Checking all {@link Rule}s about the protected method. * * @param method the protected method * @param count tokens required * @return true if no rule's threshold is exceeded, otherwise return false. */ public static boolean entry(Method method, int count) { return entry(method, EntryType.OUT, count, OBJECTS0); }
@Override protected Entry trueExit(int count, Object... args) throws ErrorEntryFreeException { exitForContext(context, count, args); return parent; }
/** * Trace provided {@link Throwable} and increment exception count to entry in current context. * * @param e exception to record */ public static void trace(Throwable e) { trace(e, 1); }
private AsyncEntry asyncEntryWithNoChain(ResourceWrapper resourceWrapper, Context context) { AsyncEntry entry = new AsyncEntry(resourceWrapper, null, context); entry.initAsyncContext(); // The async entry will be removed from current context as soon as it has been created. entry.cleanCurrentEntryInLocal(); return entry; }
@Override protected Entry trueExit(int count, Object... args) throws ErrorEntryFreeException { exitForContext(asyncContext, count, args); return parent; } }
@Override public Node getLastNode() { return parent == null ? null : parent.getCurNode(); } }
/** * Trace provided {@link Throwable} and increment exception count to provided entry. * * @param e exception to record * @since 1.4.2 */ public static void traceEntry(Throwable e, Entry entry) { traceEntry(e, 1, entry); }
/** * Checking all {@link Rule}s related the resource. The entry is prioritized. * * @param name the unique name for the protected resource * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded. * @since 1.4.0 */ public static Entry entryWithPriority(String name) throws BlockException { return Env.sph.entryWithPriority(name, EntryType.OUT, 1, true); }
/** * Get the parent {@link Node} of the current. * * @return the parent node of the current. */ public Node getLastNode() { if (curEntry != null && curEntry.getLastNode() != null) { return curEntry.getLastNode(); } else { return entranceNode; } }
@Override protected void clearEntryContext() { super.clearEntryContext(); this.asyncContext = null; }
/** * Checking all rules about the asynchronous resource. * * @param name the unique name of the protected resource * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded * @since 0.2.0 */ public static AsyncEntry asyncEntry(String name) throws BlockException { return Env.sph.asyncEntry(name, EntryType.OUT, 1, OBJECTS0); }
/** * Checking all {@link Rule}s about the resource. * * @param name the unique name for the protected resource * @param type 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 {@link SystemRule} * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded. */ public static Entry entry(String name, EntryType type) throws BlockException { return Env.sph.entry(name, type, 1, OBJECTS0); }
/** * Checking all {@link Rule}s about the resource. * * @param name the unique name of the protected resource * @return true if no rule's threshold is exceeded, otherwise return false. */ public static boolean entry(String name) { return entry(name, EntryType.OUT, 1, OBJECTS0); }
/** * Checking all {@link Rule}s about the resource. * * @param name the unique string for the resource * @param count tokens required * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded. */ public static Entry entry(String name, int count) throws BlockException { return Env.sph.entry(name, EntryType.OUT, count, OBJECTS0); }
/** * Checking all {@link Rule}s about the resource. * * @param name the unique string for the resource * @param count tokens required * @return true if no rule's threshold is exceeded, otherwise return false. */ public static boolean entry(String name, int count) { return entry(name, EntryType.OUT, count, OBJECTS0); }
/** * Checking all {@link Rule}s about the resource. * * @param name the unique name of the protected resource * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded. */ public static Entry entry(String name) throws BlockException { return Env.sph.entry(name, EntryType.OUT, 1, OBJECTS0); }
/** * Checking all {@link Rule}s about the protected method. * * @param method the protected method * @param type 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 {@link SystemRule} * @return true if no rule's threshold is exceeded, otherwise return false. */ public static boolean entry(Method method, EntryType type) { return entry(method, type, 1, OBJECTS0); }
/** * Checking all {@link Rule}s about the protected method. * * @param method the protected method * @param count tokens required * @throws BlockException if the block criteria is met, eg. when any rule's threshold is exceeded. */ public static Entry entry(Method method, int count) throws BlockException { return Env.sph.entry(method, EntryType.OUT, count, OBJECTS0); }
/** * Checking all {@link Rule}s about the resource. * * @param name the unique name for the protected resource * @param type 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 {@link SystemRule} * @return true if no rule's threshold is exceeded, otherwise return false. */ public static boolean entry(String name, EntryType type) { return entry(name, type, 1, OBJECTS0); }