Search in sources :

Example 6 with FailureDetector

use of org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.FailureDetector in project fluency by komamitsu.

the class FluencyBuilderForFluentd method createBaseSender.

private FluentdSender createBaseSender(String host, Integer port, boolean withHeartBeater) {
    if (withHeartBeater && port == null) {
        throw new IllegalArgumentException("`port` should be specified when using heartbeat");
    }
    if (isSslEnabled()) {
        SSLSender.Config senderConfig = new SSLSender.Config();
        FailureDetector failureDetector = null;
        if (host != null) {
            senderConfig.setHost(host);
        }
        if (port != null) {
            senderConfig.setPort(port);
        }
        if (withHeartBeater) {
            SSLHeartbeater.Config hbConfig = new SSLHeartbeater.Config();
            hbConfig.setHost(host);
            hbConfig.setPort(port);
            SSLHeartbeater heartbeater = new SSLHeartbeater(hbConfig);
            failureDetector = new FailureDetector(new PhiAccrualFailureDetectStrategy(), heartbeater);
        }
        if (connectionTimeoutMilli != null) {
            senderConfig.setConnectionTimeoutMilli(connectionTimeoutMilli);
        }
        if (readTimeoutMilli != null) {
            senderConfig.setReadTimeoutMilli(readTimeoutMilli);
        }
        return new SSLSender(senderConfig, failureDetector);
    } else {
        TCPSender.Config senderConfig = new TCPSender.Config();
        FailureDetector failureDetector = null;
        if (host != null) {
            senderConfig.setHost(host);
        }
        if (port != null) {
            senderConfig.setPort(port);
        }
        if (withHeartBeater) {
            TCPHeartbeater.Config hbConfig = new TCPHeartbeater.Config();
            hbConfig.setHost(host);
            hbConfig.setPort(port);
            TCPHeartbeater heartbeater = new TCPHeartbeater(hbConfig);
            failureDetector = new FailureDetector(new PhiAccrualFailureDetectStrategy(), heartbeater);
        }
        if (connectionTimeoutMilli != null) {
            senderConfig.setConnectionTimeoutMilli(connectionTimeoutMilli);
        }
        if (readTimeoutMilli != null) {
            senderConfig.setReadTimeoutMilli(readTimeoutMilli);
        }
        return new TCPSender(senderConfig, failureDetector);
    }
}
Also used : SSLSender(org.komamitsu.fluency.fluentd.ingester.sender.SSLSender) PhiAccrualFailureDetectStrategy(org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.PhiAccrualFailureDetectStrategy) SSLHeartbeater(org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater) FailureDetector(org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.FailureDetector) TCPHeartbeater(org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.TCPHeartbeater) TCPSender(org.komamitsu.fluency.fluentd.ingester.sender.TCPSender)

Aggregations

FailureDetector (org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.FailureDetector)6 Test (org.junit.jupiter.api.Test)4 RetryableSender (org.komamitsu.fluency.fluentd.ingester.sender.RetryableSender)3 PhiAccrualFailureDetectStrategy (org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.PhiAccrualFailureDetectStrategy)3 InetSocketAddress (java.net.InetSocketAddress)2 Fluency (org.komamitsu.fluency.Fluency)2 MultiSender (org.komamitsu.fluency.fluentd.ingester.sender.MultiSender)2 SSLSender (org.komamitsu.fluency.fluentd.ingester.sender.SSLSender)2 TCPSender (org.komamitsu.fluency.fluentd.ingester.sender.TCPSender)2 SSLHeartbeater (org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater)2 TCPHeartbeater (org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.TCPHeartbeater)2 ExponentialBackOffRetryStrategy (org.komamitsu.fluency.fluentd.ingester.sender.retry.ExponentialBackOffRetryStrategy)2 Buffer (org.komamitsu.fluency.buffer.Buffer)1 NetworkSender (org.komamitsu.fluency.fluentd.ingester.sender.NetworkSender)1 Flusher (org.komamitsu.fluency.flusher.Flusher)1