Search in sources :

Example 1 with KafkaConsumerGroupClientImpl

use of io.confluent.ksql.services.KafkaConsumerGroupClientImpl in project ksql by confluentinc.

the class ListTopicsExecutor method execute.

public static StatementExecutorResponse execute(final ConfiguredStatement<ListTopics> statement, final SessionProperties sessionProperties, final KsqlExecutionContext executionContext, final ServiceContext serviceContext) {
    final KafkaTopicClient client = serviceContext.getTopicClient();
    final Map<String, TopicDescription> topicDescriptions = listTopics(client, statement);
    if (statement.getStatement().getShowExtended()) {
        final KafkaConsumerGroupClient consumerGroupClient = new KafkaConsumerGroupClientImpl(serviceContext::getAdminClient);
        final Map<String, List<Integer>> topicConsumersAndGroupCount = getTopicConsumerAndGroupCounts(consumerGroupClient);
        final List<KafkaTopicInfoExtended> topicInfoExtendedList = topicDescriptions.values().stream().map(desc -> topicDescriptionToTopicInfoExtended(desc, topicConsumersAndGroupCount)).collect(Collectors.toList());
        return StatementExecutorResponse.handled(Optional.of(new KafkaTopicsListExtended(statement.getStatementText(), topicInfoExtendedList)));
    } else {
        final List<KafkaTopicInfo> topicInfoList = topicDescriptions.values().stream().map(ListTopicsExecutor::topicDescriptionToTopicInfo).collect(Collectors.toList());
        return StatementExecutorResponse.handled(Optional.of(new KafkaTopicsList(statement.getStatementText(), topicInfoList)));
    }
}
Also used : Arrays(java.util.Arrays) SessionProperties(io.confluent.ksql.rest.SessionProperties) ListTopics(io.confluent.ksql.parser.tree.ListTopics) ServiceContext(io.confluent.ksql.services.ServiceContext) ConsumerSummary(io.confluent.ksql.services.KafkaConsumerGroupClient.ConsumerSummary) HashMap(java.util.HashMap) KafkaTopicsList(io.confluent.ksql.rest.entity.KafkaTopicsList) KafkaTopicsListExtended(io.confluent.ksql.rest.entity.KafkaTopicsListExtended) ReservedInternalTopics(io.confluent.ksql.util.ReservedInternalTopics) KafkaTopicClient(io.confluent.ksql.services.KafkaTopicClient) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) TopicDescription(org.apache.kafka.clients.admin.TopicDescription) TopicPartition(org.apache.kafka.common.TopicPartition) KafkaConsumerGroupClientImpl(io.confluent.ksql.services.KafkaConsumerGroupClientImpl) Collection(java.util.Collection) Set(java.util.Set) ConfiguredStatement(io.confluent.ksql.statement.ConfiguredStatement) Collectors(java.util.stream.Collectors) List(java.util.List) TreeMap(java.util.TreeMap) KsqlExecutionContext(io.confluent.ksql.KsqlExecutionContext) KafkaConsumerGroupClient(io.confluent.ksql.services.KafkaConsumerGroupClient) KafkaTopicInfoExtended(io.confluent.ksql.rest.entity.KafkaTopicInfoExtended) KafkaTopicInfo(io.confluent.ksql.rest.entity.KafkaTopicInfo) Optional(java.util.Optional) KafkaTopicsList(io.confluent.ksql.rest.entity.KafkaTopicsList) KafkaTopicsListExtended(io.confluent.ksql.rest.entity.KafkaTopicsListExtended) KafkaTopicInfo(io.confluent.ksql.rest.entity.KafkaTopicInfo) KafkaTopicClient(io.confluent.ksql.services.KafkaTopicClient) KafkaConsumerGroupClientImpl(io.confluent.ksql.services.KafkaConsumerGroupClientImpl) KafkaTopicInfoExtended(io.confluent.ksql.rest.entity.KafkaTopicInfoExtended) TopicDescription(org.apache.kafka.clients.admin.TopicDescription) KafkaTopicsList(io.confluent.ksql.rest.entity.KafkaTopicsList) ArrayList(java.util.ArrayList) List(java.util.List) KafkaConsumerGroupClient(io.confluent.ksql.services.KafkaConsumerGroupClient)

Example 2 with KafkaConsumerGroupClientImpl

use of io.confluent.ksql.services.KafkaConsumerGroupClientImpl in project ksql by confluentinc.

the class KafkaConsumerGroupClientTest method startUp.

@Before
public void startUp() {
    final KsqlConfig ksqlConfig = KsqlConfigTestUtil.create(TEST_HARNESS.getKafkaCluster());
    adminClient = AdminClient.create(ksqlConfig.getKsqlAdminClientConfigProps());
    consumerGroupClient = new KafkaConsumerGroupClientImpl(() -> adminClient);
    topicName = TopicTestUtil.uniqueTopicName();
    group0 = ConsumerGroupTestUtil.uniqueGroupId("0");
    group1 = ConsumerGroupTestUtil.uniqueGroupId("1");
}
Also used : KafkaConsumerGroupClientImpl(io.confluent.ksql.services.KafkaConsumerGroupClientImpl) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Before(org.junit.Before)

Aggregations

KafkaConsumerGroupClientImpl (io.confluent.ksql.services.KafkaConsumerGroupClientImpl)2 KsqlExecutionContext (io.confluent.ksql.KsqlExecutionContext)1 ListTopics (io.confluent.ksql.parser.tree.ListTopics)1 SessionProperties (io.confluent.ksql.rest.SessionProperties)1 KafkaTopicInfo (io.confluent.ksql.rest.entity.KafkaTopicInfo)1 KafkaTopicInfoExtended (io.confluent.ksql.rest.entity.KafkaTopicInfoExtended)1 KafkaTopicsList (io.confluent.ksql.rest.entity.KafkaTopicsList)1 KafkaTopicsListExtended (io.confluent.ksql.rest.entity.KafkaTopicsListExtended)1 KafkaConsumerGroupClient (io.confluent.ksql.services.KafkaConsumerGroupClient)1 ConsumerSummary (io.confluent.ksql.services.KafkaConsumerGroupClient.ConsumerSummary)1 KafkaTopicClient (io.confluent.ksql.services.KafkaTopicClient)1 ServiceContext (io.confluent.ksql.services.ServiceContext)1 ConfiguredStatement (io.confluent.ksql.statement.ConfiguredStatement)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 ReservedInternalTopics (io.confluent.ksql.util.ReservedInternalTopics)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1