From 03922dbf6c72217d4c64cc7bf47e098d3638a50a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=B1=AA?= Date: Thu, 11 Oct 2018 09:28:43 +0800 Subject: [PATCH] Enhancement/normalize metric field (#170) normalize metric fields and methods: - rename exception to exceptionQps; - remove ed postfix of all fields and methods about metrics; --- .../SentinelGrpcClientInterceptorTest.java | 6 +- .../SentinelGrpcServerInterceptorTest.java | 6 +- .../alibaba/csp/sentinel/context/Context.java | 12 ++-- .../csp/sentinel/node/DefaultNode.java | 14 ++-- .../csp/sentinel/node/EntranceNode.java | 8 +-- .../com/alibaba/csp/sentinel/node/Node.java | 16 ++--- .../csp/sentinel/node/StatisticNode.java | 14 ++-- .../csp/sentinel/node/metric/MetricNode.java | 64 +++++++++---------- .../slots/statistic/StatisticSlot.java | 6 +- .../slots/statistic/metric/ArrayMetric.java | 6 +- .../datasource/entity/MetricEntity.java | 59 ++++++++--------- .../dashboard/domain/ResourceTreeNode.java | 36 +++++------ .../dashboard/metric/MetricFetcher.java | 12 ++-- .../metric/InMemoryMetricsRepository.java | 10 +-- .../sentinel/dashboard/view/vo/MetricVo.java | 60 ++++++++--------- .../dashboard/view/vo/ResourceVo.java | 42 ++++++------ .../app/scripts/controllers/metric.js | 22 +++---- .../webapp/resources/app/views/identity.html | 8 +-- .../webapp/resources/app/views/metric.html | 4 +- .../FetchClusterNodeHumanCommandHandler.java | 4 +- .../handler/FetchOriginCommandHandler.java | 8 +-- .../FetchSystemStatusCommandHandler.java | 2 +- .../handler/FetchTreeCommandHandler.java | 12 ++-- .../csp/sentinel/command/vo/NodeVo.java | 42 ++++++------ 24 files changed, 235 insertions(+), 238 deletions(-) diff --git a/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcClientInterceptorTest.java b/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcClientInterceptorTest.java index 61fa180e..7c6972e6 100755 --- a/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcClientInterceptorTest.java +++ b/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcClientInterceptorTest.java @@ -66,14 +66,14 @@ public class SentinelGrpcClientInterceptorTest { ClusterNode clusterNode = ClusterBuilderSlot.getClusterNode(resourceName, EntryType.OUT); assertNotNull(clusterNode); - assertEquals((total - threshold) / 2, clusterNode.blockedRequest()); + assertEquals((total - threshold) / 2, clusterNode.blockRequest()); assertEquals(total / 2, clusterNode.totalRequest()); long totalQps = clusterNode.totalQps(); long passQps = clusterNode.passQps(); - long blockedQps = clusterNode.blockedQps(); + long blockQps = clusterNode.blockQps(); assertEquals(total, totalQps); - assertEquals(total - threshold, blockedQps); + assertEquals(total - threshold, blockQps); assertEquals(threshold, passQps); server.stop(); diff --git a/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcServerInterceptorTest.java b/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcServerInterceptorTest.java index d924742c..432a6281 100755 --- a/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcServerInterceptorTest.java +++ b/sentinel-adapter/sentinel-grpc-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/grpc/SentinelGrpcServerInterceptorTest.java @@ -68,14 +68,14 @@ public class SentinelGrpcServerInterceptorTest { ClusterNode clusterNode = ClusterBuilderSlot.getClusterNode(resourceName, EntryType.IN); assertNotNull(clusterNode); - assertEquals((total - threshold) / 2, clusterNode.blockedRequest()); + assertEquals((total - threshold) / 2, clusterNode.blockRequest()); assertEquals(total / 2, clusterNode.totalRequest()); long totalQps = clusterNode.totalQps(); long passQps = clusterNode.passQps(); - long blockedQps = clusterNode.blockedQps(); + long blockQps = clusterNode.blockQps(); assertEquals(total, totalQps); - assertEquals(total - threshold, blockedQps); + assertEquals(total - threshold, blockQps); assertEquals(threshold, passQps); server.stop(); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/Context.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/Context.java index cd04899a..0e857b72 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/Context.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/Context.java @@ -139,15 +139,15 @@ public class Context { return getOriginNode() == null ? 0 : getOriginNode().totalQps(); } - public double getOriginBlockedQps() { - return getOriginNode() == null ? 0 : getOriginNode().blockedQps(); + public double getOriginBlockQps() { + return getOriginNode() == null ? 0 : getOriginNode().blockQps(); } - public double getOriginPassedReqQps() { + public double getOriginPassReqQps() { return getOriginNode() == null ? 0 : getOriginNode().successQps(); } - public double getOriginPassedQps() { + public double getOriginPassQps() { return getOriginNode() == null ? 0 : getOriginNode().passQps(); } @@ -155,8 +155,8 @@ public class Context { return getOriginNode() == null ? 0 : getOriginNode().totalRequest(); } - public long getOriginBlockedRequest() { - return getOriginNode() == null ? 0 : getOriginNode().blockedRequest(); + public long getOriginBlockRequest() { + return getOriginNode() == null ? 0 : getOriginNode().blockRequest(); } public double getOriginAvgRt() { diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/DefaultNode.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/DefaultNode.java index 46383580..521c7e60 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/DefaultNode.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/DefaultNode.java @@ -88,9 +88,9 @@ public class DefaultNode extends StatisticNode { } @Override - public void increaseBlockedQps() { - super.increaseBlockedQps(); - this.clusterNode.increaseBlockedQps(); + public void increaseBlockQps() { + super.increaseBlockQps(); + this.clusterNode.increaseBlockQps(); } @Override @@ -134,13 +134,13 @@ public class DefaultNode extends StatisticNode { if (!(node instanceof EntranceNode)) { System.out.println( String.format("%s(thread:%s pq:%s bq:%s tq:%s rt:%s 1mp:%s 1mb:%s 1mt:%s)", node.id.getShowName(), - node.curThreadNum(), node.passQps(), node.blockedQps(), node.totalQps(), node.avgRt(), - node.totalRequest() - node.blockedRequest(), node.blockedRequest(), node.totalRequest())); + node.curThreadNum(), node.passQps(), node.blockQps(), node.totalQps(), node.avgRt(), + node.totalRequest() - node.blockRequest(), node.blockRequest(), node.totalRequest())); } else { System.out.println( String.format("Entry-%s(t:%s pq:%s bq:%s tq:%s rt:%s 1mp:%s 1mb:%s 1mt:%s)", node.id.getShowName(), - node.curThreadNum(), node.passQps(), node.blockedQps(), node.totalQps(), node.avgRt(), - node.totalRequest() - node.blockedRequest(), node.blockedRequest(), node.totalRequest())); + node.curThreadNum(), node.passQps(), node.blockQps(), node.totalQps(), node.avgRt(), + node.totalRequest() - node.blockRequest(), node.blockRequest(), node.totalRequest())); } for (Node n : node.getChildList()) { DefaultNode dn = (DefaultNode)n; diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/EntranceNode.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/EntranceNode.java index cf94b197..e379daf4 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/EntranceNode.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/EntranceNode.java @@ -54,19 +54,19 @@ public class EntranceNode extends DefaultNode { } @Override - public long blockedQps() { + public long blockQps() { int blockQps = 0; for (Node node : getChildList()) { - blockQps += node.blockedQps(); + blockQps += node.blockQps(); } return blockQps; } @Override - public long blockedRequest() { + public long blockRequest() { long r = 0; for (Node node : getChildList()) { - r += node.blockedRequest(); + r += node.blockRequest(); } return r; } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java index ecd7b018..ff82a41c 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java @@ -29,7 +29,7 @@ import com.alibaba.csp.sentinel.node.metric.MetricNode; public interface Node { /** - * Get incoming request per minute. {@code pass + blocked} + * Get incoming request per minute. {@code pass + block} */ long totalRequest(); @@ -41,9 +41,9 @@ public interface Node { long totalSuccess(); /** - * Get blocked request count per minute. + * Get block request count per minute. */ - long blockedRequest(); + long blockRequest(); /** * Get exception count per minute. @@ -56,12 +56,12 @@ public interface Node { long passQps(); /** - * Get blocked request per second. + * Get block request per second. */ - long blockedQps(); + long blockQps(); /** - * Get {@link #passQps()} + {@link #blockedQps()} request per second. + * Get {@link #passQps()} + {@link #blockQps()} request per second. */ long totalQps(); @@ -90,7 +90,7 @@ public interface Node { int curThreadNum(); /** - * Get last second blocked QPS. + * Get last second block QPS. */ long previousBlockQps(); @@ -110,7 +110,7 @@ public interface Node { */ void rt(long rt); - void increaseBlockedQps(); + void increaseBlockQps(); void increaseExceptionQps(); diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/StatisticNode.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/StatisticNode.java index 4158262b..3c504bb6 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/StatisticNode.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/StatisticNode.java @@ -53,10 +53,10 @@ public class StatisticNode implements Node { long newLastFetchTime = lastFetchTime; for (MetricNode node : nodesOfEverySecond) { if (node.getTimestamp() > lastFetchTime && node.getTimestamp() < currentTime) { - if (node.getPassedQps() != 0 - || node.getBlockedQps() != 0 + if (node.getPassQps() != 0 + || node.getBlockQps() != 0 || node.getSuccessQps() != 0 - || node.getException() != 0 + || node.getExceptionQps() != 0 || node.getRt() != 0) { metrics.put(node.getTimestamp(), node); newLastFetchTime = Math.max(newLastFetchTime, node.getTimestamp()); @@ -80,12 +80,12 @@ public class StatisticNode implements Node { } @Override - public long blockedRequest() { + public long blockRequest() { return rollingCounterInMinute.block() / 2; } @Override - public long blockedQps() { + public long blockQps() { return rollingCounterInSecond.block() / IntervalProperty.INTERVAL; } @@ -101,7 +101,7 @@ public class StatisticNode implements Node { @Override public long totalQps() { - return passQps() + blockedQps(); + return passQps() + blockQps(); } @Override @@ -170,7 +170,7 @@ public class StatisticNode implements Node { } @Override - public void increaseBlockedQps() { + public void increaseBlockQps() { rollingCounterInSecond.addBlock(); rollingCounterInMinute.addBlock(); } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricNode.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricNode.java index ef0171e9..682debf1 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricNode.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricNode.java @@ -22,10 +22,10 @@ import java.util.Date; public class MetricNode { private long timestamp; - private long passedQps; - private long blockedQps; + private long passQps; + private long blockQps; private long successQps; - private long exception; + private long exceptionQps; private long rt; private String resource; @@ -46,28 +46,28 @@ public class MetricNode { this.successQps = successQps; } - public long getPassedQps() { - return passedQps; + public long getPassQps() { + return passQps; } - public void setPassedQps(long passedQps) { - this.passedQps = passedQps; + public void setPassQps(long passQps) { + this.passQps = passQps; } - public long getException() { - return exception; + public long getExceptionQps() { + return exceptionQps; } - public void setException(long exception) { - this.exception = exception; + public void setExceptionQps(long exceptionQps) { + this.exceptionQps = exceptionQps; } - public long getBlockedQps() { - return blockedQps; + public long getBlockQps() { + return blockQps; } - public void setBlockedQps(long blockedQps) { - this.blockedQps = blockedQps; + public void setBlockQps(long blockQps) { + this.blockQps = blockQps; } public long getRt() { @@ -90,10 +90,10 @@ public class MetricNode { public String toString() { return "MetricNode{" + "timestamp=" + timestamp + - ", passedQps=" + passedQps + - ", blockedQs=" + blockedQps + + ", passQps=" + passQps + + ", blockQps=" + blockQps + ", successQps=" + successQps + - ", exception=" + exception + + ", exceptionQps=" + exceptionQps + ", rt=" + rt + ", resource='" + resource + '\'' + '}'; @@ -103,7 +103,7 @@ public class MetricNode { * To formatting string. All "|" in {@link #resource} will be replaced with "_", format is: *
* - * timestamp|resource|passedQps|blockedQps|successQps|exception|rt + * timestamp|resource|passQps|blockQps|successQps|exceptionQps|rt * * * @return string format of this. @@ -113,10 +113,10 @@ public class MetricNode { sb.append(timestamp).append("|"); String legalName = resource.replaceAll("\\|", "_"); sb.append(legalName).append("|"); - sb.append(passedQps).append("|"); - sb.append(blockedQps).append("|"); + sb.append(passQps).append("|"); + sb.append(blockQps).append("|"); sb.append(successQps).append("|"); - sb.append(exception).append("|"); + sb.append(exceptionQps).append("|"); sb.append(rt); return sb.toString(); } @@ -132,10 +132,10 @@ public class MetricNode { String[] strs = line.split("\\|"); node.setTimestamp(Long.parseLong(strs[0])); node.setResource(strs[1]); - node.setPassedQps(Long.parseLong(strs[2])); - node.setBlockedQps(Long.parseLong(strs[3])); + node.setPassQps(Long.parseLong(strs[2])); + node.setBlockQps(Long.parseLong(strs[3])); node.setSuccessQps(Long.parseLong(strs[4])); - node.setException(Long.parseLong(strs[5])); + node.setExceptionQps(Long.parseLong(strs[5])); node.setRt(Long.parseLong(strs[6])); return node; } @@ -144,7 +144,7 @@ public class MetricNode { * To formatting string. All "|" in {@link MetricNode#resource} will be replaced with "_", format is: *
* - * timestamp|yyyy-MM-dd HH:mm:ss|resource|passedQps|blockedQps|successQps|exception|rt\n + * timestamp|yyyy-MM-dd HH:mm:ss|resource|passQps|blockQps|successQps|exceptionQps|rt\n * * * @return string format of this. @@ -157,10 +157,10 @@ public class MetricNode { sb.append(df.format(new Date(getTimestamp()))).append("|"); String legalName = getResource().replaceAll("\\|", "_"); sb.append(legalName).append("|"); - sb.append(getPassedQps()).append("|"); - sb.append(getBlockedQps()).append("|"); + sb.append(getPassQps()).append("|"); + sb.append(getBlockQps()).append("|"); sb.append(getSuccessQps()).append("|"); - sb.append(getException()).append("|"); + sb.append(getExceptionQps()).append("|"); sb.append(getRt()); sb.append('\n'); return sb.toString(); @@ -178,10 +178,10 @@ public class MetricNode { MetricNode node = new MetricNode(); node.setTimestamp(time); node.setResource(strs[2]); - node.setPassedQps(Long.parseLong(strs[3])); - node.setBlockedQps(Long.parseLong(strs[4])); + node.setPassQps(Long.parseLong(strs[3])); + node.setBlockQps(Long.parseLong(strs[4])); node.setSuccessQps(Long.parseLong(strs[5])); - node.setException(Long.parseLong(strs[6])); + node.setExceptionQps(Long.parseLong(strs[6])); node.setRt(Long.parseLong(strs[7])); return node; } diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/StatisticSlot.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/StatisticSlot.java index 093adbe3..67ddc4a9 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/StatisticSlot.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/StatisticSlot.java @@ -72,13 +72,13 @@ public class StatisticSlot extends AbstractLinkedProcessorSlot { context.getCurEntry().setError(e); // Add block count. - node.increaseBlockedQps(); + node.increaseBlockQps(); if (context.getCurEntry().getOriginNode() != null) { - context.getCurEntry().getOriginNode().increaseBlockedQps(); + context.getCurEntry().getOriginNode().increaseBlockQps(); } if (resourceWrapper.getType() == EntryType.IN) { - Constants.ENTRY_NODE.increaseBlockedQps(); + Constants.ENTRY_NODE.increaseBlockQps(); } for (ProcessorSlotEntryCallback handler : StatisticSlotCallbackRegistry.getEntryCallbacks()) { diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/metric/ArrayMetric.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/metric/ArrayMetric.java index 684c8365..f6a9277f 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/metric/ArrayMetric.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/statistic/metric/ArrayMetric.java @@ -144,9 +144,9 @@ public class ArrayMetric implements Metric { continue; } MetricNode node = new MetricNode(); - node.setBlockedQps(window.value().block()); - node.setException(window.value().exception()); - node.setPassedQps(window.value().pass()); + node.setBlockQps(window.value().block()); + node.setExceptionQps(window.value().exception()); + node.setPassQps(window.value().pass()); long passQps = window.value().success(); node.setSuccessQps(passQps); if (passQps != 0) { diff --git a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/MetricEntity.java b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/MetricEntity.java index c8c2806a..fd3314f6 100755 --- a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/MetricEntity.java +++ b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/datasource/entity/MetricEntity.java @@ -30,16 +30,13 @@ public class MetricEntity { */ private Date timestamp; private String resource; - private Long passedQps; + private Long passQps; private Long successQps; - private Long blockedQps; - /** - * 发生异常的次数 - */ - private Long exception; + private Long blockQps; + private Long exceptionQps; /** - * 所有successQps的Rt的和。 + * summary rt of all success exit qps. */ private double rt; @@ -58,26 +55,26 @@ public class MetricEntity { entity.setApp(oldEntity.getApp()); entity.setTimestamp(oldEntity.getTimestamp()); entity.setResource(oldEntity.getResource()); - entity.setPassedQps(oldEntity.getPassedQps()); - entity.setBlockedQps(oldEntity.getBlockedQps()); + entity.setPassQps(oldEntity.getPassQps()); + entity.setBlockQps(oldEntity.getBlockQps()); entity.setSuccessQps(oldEntity.getSuccessQps()); - entity.setException(oldEntity.getException()); + entity.setExceptionQps(oldEntity.getExceptionQps()); entity.setRt(oldEntity.getRt()); entity.setCount(oldEntity.getCount()); entity.setResource(oldEntity.getResource()); return entity; } - public synchronized void addPassedQps(Long passedQps) { - this.passedQps += passedQps; + public synchronized void addPassQps(Long passQps) { + this.passQps += passQps; } - public synchronized void addBlockedQps(Long blockedQps) { - this.blockedQps += blockedQps; + public synchronized void addBlockQps(Long blockQps) { + this.blockQps += blockQps; } - public synchronized void addException(Long exception) { - this.exception += exception; + public synchronized void addExceptionQps(Long exceptionQps) { + this.exceptionQps += exceptionQps; } public synchronized void addCount(int count) { @@ -149,28 +146,28 @@ public class MetricEntity { this.resourceCode = resource.hashCode(); } - public Long getPassedQps() { - return passedQps; + public Long getPassQps() { + return passQps; } - public void setPassedQps(Long passedQps) { - this.passedQps = passedQps; + public void setPassQps(Long passQps) { + this.passQps = passQps; } - public Long getBlockedQps() { - return blockedQps; + public Long getBlockQps() { + return blockQps; } - public void setBlockedQps(Long blockedQps) { - this.blockedQps = blockedQps; + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; } - public Long getException() { - return exception; + public Long getExceptionQps() { + return exceptionQps; } - public void setException(Long exception) { - this.exception = exception; + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; } public double getRt() { @@ -210,10 +207,10 @@ public class MetricEntity { ", app='" + app + '\'' + ", timestamp=" + timestamp + ", resource='" + resource + '\'' + - ", passedQps=" + passedQps + - ", blockedQps=" + blockedQps + + ", passQps=" + passQps + + ", blockQps=" + blockQps + ", successQps=" + successQps + - ", exception=" + exception + + ", exceptionQps=" + exceptionQps + ", rt=" + rt + ", count=" + count + ", resourceCode=" + resourceCode + diff --git a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/domain/ResourceTreeNode.java b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/domain/ResourceTreeNode.java index 542a0814..8011ff8b 100755 --- a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/domain/ResourceTreeNode.java +++ b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/domain/ResourceTreeNode.java @@ -32,13 +32,13 @@ public class ResourceTreeNode { private Integer threadNum; private Long passQps; - private Long blockedQps; + private Long blockQps; private Long totalQps; private Long averageRt; private Long successQps; private Long exceptionQps; - private Long oneMinutePassed; - private Long oneMinuteBlocked; + private Long oneMinutePass; + private Long oneMinuteBlock; private Long oneMinuteException; private Long oneMinuteTotal; @@ -74,13 +74,13 @@ public class ResourceTreeNode { node.resource = vo.getResource(); node.threadNum = vo.getThreadNum(); node.passQps = vo.getPassQps(); - node.blockedQps = vo.getBlockedQps(); + node.blockQps = vo.getBlockQps(); node.totalQps = vo.getTotalQps(); node.averageRt = vo.getAverageRt(); node.successQps = vo.getSuccessQps(); node.exceptionQps = vo.getExceptionQps(); - node.oneMinutePassed = vo.getOneMinutePassed(); - node.oneMinuteBlocked = vo.getOneMinuteBlocked(); + node.oneMinutePass = vo.getOneMinutePass(); + node.oneMinuteBlock = vo.getOneMinuteBlock(); node.oneMinuteException = vo.getOneMinuteException(); node.oneMinuteTotal = vo.getOneMinuteTotal(); return node; @@ -151,12 +151,12 @@ public class ResourceTreeNode { this.passQps = passQps; } - public Long getBlockedQps() { - return blockedQps; + public Long getBlockQps() { + return blockQps; } - public void setBlockedQps(Long blockedQps) { - this.blockedQps = blockedQps; + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; } public Long getTotalQps() { @@ -191,20 +191,20 @@ public class ResourceTreeNode { this.exceptionQps = exceptionQps; } - public Long getOneMinutePassed() { - return oneMinutePassed; + public Long getOneMinutePass() { + return oneMinutePass; } - public void setOneMinutePassed(Long oneMinutePassed) { - this.oneMinutePassed = oneMinutePassed; + public void setOneMinutePass(Long oneMinutePass) { + this.oneMinutePass = oneMinutePass; } - public Long getOneMinuteBlocked() { - return oneMinuteBlocked; + public Long getOneMinuteBlock() { + return oneMinuteBlock; } - public void setOneMinuteBlocked(Long oneMinuteBlocked) { - this.oneMinuteBlocked = oneMinuteBlocked; + public void setOneMinuteBlock(Long oneMinuteBlock) { + this.oneMinuteBlock = oneMinuteBlock; } public Long getOneMinuteException() { diff --git a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/metric/MetricFetcher.java b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/metric/MetricFetcher.java index dce727f0..6ffd2b78 100755 --- a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/metric/MetricFetcher.java +++ b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/metric/MetricFetcher.java @@ -304,19 +304,19 @@ public class MetricFetcher { String key = buildMetricKey(machine.getApp(), node.getResource(), node.getTimestamp()); MetricEntity entity = map.get(key); if (entity != null) { - entity.addPassedQps(node.getPassedQps()); - entity.addBlockedQps(node.getBlockedQps()); + entity.addPassQps(node.getPassQps()); + entity.addBlockQps(node.getBlockQps()); entity.addRtAndSuccessQps(node.getRt(), node.getSuccessQps()); - entity.addException(node.getException()); + entity.addExceptionQps(node.getExceptionQps()); entity.addCount(1); } else { entity = new MetricEntity(); entity.setApp(machine.getApp()); entity.setTimestamp(new Date(node.getTimestamp())); - entity.setPassedQps(node.getPassedQps()); - entity.setBlockedQps(node.getBlockedQps()); + entity.setPassQps(node.getPassQps()); + entity.setBlockQps(node.getBlockQps()); entity.setRtAndSuccessQps(node.getRt(), node.getSuccessQps()); - entity.setException(node.getException()); + entity.setExceptionQps(node.getExceptionQps()); entity.setCount(1); entity.setResource(node.getResource()); map.put(key, entity); diff --git a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java index 29f42770..c52403b4 100644 --- a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java +++ b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/repository/metric/InMemoryMetricsRepository.java @@ -113,10 +113,10 @@ public class InMemoryMetricsRepository implements MetricsRepository { MetricEntity e1 = o1.getValue(); MetricEntity e2 = o2.getValue(); - int t = e2.getBlockedQps().compareTo(e1.getBlockedQps()); + int t = e2.getBlockQps().compareTo(e1.getBlockQps()); if (t != 0) { return t; } - return e2.getPassedQps().compareTo(e1.getPassedQps()); + return e2.getPassQps().compareTo(e1.getPassQps()); }) .map(Entry::getKey) .collect(Collectors.toList()); diff --git a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/MetricVo.java b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/MetricVo.java index fd9296b4..c2e73713 100755 --- a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/MetricVo.java +++ b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/MetricVo.java @@ -29,11 +29,11 @@ public class MetricVo implements Comparable { private String app; private Long timestamp; private Long gmtCreate = System.currentTimeMillis(); - private String identity; - private Long passedQps; - private Long blockedQps; + private String resource; + private Long passQps; + private Long blockQps; private Long successQps; - private Long exception; + private Long exceptionQps; /** * average rt */ @@ -78,11 +78,11 @@ public class MetricVo implements Comparable { vo.app = entity.getApp(); vo.timestamp = entity.getTimestamp().getTime(); vo.gmtCreate = entity.getGmtCreate().getTime(); - vo.identity = entity.getResource(); - vo.passedQps = entity.getPassedQps(); - vo.blockedQps = entity.getBlockedQps(); + vo.resource = entity.getResource(); + vo.passQps = entity.getPassQps(); + vo.blockQps = entity.getBlockQps(); vo.successQps = entity.getSuccessQps(); - vo.exception = entity.getException(); + vo.exceptionQps = entity.getExceptionQps(); if (entity.getSuccessQps() != 0) { vo.rt = entity.getRt() / entity.getSuccessQps(); } else { @@ -96,18 +96,18 @@ public class MetricVo implements Comparable { String[] strs = line.split("\\|"); long timestamp = Long.parseLong(strs[0]); String identity = strs[1]; - long passedQps = Long.parseLong(strs[2]); - long blockedQps = Long.parseLong(strs[3]); + long passQps = Long.parseLong(strs[2]); + long blockQps = Long.parseLong(strs[3]); long exception = Long.parseLong(strs[4]); double rt = Double.parseDouble(strs[5]); long successQps = Long.parseLong(strs[6]); MetricVo vo = new MetricVo(); vo.timestamp = timestamp; - vo.identity = identity; - vo.passedQps = passedQps; - vo.blockedQps = blockedQps; + vo.resource = identity; + vo.passQps = passQps; + vo.blockQps = blockQps; vo.successQps = successQps; - vo.exception = exception; + vo.exceptionQps = exception; vo.rt = rt; vo.count = 1; return vo; @@ -145,28 +145,28 @@ public class MetricVo implements Comparable { this.gmtCreate = gmtCreate; } - public String getIdentity() { - return identity; + public String getResource() { + return resource; } - public void setIdentity(String identity) { - this.identity = identity; + public void setResource(String resource) { + this.resource = resource; } - public Long getPassedQps() { - return passedQps; + public Long getPassQps() { + return passQps; } - public void setPassedQps(Long passedQps) { - this.passedQps = passedQps; + public void setPassQps(Long passQps) { + this.passQps = passQps; } - public Long getBlockedQps() { - return blockedQps; + public Long getBlockQps() { + return blockQps; } - public void setBlockedQps(Long blockedQps) { - this.blockedQps = blockedQps; + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; } public Long getSuccessQps() { @@ -177,12 +177,12 @@ public class MetricVo implements Comparable { this.successQps = successQps; } - public Long getException() { - return exception; + public Long getExceptionQps() { + return exceptionQps; } - public void setException(Long exception) { - this.exception = exception; + public void setExceptionQps(Long exceptionQps) { + this.exceptionQps = exceptionQps; } public Double getRt() { diff --git a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/ResourceVo.java b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/ResourceVo.java index a84096a3..bbba8b47 100755 --- a/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/ResourceVo.java +++ b/sentinel-dashboard/src/main/java/com/taobao/csp/sentinel/dashboard/view/vo/ResourceVo.java @@ -32,13 +32,13 @@ public class ResourceVo { private Integer threadNum; private Long passQps; - private Long blockedQps; + private Long blockQps; private Long totalQps; private Long averageRt; private Long passRequestQps; private Long exceptionQps; - private Long oneMinutePassed; - private Long oneMinuteBlocked; + private Long oneMinutePass; + private Long oneMinuteBlock; private Long oneMinuteException; private Long oneMinuteTotal; @@ -64,12 +64,12 @@ public class ResourceVo { vo.resource = nodeVo.getResource(); vo.threadNum = nodeVo.getThreadNum(); vo.passQps = nodeVo.getPassQps(); - vo.blockedQps = nodeVo.getBlockedQps(); + vo.blockQps = nodeVo.getBlockQps(); vo.totalQps = nodeVo.getTotalQps(); vo.averageRt = nodeVo.getAverageRt(); vo.exceptionQps = nodeVo.getExceptionQps(); - vo.oneMinutePassed = nodeVo.getOneMinutePassed(); - vo.oneMinuteBlocked = nodeVo.getOneMinuteBlocked(); + vo.oneMinutePass = nodeVo.getOneMinutePass(); + vo.oneMinuteBlock = nodeVo.getOneMinuteBlock(); vo.oneMinuteException = nodeVo.getOneMinuteException(); vo.oneMinuteTotal = nodeVo.getOneMinuteTotal(); list.add(vo); @@ -103,12 +103,12 @@ public class ResourceVo { vo.resource = node.getResource(); vo.threadNum = node.getThreadNum(); vo.passQps = node.getPassQps(); - vo.blockedQps = node.getBlockedQps(); + vo.blockQps = node.getBlockQps(); vo.totalQps = node.getTotalQps(); vo.averageRt = node.getAverageRt(); vo.exceptionQps = node.getExceptionQps(); - vo.oneMinutePassed = node.getOneMinutePassed(); - vo.oneMinuteBlocked = node.getOneMinuteBlocked(); + vo.oneMinutePass = node.getOneMinutePass(); + vo.oneMinuteBlock = node.getOneMinuteBlock(); vo.oneMinuteException = node.getOneMinuteException(); vo.oneMinuteTotal = node.getOneMinuteTotal(); vo.visible = node.isVisible(); @@ -159,12 +159,12 @@ public class ResourceVo { this.passQps = passQps; } - public Long getBlockedQps() { - return blockedQps; + public Long getBlockQps() { + return blockQps; } - public void setBlockedQps(Long blockedQps) { - this.blockedQps = blockedQps; + public void setBlockQps(Long blockQps) { + this.blockQps = blockQps; } public Long getTotalQps() { @@ -207,20 +207,20 @@ public class ResourceVo { this.oneMinuteException = oneMinuteException; } - public Long getOneMinutePassed() { - return oneMinutePassed; + public Long getOneMinutePass() { + return oneMinutePass; } - public void setOneMinutePassed(Long oneMinutePassed) { - this.oneMinutePassed = oneMinutePassed; + public void setOneMinutePass(Long oneMinutePass) { + this.oneMinutePass = oneMinutePass; } - public Long getOneMinuteBlocked() { - return oneMinuteBlocked; + public Long getOneMinuteBlock() { + return oneMinuteBlock; } - public void setOneMinuteBlocked(Long oneMinuteBlocked) { - this.oneMinuteBlocked = oneMinuteBlocked; + public void setOneMinuteBlock(Long oneMinuteBlock) { + this.oneMinuteBlock = oneMinuteBlock; } public Long getOneMinuteTotal() { diff --git a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js index 8f853007..558495a5 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js +++ b/sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js @@ -75,13 +75,13 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv type: 'time', mask: 'YYYY-MM-DD HH:mm:ss' }); - chart.scale('passedQps', { + chart.scale('passQps', { min: 0, fine: true, alias: 'p_qps' // max: 10 }); - chart.scale('blockedQps', { + chart.scale('blockQps', { min: 0, fine: true, alias: 'b_qps', @@ -94,7 +94,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv grid: null, label: null }); - chart.axis('blockedQps', { + chart.axis('blockQps', { grid: null, label: null }); @@ -118,17 +118,17 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv allowAllCanceled: true, itemFormatter: function (val) { // console.log('val=', val); - if ('passedQps' === val) { + if ('passQps' === val) { return 'p_qps'; } - if ('blockedQps' === val) { + if ('blockQps' === val) { return 'b_qps'; } return val; }, items: [ - { value: 'passedQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } }, - { value: 'blockedQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } }, + { value: 'passQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } }, + { value: 'blockQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } }, // { value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} }, ], onClick: function (ev) { @@ -148,8 +148,8 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv } } }); - chart.line().position('timestamp*passedQps').size(1).color('green').shape('smooth'); - chart.line().position('timestamp*blockedQps').size(1).color('blue').shape('smooth'); + chart.line().position('timestamp*passQps').size(1).color('green').shape('smooth'); + chart.line().position('timestamp*blockQps').size(1).color('blue').shape('smooth'); // chart.line().position('timestamp*rt').size(1).color('gray'); G2.track(false); chart.render(); @@ -214,8 +214,8 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv for (var j = lastTime + 1; j < curTime; j++) { filledData.push({ "timestamp": j * 1000, - "passedQps": 0, - "blockedQps": 0, + "passQps": 0, + "blockQps": 0, "successQps": 0, "exception": 0, "rt": 0, diff --git a/sentinel-dashboard/src/main/webapp/resources/app/views/identity.html b/sentinel-dashboard/src/main/webapp/resources/app/views/identity.html index 682f71bb..03eba209 100755 --- a/sentinel-dashboard/src/main/webapp/resources/app/views/identity.html +++ b/sentinel-dashboard/src/main/webapp/resources/app/views/identity.html @@ -61,13 +61,13 @@ {{resource.passQps}} - {{resource.blockedQps}} + {{resource.blockQps}} {{resource.threadNum}} {{resource.averageRt}} - {{resource.oneMinutePassed}} + {{resource.oneMinutePass}} - {{resource.oneMinuteBlocked}} - {{resource.oneMinuteBlocked}} + {{resource.oneMinuteBlock}} + {{resource.oneMinuteBlock}}