com.springframework.boxes.jmetric.starter.BoxesMetricPipelineProxy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boxes-metric-starter Show documentation
Show all versions of spring-boxes-metric-starter Show documentation
spring-metric-boxes-boot-starter
package com.springframework.boxes.jmetric.starter;
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@NoArgsConstructor
@AllArgsConstructor
public class BoxesMetricPipelineProxy implements BoxesMetricPipeline {
/**
* 上报渠道
*/
private List pool = Lists.newArrayList();
/**
* 添加上报渠道
*
* @param pipeline 上报渠道
*/
public void add(BoxesMetricPipeline pipeline) {
if (null == pipeline) {
return;
}
pool.add(pipeline);
}
/**
* 添加上报渠道
*
* @param pipelines 上报渠道
*/
public void add(BoxesMetricPipeline... pipelines) {
add(Lists.newArrayList(pipelines));
}
/**
* 添加上报渠道
*
* @param pipelines 上报渠道
*/
public void add(List pipelines) {
if (CollectionUtils.isEmpty(pipelines)) {
return;
}
pool.addAll(pipelines);
}
@Override
public void pipeline(BoxesMetricCollector collector, String key, Object value, long mills) {
Optional.ofNullable(pool).orElse(Lists.newArrayList()).forEach(
x -> {
x.pipeline(collector, key, value, mills);
}
);
}
@Override
public void pipeline(BoxesMetricCollector collector, Map metricMapping, long mills) {
Optional.ofNullable(pool).orElse(Lists.newArrayList()).forEach(
x -> {
x.pipeline(collector, metricMapping, mills);
}
);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy