Search in sources :

Example 1 with RangeAssignor

use of org.apache.kafka.clients.consumer.RangeAssignor in project kafka by apache.

the class ConsumerCoordinatorTest method testProtocolMetadataOrder.

@Test
public void testProtocolMetadataOrder() {
    RoundRobinAssignor roundRobin = new RoundRobinAssignor();
    RangeAssignor range = new RangeAssignor();
    try (Metrics metrics = new Metrics(time)) {
        ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(roundRobin, range), ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false);
        List<ProtocolMetadata> metadata = coordinator.metadata();
        assertEquals(2, metadata.size());
        assertEquals(roundRobin.name(), metadata.get(0).name());
        assertEquals(range.name(), metadata.get(1).name());
    }
    try (Metrics metrics = new Metrics(time)) {
        ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(range, roundRobin), ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false);
        List<ProtocolMetadata> metadata = coordinator.metadata();
        assertEquals(2, metadata.size());
        assertEquals(range.name(), metadata.get(0).name());
        assertEquals(roundRobin.name(), metadata.get(1).name());
    }
}
Also used : Metrics(org.apache.kafka.common.metrics.Metrics) RangeAssignor(org.apache.kafka.clients.consumer.RangeAssignor) RoundRobinAssignor(org.apache.kafka.clients.consumer.RoundRobinAssignor) ProtocolMetadata(org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata) Test(org.junit.Test)

Example 2 with RangeAssignor

use of org.apache.kafka.clients.consumer.RangeAssignor in project apache-kafka-on-k8s by banzaicloud.

the class ConsumerCoordinatorTest method testProtocolMetadataOrder.

@Test
public void testProtocolMetadataOrder() {
    RoundRobinAssignor roundRobin = new RoundRobinAssignor();
    RangeAssignor range = new RangeAssignor();
    try (Metrics metrics = new Metrics(time)) {
        ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(roundRobin, range), ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false, true);
        List<ProtocolMetadata> metadata = coordinator.metadata();
        assertEquals(2, metadata.size());
        assertEquals(roundRobin.name(), metadata.get(0).name());
        assertEquals(range.name(), metadata.get(1).name());
    }
    try (Metrics metrics = new Metrics(time)) {
        ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(range, roundRobin), ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false, true);
        List<ProtocolMetadata> metadata = coordinator.metadata();
        assertEquals(2, metadata.size());
        assertEquals(range.name(), metadata.get(0).name());
        assertEquals(roundRobin.name(), metadata.get(1).name());
    }
}
Also used : Metrics(org.apache.kafka.common.metrics.Metrics) RangeAssignor(org.apache.kafka.clients.consumer.RangeAssignor) RoundRobinAssignor(org.apache.kafka.clients.consumer.RoundRobinAssignor) ProtocolMetadata(org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata) Test(org.junit.Test)

Aggregations

RangeAssignor (org.apache.kafka.clients.consumer.RangeAssignor)2 RoundRobinAssignor (org.apache.kafka.clients.consumer.RoundRobinAssignor)2 Metrics (org.apache.kafka.common.metrics.Metrics)2 ProtocolMetadata (org.apache.kafka.common.requests.JoinGroupRequest.ProtocolMetadata)2 Test (org.junit.Test)2