All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.taobao.csp.sentinel.SphO Maven / Gradle / Ivy

There is a newer version: 1.8.3
Show newest version
/**
 * 
 */
package com.taobao.csp.sentinel;

import java.lang.reflect.Method;

import com.taobao.csp.courier.RecordLog;
import com.taobao.csp.sentinel.context.ContextUtil;
import com.taobao.csp.sentinel.slotchain.ResourceWraper;
import com.taobao.csp.sentinel.slots.block.BlockException;

/**
 * @author [email protected] 2014��5��30��
 * @author [email protected]
 * @author jialiang.linjl([email protected]
 */
public class SphO {
  
    public static boolean entry(Method m, NodeType type, Object... args) {
        try {
            Env.sph.entry(m, type, args);
        } catch (BlockException e) {
            return false;
        } catch (Throwable e) {
            RecordLog.info("[sentinel] fatal error", e);
            return true;
        }
        return true;
    }


    
    public static boolean entry(Method m) {
        return entry(m, NodeType.CUSTOM, new Object[0]);
    }

    public static boolean entry(Method m, Object... args) {
        return entry(m, NodeType.CUSTOM,  args);
    }

    public static boolean entry(String s, NodeType type, Object... args) {
        try {
            Env.sph.entry(s, type, args);
        } catch (BlockException e) {
            return false;
        } catch (Throwable e) {
            RecordLog.info("[sentinel] fatal error", e);
            return true;
        }
        return true;
    }



    public static boolean entry(String s) {
        return entry(s, NodeType.CUSTOM,  new Object[0]);
    }

    public static boolean entry(String s, NodeType nodeType) {
        return entry(s, nodeType,  new Object[0]);
    }

    public static boolean entry(String s, Object... args) {
        return entry(s, NodeType.CUSTOM,  args);
    }

    public static boolean entry(ResourceWraper resourceWraper, Object... args) {
        try {
            Env.sph.entry(resourceWraper, args);
        } catch (BlockException e) {
            return false;
        } catch (Throwable e) {
            RecordLog.info("[sentinel] fatal error", e);
            return true;
        }
        return true;
    }

    public static boolean entry(ResourceWraper resourceWraper) {

        return entry(resourceWraper, new Object[0]);
    }

    public static void exit(Object... args) {
        ContextUtil.getContext().getCurEntry().exit(args);
    }

    public static void exit() {
        ContextUtil.getContext().getCurEntry().exit(new Object[0]);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy