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

com.signalfuse.metrics.connection.HttpDataPointProtobufReceiverFactory Maven / Gradle / Ivy

Go to download

Bare minimum core library needed to sending metrics to SignalFuse from Java clients

There is a newer version: 0.0.19
Show newest version
package com.signalfuse.metrics.connection;

import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;

import com.signalfuse.endpoint.SignalFuseReceiverEndpoint;
import com.signalfuse.metrics.SignalfuseMetricsException;

public class HttpDataPointProtobufReceiverFactory implements DataPointReceiverFactory {
    public static final int DEFAULT_TIMEOUT_MS = 2000;
    public static final int DEFAULT_VERSION = 2;

    private final SignalFuseReceiverEndpoint endpoint;
    private HttpClientConnectionManager httpClientConnectionManager =
            new BasicHttpClientConnectionManager();
    private int timeoutMs = DEFAULT_TIMEOUT_MS;
    private int version = DEFAULT_VERSION;

    public HttpDataPointProtobufReceiverFactory(SignalFuseReceiverEndpoint endpoint) {
        this.endpoint = endpoint;
    }

    public HttpDataPointProtobufReceiverFactory setTimeoutMs(int timeoutMs) {
        this.timeoutMs = timeoutMs;
        return this;
    }

    public HttpDataPointProtobufReceiverFactory setVersion(int version) {
        this.version = version;
        return this;
    }

    public void setHttpClientConnectionManager(
            HttpClientConnectionManager httpClientConnectionManager) {
        this.httpClientConnectionManager = httpClientConnectionManager;
    }

    @Override
    public DataPointReceiver createDataPointReceiver() throws
            SignalfuseMetricsException {
        if (version == 1) {
            return new HttpDataPointProtobufReceiverConnection(endpoint, this.timeoutMs, httpClientConnectionManager);
        } else {
            return new HttpDataPointProtobufReceiverConnectionV2(endpoint, this.timeoutMs, httpClientConnectionManager);
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy