Refactor metrics code.

This commit is contained in:
Chuanyi Li L
2018-08-07 17:17:33 +08:00
committed by Chuanyi Li
parent 75de57c102
commit fec9803aae
17 changed files with 476 additions and 333 deletions

View File

@@ -1,31 +0,0 @@
package com.alibaba.otter.canal.common.utils;
/**
* 用于dump记录counter
* 这种场景下,
* <strong>写操作>>读操作</strong>
* dump线程为串行,读取counter时,并不严格要求最新值可见,使用普通long即可。
*
* @author Chuanyi Li
*/
public class SerializedLongAdder {
private long value = 0;
public SerializedLongAdder(long initial) {
this.value = initial;
}
public void add(long x) {
value += x;
}
public void increment() {
value ++;
}
public long get() {
return value;
}
}