[GitHub] [skywalking] wu-sheng commented on a change in pull request #4247: fix thread unsafe problem in server-alarm-plugin (#4230)

2020-01-19 Thread GitBox
wu-sheng commented on a change in pull request #4247: fix thread unsafe problem 
in server-alarm-plugin (#4230)
URL: https://github.com/apache/skywalking/pull/4247#discussion_r368284230
 
 

 ##
 File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java
 ##
 @@ -227,18 +221,17 @@ public void moveTo(LocalDateTime current) {
 public void add(Metrics metrics) {
 long bucket = metrics.getTimeBucket();
 
-LocalDateTime timebucket = 
TIME_BUCKET_FORMATTER.parseLocalDateTime(bucket + "");
-
-int minutes = Minutes.minutesBetween(timebucket, 
endTime).getMinutes();
-if (minutes == -1) {
-this.moveTo(timebucket);
-
-}
+LocalDateTime timeBucket = 
TIME_BUCKET_FORMATTER.parseLocalDateTime(bucket + "");
 
-lock.lock();
+this.lock.lock();
 try {
+if (this.endTime == null) {
+init();
+this.endTime = timeBucket;
 
 Review comment:
   Why add this? End time has been initialized in the constructor. End time 
should never be null. Right?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [skywalking] wu-sheng commented on a change in pull request #4247: fix thread unsafe problem in server-alarm-plugin (#4230)

2020-01-18 Thread GitBox
wu-sheng commented on a change in pull request #4247: fix thread unsafe problem 
in server-alarm-plugin (#4230)
URL: https://github.com/apache/skywalking/pull/4247#discussion_r368268133
 
 

 ##
 File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java
 ##
 @@ -290,28 +278,28 @@ private boolean isMatch() {
 
 switch (valueType) {
 case LONG:
-long lvalue = ((LongValueHolder)metrics).getValue();
+long lvalue = ((LongValueHolder) metrics).getValue();
 long lexpected = 
RunningRule.this.threshold.getLongThreshold();
 if (op.test(lexpected, lvalue)) {
 matchCount++;
 }
 break;
 case INT:
-int ivalue = ((IntValueHolder)metrics).getValue();
+int ivalue = ((IntValueHolder) metrics).getValue();
 int iexpected = 
RunningRule.this.threshold.getIntThreshold();
 if (op.test(iexpected, ivalue)) {
 matchCount++;
 }
 break;
 case DOUBLE:
-double dvalue = 
((DoubleValueHolder)metrics).getValue();
+double dvalue = ((DoubleValueHolder) 
metrics).getValue();
 double dexpected = 
RunningRule.this.threshold.getDoubleThreshold();
 if (op.test(dexpected, dvalue)) {
 matchCount++;
 }
 break;
 case MULTI_INTS:
-int[] ivalueArray = 
((MultiIntValuesHolder)metrics).getValues();
+int[] ivalueArray = ((MultiIntValuesHolder) 
metrics).getValues();
 
 Review comment:
   But we are not using it .SkyWalking has its own format, please revert those.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [skywalking] wu-sheng commented on a change in pull request #4247: fix thread unsafe problem in server-alarm-plugin (#4230)

2020-01-18 Thread GitBox
wu-sheng commented on a change in pull request #4247: fix thread unsafe problem 
in server-alarm-plugin (#4230)
URL: https://github.com/apache/skywalking/pull/4247#discussion_r368267810
 
 

 ##
 File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java
 ##
 @@ -86,7 +83,7 @@ public RunningRule(AlarmRule alarmRule) {
  * Receive metrics result from persistence, after it is saved into 
storage. In alarm, only minute dimensionality
  * metrics are expected to process.
  *
- * @param meta of input metrics
+ * @param metaof input metrics
 
 Review comment:
   Why change this?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [skywalking] wu-sheng commented on a change in pull request #4247: fix thread unsafe problem in server-alarm-plugin (#4230)

2020-01-18 Thread GitBox
wu-sheng commented on a change in pull request #4247: fix thread unsafe problem 
in server-alarm-plugin (#4230)
URL: https://github.com/apache/skywalking/pull/4247#discussion_r368267823
 
 

 ##
 File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java
 ##
 @@ -290,28 +278,28 @@ private boolean isMatch() {
 
 switch (valueType) {
 case LONG:
-long lvalue = ((LongValueHolder)metrics).getValue();
+long lvalue = ((LongValueHolder) metrics).getValue();
 long lexpected = 
RunningRule.this.threshold.getLongThreshold();
 if (op.test(lexpected, lvalue)) {
 matchCount++;
 }
 break;
 case INT:
-int ivalue = ((IntValueHolder)metrics).getValue();
+int ivalue = ((IntValueHolder) metrics).getValue();
 int iexpected = 
RunningRule.this.threshold.getIntThreshold();
 if (op.test(iexpected, ivalue)) {
 matchCount++;
 }
 break;
 case DOUBLE:
-double dvalue = 
((DoubleValueHolder)metrics).getValue();
+double dvalue = ((DoubleValueHolder) 
metrics).getValue();
 double dexpected = 
RunningRule.this.threshold.getDoubleThreshold();
 if (op.test(dexpected, dvalue)) {
 matchCount++;
 }
 break;
 case MULTI_INTS:
-int[] ivalueArray = 
((MultiIntValuesHolder)metrics).getValues();
+int[] ivalueArray = ((MultiIntValuesHolder) 
metrics).getValues();
 
 Review comment:
   What change the format of all these cases?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [skywalking] wu-sheng commented on a change in pull request #4247: fix thread unsafe problem in server-alarm-plugin (#4230)

2020-01-18 Thread GitBox
wu-sheng commented on a change in pull request #4247: fix thread unsafe problem 
in server-alarm-plugin (#4230)
URL: https://github.com/apache/skywalking/pull/4247#discussion_r368267794
 
 

 ##
 File path: 
oap-server/server-alarm-plugin/src/main/java/org/apache/skywalking/oap/server/core/alarm/provider/RunningRule.java
 ##
 @@ -187,7 +182,7 @@ public void moveTo(LocalDateTime targetTime) {
 private int silenceCountdown;
 
 private LinkedList values;
-private ReentrantLock lock = new ReentrantLock();
+private ReentrantLock reentrantLock = new ReentrantLock();
 
 Review comment:
   Why change this name?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services