Search in sources :

Example 1 with JsonlRecordFormatter

use of org.komamitsu.fluency.aws.s3.recordformat.JsonlRecordFormatter in project fluency by komamitsu.

the class FluencyBuilderForAwsS3Test method buildWithCustomConfig.

@Test
void buildWithCustomConfig() {
    FluencyBuilderForAwsS3 builder = builderWithCustomConfig;
    AwsS3Sender sender = mock(AwsS3Sender.class);
    doReturn(sender).when(builder).createSender(any(AwsS3Sender.Config.class));
    builder.setFormatType(FluencyBuilderForAwsS3.FormatType.JSONL);
    Fluency fluency = builder.build();
    assertEquals(fluency, this.fluency);
    ArgumentCaptor<AwsS3Sender.Config> configArgumentCaptor = ArgumentCaptor.forClass(AwsS3Sender.Config.class);
    verify(builder, times(1)).createSender(configArgumentCaptor.capture());
    AwsS3Sender.Config senderConfig = configArgumentCaptor.getValue();
    assertEquals("https://foo.bar.org", senderConfig.getEndpoint());
    assertEquals(Region.US_EAST_1.toString(), senderConfig.getRegion());
    assertEquals("ACCESSKEYID", senderConfig.getAwsAccessKeyId());
    assertEquals("SECRETACCESSKEY", senderConfig.getAwsSecretAccessKey());
    assertEquals(4, senderConfig.getRetryMax());
    assertEquals(543, senderConfig.getRetryIntervalMs());
    assertEquals(65432, senderConfig.getMaxRetryIntervalMs());
    assertEquals(1.234f, senderConfig.getRetryFactor());
    assertEquals(99 * 1024, senderConfig.getWorkBufSize());
    assertFalse(senderConfig.isCompressionEnabled());
    ArgumentCaptor<RecordFormatter> recordFormatterArgumentCaptor = ArgumentCaptor.forClass(RecordFormatter.class);
    ArgumentCaptor<Ingester> ingesterArgumentCaptor = ArgumentCaptor.forClass(Ingester.class);
    verify(builder, times(1)).buildFromIngester(recordFormatterArgumentCaptor.capture(), ingesterArgumentCaptor.capture());
    RecordFormatter recordFormatter = recordFormatterArgumentCaptor.getValue();
    assertTrue(recordFormatter instanceof JsonlRecordFormatter);
    AwsS3Ingester ingester = (AwsS3Ingester) ingesterArgumentCaptor.getValue();
    assertEquals(sender, ingester.getSender());
    DefaultS3DestinationDecider destinationDecider = (DefaultS3DestinationDecider) ingester.getS3DestinationDecider();
    assertEquals("mydata", destinationDecider.getKeyPrefix());
    assertEquals(".zzz", destinationDecider.getKeySuffix());
    assertEquals(ZoneId.of("JST", SHORT_IDS), destinationDecider.getZoneId());
    ArgumentCaptor<Buffer.Config> bufferConfigArgumentCaptor = ArgumentCaptor.forClass(Buffer.Config.class);
    ArgumentCaptor<Flusher.Config> flusherConfigArgumentCaptor = ArgumentCaptor.forClass(Flusher.Config.class);
    verify(builder, times(1)).createFluency(eq(recordFormatter), eq(ingester), bufferConfigArgumentCaptor.capture(), flusherConfigArgumentCaptor.capture());
    Buffer.Config bufferConfig = bufferConfigArgumentCaptor.getValue();
    assertEquals(42 * 1024 * 1024, bufferConfig.getMaxBufferSize());
    assertEquals(2 * 1024 * 1024, bufferConfig.getChunkInitialSize());
    assertEquals(9 * 1024 * 1024, bufferConfig.getChunkRetentionSize());
    assertEquals(1234, bufferConfig.getChunkRetentionTimeMillis());
}
Also used : Buffer(org.komamitsu.fluency.buffer.Buffer) AwsS3Sender(org.komamitsu.fluency.aws.s3.ingester.sender.AwsS3Sender) Fluency(org.komamitsu.fluency.Fluency) JsonlRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.JsonlRecordFormatter) AwsS3RecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.AwsS3RecordFormatter) RecordFormatter(org.komamitsu.fluency.recordformat.RecordFormatter) MessagePackRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.MessagePackRecordFormatter) CsvRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.CsvRecordFormatter) DefaultS3DestinationDecider(org.komamitsu.fluency.aws.s3.ingester.DefaultS3DestinationDecider) Flusher(org.komamitsu.fluency.flusher.Flusher) Ingester(org.komamitsu.fluency.ingester.Ingester) AwsS3Ingester(org.komamitsu.fluency.aws.s3.ingester.AwsS3Ingester) JsonlRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.JsonlRecordFormatter) AwsS3Ingester(org.komamitsu.fluency.aws.s3.ingester.AwsS3Ingester) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with JsonlRecordFormatter

use of org.komamitsu.fluency.aws.s3.recordformat.JsonlRecordFormatter in project fluency by komamitsu.

the class FluencyBuilderForAwsS3 method createRecordFormatter.

private AwsS3RecordFormatter createRecordFormatter() {
    if (formatType == null) {
        throw new IllegalArgumentException("format type must be set");
    }
    AwsS3RecordFormatter recordFormatter;
    switch(getFormatType()) {
        case MESSAGE_PACK:
            recordFormatter = new MessagePackRecordFormatter();
            break;
        case JSONL:
            recordFormatter = new JsonlRecordFormatter();
            break;
        case CSV:
            CsvRecordFormatter.Config config = new CsvRecordFormatter.Config();
            config.setColumnNames(getFormatCsvColumnNames());
            recordFormatter = new CsvRecordFormatter(config);
            break;
        default:
            throw new IllegalArgumentException("Unexpected format type: " + getFormatType());
    }
    return recordFormatter;
}
Also used : AwsS3RecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.AwsS3RecordFormatter) CsvRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.CsvRecordFormatter) JsonlRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.JsonlRecordFormatter) MessagePackRecordFormatter(org.komamitsu.fluency.aws.s3.recordformat.MessagePackRecordFormatter)

Aggregations

AwsS3RecordFormatter (org.komamitsu.fluency.aws.s3.recordformat.AwsS3RecordFormatter)2 CsvRecordFormatter (org.komamitsu.fluency.aws.s3.recordformat.CsvRecordFormatter)2 JsonlRecordFormatter (org.komamitsu.fluency.aws.s3.recordformat.JsonlRecordFormatter)2 MessagePackRecordFormatter (org.komamitsu.fluency.aws.s3.recordformat.MessagePackRecordFormatter)2 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 Fluency (org.komamitsu.fluency.Fluency)1 AwsS3Ingester (org.komamitsu.fluency.aws.s3.ingester.AwsS3Ingester)1 DefaultS3DestinationDecider (org.komamitsu.fluency.aws.s3.ingester.DefaultS3DestinationDecider)1 AwsS3Sender (org.komamitsu.fluency.aws.s3.ingester.sender.AwsS3Sender)1 Buffer (org.komamitsu.fluency.buffer.Buffer)1 Flusher (org.komamitsu.fluency.flusher.Flusher)1 Ingester (org.komamitsu.fluency.ingester.Ingester)1 RecordFormatter (org.komamitsu.fluency.recordformat.RecordFormatter)1