refactor Metrics class. (#4418)

* refactor Metrics class.
This commit is contained in:
aderm 2020-02-28 08:49:12 +08:00 committed by GitHub
parent 467ef8bffc
commit 036aee8d2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 9 deletions

View File

@ -26,7 +26,7 @@ public class TimeBucket {
* Record time bucket format in Second Unit.
*
* @param time Timestamp
* @return time in second format.
* @return time in second format
*/
public static long getRecordTimeBucket(long time) {
return getTimeBucket(time, Downsampling.Second);
@ -36,7 +36,7 @@ public class TimeBucket {
* Record time bucket format in Minute Unit.
*
* @param time Timestamp
* @return time in minute format.
* @return time in minute format
*/
public static long getMinuteTimeBucket(long time) {
return getTimeBucket(time, Downsampling.Minute);
@ -143,7 +143,7 @@ public class TimeBucket {
*
* @param time Timestamp
* @param downsampling Downsampling
* @return time in downsampling format.
* @return time in downsampling format
*/
public static long getTimeBucket(long time, Downsampling downsampling) {
Calendar calendar = Calendar.getInstance();

View File

@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.analysis.metrics;
import lombok.Getter;
import lombok.Setter;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.remote.data.StreamData;
import org.apache.skywalking.oap.server.core.storage.StorageData;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
@ -142,18 +143,15 @@ public abstract class Metrics extends StreamData implements StorageData {
}
}
/**
* timeBucket in minute 201809120511 min 100000000000 max 999999999999
*/
private boolean isMinuteBucket() {
return timeBucket < 999999999999L && timeBucket > 100000000000L;
return TimeBucket.isMinuteBucket(timeBucket);
}
private boolean isHourBucket() {
return timeBucket < 9999999999L && timeBucket > 1000000000L;
return TimeBucket.isHourBucket(timeBucket);
}
private boolean isDayBucket() {
return timeBucket < 99999999L && timeBucket > 10000000L;
return TimeBucket.isDayBucket(timeBucket);
}
}