|
@@ -6,6 +6,7 @@ import lombok.Data;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
+import java.util.concurrent.atomic.LongAdder;
|
|
|
|
|
|
/**
|
|
|
* 功能描述
|
|
@@ -16,51 +17,51 @@ import java.util.concurrent.atomic.AtomicLong;
|
|
|
@Data
|
|
|
public class Statistic {
|
|
|
long beginTime;
|
|
|
- AtomicLong dataCount = new AtomicLong();
|
|
|
- AtomicLong dataCountTsdbSuccess = new AtomicLong();
|
|
|
- AtomicLong dataCountDiskSuccess = new AtomicLong();
|
|
|
+ LongAdder dataCount = new LongAdder();
|
|
|
+ LongAdder dataCountTsdbSuccess = new LongAdder();
|
|
|
+ LongAdder dataCountDiskSuccess = new LongAdder();
|
|
|
|
|
|
public Statistic() {
|
|
|
beginTime = System.currentTimeMillis();
|
|
|
}
|
|
|
|
|
|
- public long incrDataCount() {
|
|
|
- return this.dataCount.incrementAndGet();
|
|
|
+ public void incrDataCount() {
|
|
|
+ this.dataCount.increment();
|
|
|
}
|
|
|
|
|
|
- public long increDataCountTsdbSuccess() {
|
|
|
- return this.dataCountTsdbSuccess.incrementAndGet();
|
|
|
+ public void increDataCountTsdbSuccess() {
|
|
|
+ this.dataCountTsdbSuccess.increment();
|
|
|
}
|
|
|
|
|
|
- public long increDataCountTsdbSuccess(int count) {
|
|
|
- return this.dataCountTsdbSuccess.addAndGet(count);
|
|
|
+ public void increDataCountTsdbSuccess(int count) {
|
|
|
+ this.dataCountTsdbSuccess.add(count);
|
|
|
}
|
|
|
|
|
|
- public long increDataCountDiskSuccess() {
|
|
|
- return this.dataCountDiskSuccess.incrementAndGet();
|
|
|
+ public void increDataCountDiskSuccess() {
|
|
|
+ this.dataCountDiskSuccess.increment();
|
|
|
}
|
|
|
|
|
|
- public long increDataCountDiskSuccess(int count) {
|
|
|
- return this.dataCountDiskSuccess.addAndGet(count);
|
|
|
+ public void increDataCountDiskSuccess(int count) {
|
|
|
+ this.dataCountDiskSuccess.add(count);
|
|
|
}
|
|
|
|
|
|
public double dataRate() {
|
|
|
long time = System.currentTimeMillis() - this.beginTime;
|
|
|
- return dataCount.get() * 1000.0 / time;
|
|
|
+ return dataCount.longValue() * 1000.0 / time;
|
|
|
}
|
|
|
|
|
|
public StatisticDto toDto() {
|
|
|
- StatisticDto statisticDto = new StatisticDto(this.beginTime, this.dataCount.get(),
|
|
|
- this.dataCountTsdbSuccess.get(), this.dataCountDiskSuccess.get());
|
|
|
+ StatisticDto statisticDto = new StatisticDto(this.beginTime, this.dataCount.longValue(),
|
|
|
+ this.dataCountTsdbSuccess.longValue(), this.dataCountDiskSuccess.longValue());
|
|
|
return statisticDto;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
long time = System.currentTimeMillis() - this.beginTime;
|
|
|
- double dataRate = dataCount.get() * 1000.0 / time;
|
|
|
- double dataCountTsdbSuccessRate = dataCountTsdbSuccess.get() * 1000.0 / time;
|
|
|
- double dataCountDiskSuccessRate = dataCountDiskSuccess.get() * 1000.0 / time;
|
|
|
+ double dataRate = dataCount.longValue() * 1000.0 / time;
|
|
|
+ double dataCountTsdbSuccessRate = dataCountTsdbSuccess.longValue() * 1000.0 / time;
|
|
|
+ double dataCountDiskSuccessRate = dataCountDiskSuccess.longValue() * 1000.0 / time;
|
|
|
|
|
|
String beginTimeString = "";
|
|
|
try {
|