Search in sources :

Example 1 with ImmutableArrayValue

use of org.msgpack.value.ImmutableArrayValue in project fluency by komamitsu.

the class FluentdIngesterTest method ingestWithAck.

@Test
void ingestWithAck() throws IOException {
    FluentdIngester.Config config = new FluentdIngester.Config();
    config.setAckResponseMode(true);
    Ingester ingester = new FluentdIngester(config, fluentdSender);
    ingester.ingest(TAG, ByteBuffer.wrap(DATA));
    ArgumentCaptor<String> ackTokenArgumentCaptor = ArgumentCaptor.forClass(String.class);
    verify(fluentdSender, times(1)).sendWithAck(byteBuffersArgumentCaptor.capture(), ackTokenArgumentCaptor.capture());
    List<ByteBuffer> byteBuffers = byteBuffersArgumentCaptor.getAllValues().get(0);
    byte[] ingested = getIngestedData(byteBuffers);
    MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(ingested);
    ImmutableArrayValue arrayValue = unpacker.unpackValue().asArrayValue();
    assertEquals(3, arrayValue.size());
    assertEquals(TAG, arrayValue.get(0).asStringValue().asString());
    assertArrayEquals(DATA, arrayValue.get(1).asRawValue().asByteArray());
    Map<Value, Value> options = arrayValue.get(2).asMapValue().map();
    assertEquals(2, options.size());
    assertEquals(DATA.length, options.get(ValueFactory.newString("size")).asIntegerValue().asInt());
    String ackToken = options.get(ValueFactory.newString("chunk")).asRawValue().asString();
    List<String> ackTokenArgumentCaptorAllValues = ackTokenArgumentCaptor.getAllValues();
    assertEquals(1, ackTokenArgumentCaptorAllValues.size());
    assertEquals(ackToken, ackTokenArgumentCaptorAllValues.get(0));
}
Also used : ByteBuffer(java.nio.ByteBuffer) MessageUnpacker(org.msgpack.core.MessageUnpacker) ImmutableArrayValue(org.msgpack.value.ImmutableArrayValue) Value(org.msgpack.value.Value) Ingester(org.komamitsu.fluency.ingester.Ingester) ImmutableArrayValue(org.msgpack.value.ImmutableArrayValue) Test(org.junit.jupiter.api.Test)

Example 2 with ImmutableArrayValue

use of org.msgpack.value.ImmutableArrayValue in project fluency by komamitsu.

the class FluentdIngesterTest method ingestWithoutAck.

@Test
void ingestWithoutAck() throws IOException {
    Ingester ingester = new FluentdIngester(new FluentdIngester.Config(), fluentdSender);
    ingester.ingest(TAG, ByteBuffer.wrap(DATA));
    verify(fluentdSender, times(1)).send(byteBuffersArgumentCaptor.capture());
    List<ByteBuffer> byteBuffers = byteBuffersArgumentCaptor.getAllValues().get(0);
    byte[] ingested = getIngestedData(byteBuffers);
    MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(ingested);
    ImmutableArrayValue arrayValue = unpacker.unpackValue().asArrayValue();
    assertEquals(3, arrayValue.size());
    assertEquals(TAG, arrayValue.get(0).asStringValue().asString());
    assertArrayEquals(DATA, arrayValue.get(1).asRawValue().asByteArray());
    Map<Value, Value> options = arrayValue.get(2).asMapValue().map();
    assertEquals(1, options.size());
    assertEquals(DATA.length, options.get(ValueFactory.newString("size")).asIntegerValue().asInt());
}
Also used : MessageUnpacker(org.msgpack.core.MessageUnpacker) ImmutableArrayValue(org.msgpack.value.ImmutableArrayValue) Value(org.msgpack.value.Value) Ingester(org.komamitsu.fluency.ingester.Ingester) ImmutableArrayValue(org.msgpack.value.ImmutableArrayValue) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)2 Test (org.junit.jupiter.api.Test)2 Ingester (org.komamitsu.fluency.ingester.Ingester)2 MessageUnpacker (org.msgpack.core.MessageUnpacker)2 ImmutableArrayValue (org.msgpack.value.ImmutableArrayValue)2 Value (org.msgpack.value.Value)2