Search in sources :

Example 1 with ResourceTreeNode

use of com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode in project Sentinel by alibaba.

the class ResourceController method fetchResourceChainListOfMachine.

/**
 * Fetch real time statistics info of the machine.
 *
 * @param ip        ip to fetch
 * @param port      port of the ip
 * @param type      one of [root, default, cluster], 'root' means fetching from tree root node, 'default' means
 *                  fetching from tree default node, 'cluster' means fetching from cluster node.
 * @param searchKey key to search
 * @return node statistics info.
 */
@GetMapping("/machineResource.json")
public Result<List<ResourceVo>> fetchResourceChainListOfMachine(String ip, Integer port, String type, String searchKey) {
    if (StringUtil.isEmpty(ip) || port == null) {
        return Result.ofFail(-1, "invalid param, give ip, port");
    }
    final String ROOT = "root";
    final String DEFAULT = "default";
    if (StringUtil.isEmpty(type)) {
        type = ROOT;
    }
    if (ROOT.equalsIgnoreCase(type) || DEFAULT.equalsIgnoreCase(type)) {
        List<NodeVo> nodeVos = httpFetcher.fetchResourceOfMachine(ip, port, type);
        if (nodeVos == null) {
            return Result.ofSuccess(null);
        }
        ResourceTreeNode treeNode = ResourceTreeNode.fromNodeVoList(nodeVos);
        treeNode.searchIgnoreCase(searchKey);
        return Result.ofSuccess(ResourceVo.fromResourceTreeNode(treeNode));
    } else {
        // Normal (cluster node).
        List<NodeVo> nodeVos = httpFetcher.fetchClusterNodeOfMachine(ip, port, true);
        if (nodeVos == null) {
            return Result.ofSuccess(null);
        }
        if (StringUtil.isNotEmpty(searchKey)) {
            nodeVos = nodeVos.stream().filter(node -> node.getResource().toLowerCase().contains(searchKey.toLowerCase())).collect(Collectors.toList());
        }
        return Result.ofSuccess(ResourceVo.fromNodeVoList(nodeVos));
    }
}
Also used : NodeVo(com.alibaba.csp.sentinel.command.vo.NodeVo) ResourceTreeNode(com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with ResourceTreeNode

use of com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode in project spring-boot-student by wyh-spring-ecosystem-student.

the class ResourceController method fetchResourceChainListOfMachine.

/**
 * Fetch real time statistics info of the machine.
 *
 * @param ip        ip to fetch
 * @param port      port of the ip
 * @param type      one of [root, default, cluster], 'root' means fetching from tree root node, 'default' means
 *                  fetching from tree default node, 'cluster' means fetching from cluster node.
 * @param searchKey key to search
 * @return node statistics info.
 */
@GetMapping("/machineResource.json")
public Result<List<ResourceVo>> fetchResourceChainListOfMachine(String ip, Integer port, String type, String searchKey) {
    if (StringUtil.isEmpty(ip) || port == null) {
        return Result.ofFail(-1, "invalid param, give ip, port");
    }
    final String ROOT = "root";
    final String DEFAULT = "default";
    if (StringUtil.isEmpty(type)) {
        type = ROOT;
    }
    if (ROOT.equalsIgnoreCase(type) || DEFAULT.equalsIgnoreCase(type)) {
        List<NodeVo> nodeVos = httpFetcher.fetchResourceOfMachine(ip, port, type);
        if (nodeVos == null) {
            return Result.ofSuccess(null);
        }
        ResourceTreeNode treeNode = ResourceTreeNode.fromNodeVoList(nodeVos);
        treeNode.searchIgnoreCase(searchKey);
        return Result.ofSuccess(ResourceVo.fromResourceTreeNode(treeNode));
    } else {
        // Normal (cluster node).
        List<NodeVo> nodeVos = httpFetcher.fetchClusterNodeOfMachine(ip, port, true);
        if (nodeVos == null) {
            return Result.ofSuccess(null);
        }
        if (StringUtil.isNotEmpty(searchKey)) {
            nodeVos = nodeVos.stream().filter(node -> node.getResource().toLowerCase().contains(searchKey.toLowerCase())).collect(Collectors.toList());
        }
        return Result.ofSuccess(ResourceVo.fromNodeVoList(nodeVos));
    }
}
Also used : NodeVo(com.alibaba.csp.sentinel.command.vo.NodeVo) ResourceTreeNode(com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with ResourceTreeNode

use of com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode in project XHuiCloud by sindaZeng.

the class ResourceController method fetchResourceChainListOfMachine.

/**
 * Fetch real time statistics info of the machine.
 *
 * @param ip        ip to fetch
 * @param port      port of the ip
 * @param type      one of [root, default, cluster], 'root' means fetching from tree root node, 'default' means
 *                  fetching from tree default node, 'cluster' means fetching from cluster node.
 * @param searchKey key to search
 * @return node statistics info.
 */
@GetMapping("/machineResource.json")
public Result<List<ResourceVo>> fetchResourceChainListOfMachine(String ip, Integer port, String type, String searchKey) {
    if (StringUtil.isEmpty(ip) || port == null) {
        return Result.ofFail(-1, "invalid param, give ip, port");
    }
    final String ROOT = "root";
    final String DEFAULT = "default";
    if (StringUtil.isEmpty(type)) {
        type = ROOT;
    }
    if (ROOT.equalsIgnoreCase(type) || DEFAULT.equalsIgnoreCase(type)) {
        List<NodeVo> nodeVos = httpFetcher.fetchResourceOfMachine(ip, port, type);
        if (nodeVos == null) {
            return Result.ofSuccess(null);
        }
        ResourceTreeNode treeNode = ResourceTreeNode.fromNodeVoList(nodeVos);
        treeNode.searchIgnoreCase(searchKey);
        return Result.ofSuccess(ResourceVo.fromResourceTreeNode(treeNode));
    } else {
        // Normal (cluster node).
        List<NodeVo> nodeVos = httpFetcher.fetchClusterNodeOfMachine(ip, port, true);
        if (nodeVos == null) {
            return Result.ofSuccess(null);
        }
        if (StringUtil.isNotEmpty(searchKey)) {
            nodeVos = nodeVos.stream().filter(node -> node.getResource().toLowerCase().contains(searchKey.toLowerCase())).collect(Collectors.toList());
        }
        return Result.ofSuccess(ResourceVo.fromNodeVoList(nodeVos));
    }
}
Also used : NodeVo(com.alibaba.csp.sentinel.command.vo.NodeVo) ResourceTreeNode(com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with ResourceTreeNode

use of com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode in project XHuiCloud by sindaZeng.

the class ResourceVo method visit.

/**
 * This node is visible when this.visible==true or one of this's parents is visible,
 * root node is always invisible.
 */
private static void visit(ResourceTreeNode node, List<ResourceVo> list, boolean parentVisible, boolean isRoot) {
    boolean visible = !isRoot && (node.isVisible() || parentVisible);
    // boolean visible = node.isVisible();
    if (visible) {
        ResourceVo vo = new ResourceVo();
        vo.parentTtId = node.getParentId();
        vo.ttId = node.getId();
        vo.resource = node.getResource();
        vo.threadNum = node.getThreadNum();
        vo.passQps = node.getPassQps();
        vo.blockQps = node.getBlockQps();
        vo.totalQps = node.getTotalQps();
        vo.averageRt = node.getAverageRt();
        vo.exceptionQps = node.getExceptionQps();
        vo.oneMinutePass = node.getOneMinutePass();
        vo.oneMinuteBlock = node.getOneMinuteBlock();
        vo.oneMinuteException = node.getOneMinuteException();
        vo.oneMinuteTotal = node.getOneMinuteTotal();
        vo.visible = node.isVisible();
        list.add(vo);
    }
    for (ResourceTreeNode c : node.getChildren()) {
        visit(c, list, visible, false);
    }
}
Also used : ResourceTreeNode(com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode)

Example 5 with ResourceTreeNode

use of com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode in project RuoYi-Cloud-Plus by JavaLionLi.

the class ResourceVo method visit.

/**
 * This node is visible when this.visible==true or one of this's parents is visible,
 * root node is always invisible.
 */
private static void visit(ResourceTreeNode node, List<ResourceVo> list, boolean parentVisible, boolean isRoot) {
    boolean visible = !isRoot && (node.isVisible() || parentVisible);
    // boolean visible = node.isVisible();
    if (visible) {
        ResourceVo vo = new ResourceVo();
        vo.parentTtId = node.getParentId();
        vo.ttId = node.getId();
        vo.resource = node.getResource();
        vo.threadNum = node.getThreadNum();
        vo.passQps = node.getPassQps();
        vo.blockQps = node.getBlockQps();
        vo.totalQps = node.getTotalQps();
        vo.averageRt = node.getAverageRt();
        vo.exceptionQps = node.getExceptionQps();
        vo.oneMinutePass = node.getOneMinutePass();
        vo.oneMinuteBlock = node.getOneMinuteBlock();
        vo.oneMinuteException = node.getOneMinuteException();
        vo.oneMinuteTotal = node.getOneMinuteTotal();
        vo.visible = node.isVisible();
        list.add(vo);
    }
    for (ResourceTreeNode c : node.getChildren()) {
        visit(c, list, visible, false);
    }
}
Also used : ResourceTreeNode(com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode)

Aggregations

ResourceTreeNode (com.alibaba.csp.sentinel.dashboard.domain.ResourceTreeNode)10 NodeVo (com.alibaba.csp.sentinel.command.vo.NodeVo)5 GetMapping (org.springframework.web.bind.annotation.GetMapping)5