use of com.alibaba.csp.sentinel.command.vo.NodeVo in project Sentinel by alibaba.
the class FetchJsonTreeCommandHandler method visit.
/**
* Preorder traversal.
*/
private void visit(DefaultNode node, List<NodeVo> results, String parentId) {
NodeVo vo = NodeVo.fromDefaultNode(node, parentId);
results.add(vo);
String id = vo.getId();
for (Node n : node.getChildList()) {
visit((DefaultNode) n, results, id);
}
}
use of com.alibaba.csp.sentinel.command.vo.NodeVo 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));
}
}
use of com.alibaba.csp.sentinel.command.vo.NodeVo in project Sentinel by alibaba.
the class ResourceVo method fromNodeVoList.
public static List<ResourceVo> fromNodeVoList(List<NodeVo> nodeVos) {
if (nodeVos == null) {
return null;
}
List<ResourceVo> list = new ArrayList<>();
for (NodeVo nodeVo : nodeVos) {
ResourceVo vo = new ResourceVo();
vo.parentTtId = nodeVo.getParentId();
vo.ttId = nodeVo.getId();
vo.resource = nodeVo.getResource();
vo.threadNum = nodeVo.getThreadNum();
vo.passQps = nodeVo.getPassQps();
vo.blockQps = nodeVo.getBlockQps();
vo.totalQps = nodeVo.getTotalQps();
vo.averageRt = nodeVo.getAverageRt();
vo.exceptionQps = nodeVo.getExceptionQps();
vo.oneMinutePass = nodeVo.getOneMinutePass();
vo.oneMinuteBlock = nodeVo.getOneMinuteBlock();
vo.oneMinuteException = nodeVo.getOneMinuteException();
vo.oneMinuteTotal = nodeVo.getOneMinuteTotal();
list.add(vo);
}
return list;
}
use of com.alibaba.csp.sentinel.command.vo.NodeVo in project pig by pig-mesh.
the class ResourceVo method fromNodeVoList.
public static List<ResourceVo> fromNodeVoList(List<NodeVo> nodeVos) {
if (nodeVos == null) {
return null;
}
List<ResourceVo> list = new ArrayList<>();
for (NodeVo nodeVo : nodeVos) {
ResourceVo vo = new ResourceVo();
vo.parentTtId = nodeVo.getParentId();
vo.ttId = nodeVo.getId();
vo.resource = nodeVo.getResource();
vo.threadNum = nodeVo.getThreadNum();
vo.passQps = nodeVo.getPassQps();
vo.blockQps = nodeVo.getBlockQps();
vo.totalQps = nodeVo.getTotalQps();
vo.averageRt = nodeVo.getAverageRt();
vo.exceptionQps = nodeVo.getExceptionQps();
vo.oneMinutePass = nodeVo.getOneMinutePass();
vo.oneMinuteBlock = nodeVo.getOneMinuteBlock();
vo.oneMinuteException = nodeVo.getOneMinuteException();
vo.oneMinuteTotal = nodeVo.getOneMinuteTotal();
list.add(vo);
}
return list;
}
use of com.alibaba.csp.sentinel.command.vo.NodeVo 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));
}
}
Aggregations