All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.springframework.boxes.jmetric.starter.BoxesMetricPipelineProxy Maven / Gradle / Ivy

There is a newer version: 2.0.9
Show newest version
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