类 MetricWriter
java.lang.Object
com.alibaba.csp.sentinel.node.metric.MetricWriter
This class is responsible for writing
MetricNode to disk:
- metric with the same second should write to the same file;
- single file size must be controlled;
- file name is like:
${appName}-metrics.log.pid${pid}.yyyy-MM-dd.[number] - metric of different day should in different file;
- every metric file is accompanied with an index file, which file name is
${metricFileName}.idx
- 作者:
- Carpenter Lee
-
字段概要
字段修饰符和类型字段说明static final Stringstatic final StringNote:MetricWriter.MetricFileNameComparator's implementation relies on the metric file name, so we should be careful when changing the metric file name.static final Stringstatic final Comparator<String> -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidclose()static booleanfileNameMatches(String fileName, String baseFileName) Test whether fileName matches baseFileName.static StringformIndexFileName(String metricFileName) Form index file name of themetricFileNamestatic StringformMetricFileName(String appName, int pid) Form metric file name use the specific appName and pid.voidwrite(long time, List<MetricNode> nodes) 如果传入了time,就认为nodes中所有的时间时间戳都是time.
-
字段详细资料
-
METRIC_BASE_DIR
-
METRIC_FILE
Note:MetricWriter.MetricFileNameComparator's implementation relies on the metric file name, so we should be careful when changing the metric file name. -
METRIC_FILE_INDEX_SUFFIX
- 另请参阅:
-
METRIC_FILE_NAME_CMP
-
-
构造器详细资料
-
MetricWriter
public MetricWriter(long singleFileSize) -
MetricWriter
public MetricWriter(long singleFileSize, int totalFileCount)
-
-
方法详细资料
-
write
如果传入了time,就认为nodes中所有的时间时间戳都是time.- 参数:
time-nodes-- 抛出:
Exception
-
close
- 抛出:
Exception
-
fileNameMatches
Test whether fileName matches baseFileName. fileName matches baseFileName whenfileName = baseFileName + ".yyyy-MM-dd.number"
- 参数:
fileName- file namebaseFileName- base file name.- 返回:
- if fileName matches baseFileName return true, else return false.
-
formMetricFileName
Form metric file name use the specific appName and pid. Note that only form the file name, not include path. Note:MetricWriter.MetricFileNameComparator's implementation relays on the metric file name, we should be careful when changing the metric file name.- 参数:
appName-pid-- 返回:
- metric file name.
-
formIndexFileName
Form index file name of themetricFileName- 参数:
metricFileName-- 返回:
- the index file name of the metricFileName
-