Search in sources :

Example 1 with SSLHeartbeater

use of org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater in project fluency by komamitsu.

the class SSLSenderTest method testSendWithHeartbeart.

@Test
void testSendWithHeartbeart() throws Exception {
    testSendBase(port -> {
        SSLHeartbeater.Config hbConfig = new SSLHeartbeater.Config();
        hbConfig.setPort(port);
        hbConfig.setIntervalMillis(400);
        SSLSender.Config senderConfig = new SSLSender.Config();
        senderConfig.setPort(port);
        return new SSLSender(senderConfig, new FailureDetector(new PhiAccrualFailureDetectStrategy(), new SSLHeartbeater(hbConfig)));
    }, greaterThan(1), greaterThan(1));
}
Also used : 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) Test(org.junit.jupiter.api.Test)

Example 2 with SSLHeartbeater

use of org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater in project fluency by komamitsu.

the class MultiSenderTest method testConstructorForSSLSender.

@Test
void testConstructorForSSLSender() throws IOException {
    MultiSender multiSender = null;
    try {
        SSLSender.Config senderConfig0 = new SSLSender.Config();
        senderConfig0.setPort(24225);
        SSLHeartbeater.Config hbConfig0 = new SSLHeartbeater.Config();
        hbConfig0.setPort(24225);
        SSLSender.Config senderConfig1 = new SSLSender.Config();
        senderConfig1.setHost("0.0.0.0");
        senderConfig1.setPort(24226);
        SSLHeartbeater.Config hbConfig1 = new SSLHeartbeater.Config();
        hbConfig1.setHost("0.0.0.0");
        hbConfig1.setPort(24226);
        multiSender = new MultiSender(new MultiSender.Config(), Arrays.asList(new SSLSender(senderConfig0, createFailureDetector(new SSLHeartbeater(hbConfig0))), new SSLSender(senderConfig1, createFailureDetector(new SSLHeartbeater(hbConfig1)))));
        assertThat(multiSender.toString().length(), greaterThan(0));
        assertEquals(2, multiSender.getSenders().size());
        SSLSender sslSender = (SSLSender) multiSender.getSenders().get(0);
        assertEquals("127.0.0.1", sslSender.getHost());
        assertEquals(24225, sslSender.getPort());
        assertEquals("127.0.0.1", sslSender.getFailureDetector().getHeartbeater().getHost());
        assertEquals(24225, sslSender.getFailureDetector().getHeartbeater().getPort());
        sslSender = (SSLSender) multiSender.getSenders().get(1);
        assertEquals("0.0.0.0", sslSender.getHost());
        assertEquals(24226, sslSender.getPort());
        assertEquals("0.0.0.0", sslSender.getFailureDetector().getHeartbeater().getHost());
        assertEquals(24226, sslSender.getFailureDetector().getHeartbeater().getPort());
    } finally {
        if (multiSender != null) {
            multiSender.close();
        }
    }
}
Also used : SSLHeartbeater(org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater) Test(org.junit.jupiter.api.Test)

Example 3 with SSLHeartbeater

use of org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater 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

SSLHeartbeater (org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.SSLHeartbeater)3 Test (org.junit.jupiter.api.Test)2 FailureDetector (org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.FailureDetector)2 PhiAccrualFailureDetectStrategy (org.komamitsu.fluency.fluentd.ingester.sender.failuredetect.PhiAccrualFailureDetectStrategy)2 SSLSender (org.komamitsu.fluency.fluentd.ingester.sender.SSLSender)1 TCPSender (org.komamitsu.fluency.fluentd.ingester.sender.TCPSender)1 TCPHeartbeater (org.komamitsu.fluency.fluentd.ingester.sender.heartbeat.TCPHeartbeater)1