Search in sources :

Example 1 with KafkaFlushExFW

use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW in project zilla by aklivity.

the class KafkaFunctionsTest method shouldGenerateFetchFlushExtensionWithLatestOffset.

@Test
public void shouldGenerateFetchFlushExtensionWithLatestOffset() {
    byte[] build = KafkaFunctions.flushEx().typeId(0x01).fetch().partition(0, 1L, 1L).build().build();
    DirectBuffer buffer = new UnsafeBuffer(build);
    KafkaFlushExFW flushEx = new KafkaFlushExFW().wrap(buffer, 0, buffer.capacity());
    assertEquals(0x01, flushEx.typeId());
    final KafkaFetchFlushExFW fetchFlushEx = flushEx.fetch();
    final KafkaOffsetFW partition = fetchFlushEx.partition();
    assertEquals(0, partition.partitionId());
    assertEquals(1L, partition.partitionOffset());
    assertEquals(1L, partition.latestOffset());
}
Also used : DirectBuffer(org.agrona.DirectBuffer) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Test(org.junit.Test)

Example 2 with KafkaFlushExFW

use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW in project zilla by aklivity.

the class KafkaFunctionsTest method shouldGenerateFetchFlushExtension.

@Test
public void shouldGenerateFetchFlushExtension() {
    byte[] build = KafkaFunctions.flushEx().typeId(0x01).fetch().partition(0, 1L).build().build();
    DirectBuffer buffer = new UnsafeBuffer(build);
    KafkaFlushExFW flushEx = new KafkaFlushExFW().wrap(buffer, 0, buffer.capacity());
    assertEquals(0x01, flushEx.typeId());
    final KafkaFetchFlushExFW fetchFlushEx = flushEx.fetch();
    final KafkaOffsetFW partition = fetchFlushEx.partition();
    assertEquals(0, partition.partitionId());
    assertEquals(1L, partition.partitionOffset());
}
Also used : DirectBuffer(org.agrona.DirectBuffer) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Test(org.junit.Test)

Example 3 with KafkaFlushExFW

use of io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW in project zilla by aklivity.

the class KafkaFunctionsTest method shouldGenerateMergedFlushExtension.

@Test
public void shouldGenerateMergedFlushExtension() {
    byte[] build = KafkaFunctions.flushEx().typeId(0x01).merged().progress(0, 1L).filter().key("match").build().filter().header("name", "value").build().build().build();
    DirectBuffer buffer = new UnsafeBuffer(build);
    KafkaFlushExFW flushEx = new KafkaFlushExFW().wrap(buffer, 0, buffer.capacity());
    assertEquals(0x01, flushEx.typeId());
    final KafkaMergedFlushExFW mergedFlushEx = flushEx.merged();
    final MutableInteger partitionsCount = new MutableInteger();
    mergedFlushEx.progress().forEach(f -> partitionsCount.value++);
    assertEquals(1, partitionsCount.value);
    assertNotNull(mergedFlushEx.progress().matchFirst(p -> p.partitionId() == 0 && p.partitionOffset() == 1L));
    final MutableInteger filterCount = new MutableInteger();
    mergedFlushEx.filters().forEach(f -> filterCount.value++);
    assertEquals(2, filterCount.value);
    assertNotNull(mergedFlushEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == KEY.value() && "match".equals(c.key().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null));
    assertNotNull(mergedFlushEx.filters().matchFirst(f -> f.conditions().matchFirst(c -> c.kind() == HEADER.value() && "name".equals(c.header().name().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o))) && "value".equals(c.header().value().get((b, o, m) -> b.getStringWithoutLengthUtf8(o, m - o)))) != null));
}
Also used : DirectBuffer(org.agrona.DirectBuffer) KafkaDeltaType(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaDeltaType) KafkaDescribeBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW) ExpressionFactory(javax.el.ExpressionFactory) KafkaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDataExFW) KafkaSkip(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaSkip) KafkaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) KafkaBootstrapBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW) KafkaOffsetFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW) ByteBuffer(java.nio.ByteBuffer) KafkaValueMatchFW(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaValueMatchFW) KafkaMergedFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedFlushExFW) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) HEADER(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADER) Array32FW(io.aklivity.zilla.specs.binding.kafka.internal.types.Array32FW) KafkaMetaDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaDataExFW) MutableInteger(org.agrona.collections.MutableInteger) Before(org.junit.Before) KafkaMergedBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedBeginExFW) KafkaFetchFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW) ExpressionFactoryUtils.newExpressionFactory(org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) KafkaMetaBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMetaBeginExFW) Test(org.junit.Test) HEADERS(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADERS) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) OctetsFW(io.aklivity.zilla.specs.binding.kafka.internal.types.OctetsFW) Objects(java.util.Objects) KafkaFetchDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchDataExFW) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) KafkaDescribeDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeDataExFW) KafkaFetchBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchBeginExFW) NOT(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.NOT) ValueExpression(javax.el.ValueExpression) KafkaApi(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaApi) KEY(io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.KEY) KafkaProduceBeginExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceBeginExFW) ELContext(javax.el.ELContext) Assert.assertEquals(org.junit.Assert.assertEquals) KafkaMergedDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedDataExFW) KafkaProduceDataExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaProduceDataExFW) DirectBuffer(org.agrona.DirectBuffer) KafkaMergedFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaMergedFlushExFW) MutableInteger(org.agrona.collections.MutableInteger) KafkaFlushExFW(io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Test(org.junit.Test)

Aggregations

KafkaOffsetFW (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaOffsetFW)3 KafkaFetchFlushExFW (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFetchFlushExFW)3 KafkaFlushExFW (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaFlushExFW)3 DirectBuffer (org.agrona.DirectBuffer)3 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)3 Test (org.junit.Test)3 Array32FW (io.aklivity.zilla.specs.binding.kafka.internal.types.Array32FW)1 HEADER (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADER)1 HEADERS (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.HEADERS)1 KEY (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.KEY)1 NOT (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaConditionType.NOT)1 KafkaDeltaType (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaDeltaType)1 KafkaSkip (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaSkip)1 KafkaValueMatchFW (io.aklivity.zilla.specs.binding.kafka.internal.types.KafkaValueMatchFW)1 OctetsFW (io.aklivity.zilla.specs.binding.kafka.internal.types.OctetsFW)1 KafkaApi (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaApi)1 KafkaBeginExFW (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBeginExFW)1 KafkaBootstrapBeginExFW (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW)1 KafkaDataExFW (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDataExFW)1 KafkaDescribeBeginExFW (io.aklivity.zilla.specs.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW)1