From 271783fe2fd2be852bbb882b5d54629686d25f47 Mon Sep 17 00:00:00 2001 From: nullhuangyiming Date: Mon, 26 Sep 2022 12:21:59 +0800 Subject: [PATCH] systemRule use builder pattern,Be consistent with other Rules,Including the parent class AbstractRule --- .../csp/sentinel/slots/system/SystemRule.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/system/SystemRule.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/system/SystemRule.java index 66afdb29f8..a47479ac83 100755 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/system/SystemRule.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/system/SystemRule.java @@ -61,8 +61,9 @@ public double getQps() { * * @param qps max total QOS, values <= 0 are special for clearing the threshold. */ - public void setQps(double qps) { + public SystemRule setQps(double qps) { this.qps = qps; + return this; } public long getMaxThread() { @@ -75,8 +76,9 @@ public long getMaxThread() { * * @param maxThread max parallel thread number, values <= 0 are special for clearing the threshold. */ - public void setMaxThread(long maxThread) { + public SystemRule setMaxThread(long maxThread) { this.maxThread = maxThread; + return this; } public long getAvgRt() { @@ -88,8 +90,9 @@ public long getAvgRt() { * * @param avgRt max average response time, values <= 0 are special for clearing the threshold. */ - public void setAvgRt(long avgRt) { + public SystemRule setAvgRt(long avgRt) { this.avgRt = avgRt; + return this; } public double getHighestSystemLoad() { @@ -109,8 +112,9 @@ public double getHighestSystemLoad() { * @param highestSystemLoad highest system load, values <= 0 are special for clearing the threshold. * @see SystemRuleManager */ - public void setHighestSystemLoad(double highestSystemLoad) { + public SystemRule setHighestSystemLoad(double highestSystemLoad) { this.highestSystemLoad = highestSystemLoad; + return this; } /** @@ -127,8 +131,9 @@ public double getHighestCpuUsage() { * * @param highestCpuUsage the value to set. */ - public void setHighestCpuUsage(double highestCpuUsage) { + public SystemRule setHighestCpuUsage(double highestCpuUsage) { this.highestCpuUsage = highestCpuUsage; + return this; } @Override