Search in sources :

Example 1 with FluentdRecordFormatter

use of org.komamitsu.fluency.fluentd.recordformat.FluentdRecordFormatter in project fluency by komamitsu.

the class FluencyTestWithMockServer method testFluencyUsingAsyncFlusher.

@ParameterizedTest
@MethodSource("optionsProvider")
void testFluencyUsingAsyncFlusher(final Options options) throws Exception {
    testFluencyBase(localPorts -> {
        FluentdSender sender;
        int fluentdPort = localPorts.get(0);
        if (options.failover) {
            int secondaryFluentdPort = localPorts.get(1);
            if (options.sslEnabled) {
                sender = getDoubleSSLSender(fluentdPort, secondaryFluentdPort);
            } else {
                sender = getDoubleTCPSender(fluentdPort, secondaryFluentdPort);
            }
        } else {
            if (options.sslEnabled) {
                sender = getSingleSSLSender(fluentdPort);
            } else {
                sender = getSingleTCPSender(fluentdPort);
            }
        }
        FluentdIngester.Config ingesterConfig = new FluentdIngester.Config();
        if (options.ackResponse) {
            ingesterConfig.setAckResponseMode(true);
        }
        Buffer.Config bufferConfig = new Buffer.Config();
        if (options.smallBuffer) {
            bufferConfig.setChunkRetentionSize(SMALL_BUF_SIZE);
            bufferConfig.setMaxBufferSize(SMALL_BUF_SIZE + 1);
        }
        if (options.fileBackup) {
            bufferConfig.setFileBackupDir(TMPDIR);
            bufferConfig.setFileBackupPrefix("testFluencyUsingAsyncFlusher" + options.hashCode());
        }
        if (options.jvmHeap) {
            bufferConfig.setJvmHeapBufferMode(true);
        }
        Flusher.Config flusherConfig = new Flusher.Config();
        flusherConfig.setWaitUntilBufferFlushed(10);
        flusherConfig.setWaitUntilTerminated(10);
        Buffer buffer = new Buffer(bufferConfig, new FluentdRecordFormatter(new FluentdRecordFormatter.Config()));
        Flusher flusher = new Flusher(flusherConfig, buffer, new FluentdIngester(ingesterConfig, sender));
        return new Fluency(buffer, flusher);
    }, options);
}
Also used : ByteBuffer(java.nio.ByteBuffer) Buffer(org.komamitsu.fluency.buffer.Buffer) Fluency(org.komamitsu.fluency.Fluency) FluentdIngester(org.komamitsu.fluency.fluentd.ingester.FluentdIngester) FluentdSender(org.komamitsu.fluency.fluentd.ingester.sender.FluentdSender) Flusher(org.komamitsu.fluency.flusher.Flusher) FluentdRecordFormatter(org.komamitsu.fluency.fluentd.recordformat.FluentdRecordFormatter) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with FluentdRecordFormatter

use of org.komamitsu.fluency.fluentd.recordformat.FluentdRecordFormatter in project fluency by komamitsu.

the class FluencyTest method testBufferWithJacksonModule.

@ParameterizedTest
@MethodSource("sslFlagsProvider")
void testBufferWithJacksonModule() throws IOException {
    AtomicBoolean serialized = new AtomicBoolean();
    SimpleModule simpleModule = new SimpleModule();
    simpleModule.addSerializer(Foo.class, new FooSerializer(serialized));
    FluentdRecordFormatter.Config recordFormatterConfig = new FluentdRecordFormatter.Config();
    recordFormatterConfig.setJacksonModules(Collections.singletonList(simpleModule));
    Fluency fluency = new FluencyBuilder().buildFromIngester(new FluentdRecordFormatter(recordFormatterConfig), ingester);
    Map<String, Object> event = new HashMap<>();
    Foo foo = new Foo();
    foo.s = "Hello";
    event.put("foo", foo);
    fluency.emit("tag", event);
    assertThat(serialized.get(), is(true));
}
Also used : HashMap(java.util.HashMap) FluentdRecordFormatter(org.komamitsu.fluency.fluentd.recordformat.FluentdRecordFormatter) FluencyBuilder(org.komamitsu.fluency.FluencyBuilder) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Fluency(org.komamitsu.fluency.Fluency) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Fluency (org.komamitsu.fluency.Fluency)2 FluentdRecordFormatter (org.komamitsu.fluency.fluentd.recordformat.FluentdRecordFormatter)2 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 FluencyBuilder (org.komamitsu.fluency.FluencyBuilder)1 Buffer (org.komamitsu.fluency.buffer.Buffer)1 FluentdIngester (org.komamitsu.fluency.fluentd.ingester.FluentdIngester)1 FluentdSender (org.komamitsu.fluency.fluentd.ingester.sender.FluentdSender)1 Flusher (org.komamitsu.fluency.flusher.Flusher)1