Java Code Examples for com.alibaba.csp.sentinel.node.DefaultNode#blockRequest()

The following examples show how to use com.alibaba.csp.sentinel.node.DefaultNode#blockRequest() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NodeVo.java    From Sentinel-Dashboard-Nacos with Apache License 2.0 6 votes vote down vote up
/**
 * {@link DefaultNode} holds statistics of every node in the invoke tree.
 * We use parentId to hold the tree structure.
 *
 * @param node     the DefaultNode to be presented.
 * @param parentId random generated parent node id, may be a random UUID
 * @return node view object.
 */
public static NodeVo fromDefaultNode(DefaultNode node, String parentId) {
    if (node == null) {
        return null;
    }
    NodeVo vo = new NodeVo();
    vo.id = UUID.randomUUID().toString();
    vo.parentId = parentId;
    vo.resource = node.getId().getShowName();
    vo.threadNum = node.curThreadNum();
    vo.passQps = (long) node.passQps();
    vo.blockQps = (long) node.blockQps();
    vo.totalQps = (long) node.totalQps();
    vo.averageRt = (long) node.avgRt();
    vo.successQps = (long) node.successQps();
    vo.exceptionQps = (long) node.exceptionQps();
    vo.oneMinuteException = node.totalException();
    vo.oneMinutePass = node.totalRequest() - node.blockRequest();
    vo.oneMinuteBlock = node.blockRequest();
    vo.oneMinuteTotal = node.totalRequest();
    vo.timestamp = System.currentTimeMillis();
    return vo;
}
 
Example 2
Source File: NodeVo.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
/**
 * {@link DefaultNode} holds statistics of every node in the invoke tree.
 * We use parentId to hold the tree structure.
 *
 * @param node     the DefaultNode to be presented.
 * @param parentId random generated parent node id, may be a random UUID
 * @return node view object.
 */
public static NodeVo fromDefaultNode(DefaultNode node, String parentId) {
    if (node == null) {
        return null;
    }
    NodeVo vo = new NodeVo();
    vo.id = UUID.randomUUID().toString();
    vo.parentId = parentId;
    vo.resource = node.getId().getShowName();
    vo.threadNum = node.curThreadNum();
    vo.passQps = (long) node.passQps();
    vo.blockQps = (long) node.blockQps();
    vo.totalQps = (long) node.totalQps();
    vo.averageRt = (long) node.avgRt();
    vo.successQps = (long) node.successQps();
    vo.exceptionQps = (long) node.exceptionQps();
    vo.oneMinuteException = node.totalException();
    vo.oneMinutePass = node.totalRequest() - node.blockRequest();
    vo.oneMinuteBlock = node.blockRequest();
    vo.oneMinuteTotal = node.totalRequest();
    vo.timestamp = System.currentTimeMillis();
    return vo;
}