mmodzelewski commented on code in PR #2499: URL: https://github.com/apache/iggy/pull/2499#discussion_r2660630839
########## foreign/java/external-processors/iggy-connector-pinot/src/main/java/org/apache/iggy/connector/pinot/consumer/IggyPartitionGroupConsumer.java: ########## @@ -0,0 +1,295 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iggy.connector.pinot.consumer; + +import org.apache.iggy.client.async.tcp.AsyncIggyTcpClient; +import org.apache.iggy.connector.pinot.config.IggyStreamConfig; +import org.apache.iggy.consumergroup.Consumer; +import org.apache.iggy.identifier.ConsumerId; +import org.apache.iggy.identifier.StreamId; +import org.apache.iggy.identifier.TopicId; +import org.apache.iggy.message.Message; +import org.apache.iggy.message.PolledMessages; +import org.apache.iggy.message.PollingStrategy; +import org.apache.pinot.spi.stream.MessageBatch; +import org.apache.pinot.spi.stream.PartitionGroupConsumer; +import org.apache.pinot.spi.stream.StreamPartitionMsgOffset; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +/** + * Partition-level consumer implementation for Iggy streams. + * Reads messages from a single Iggy partition using the AsyncIggyTcpClient. + * + * <p>This consumer manages: + * <ul> + * <li>TCP connection to Iggy server</li> + * <li>Consumer group membership</li> + * <li>Message polling with offset tracking</li> + * <li>Automatic offset commit for consumer group</li> + * </ul> + */ +public class IggyPartitionGroupConsumer implements PartitionGroupConsumer { + + private static final Logger log = LoggerFactory.getLogger(IggyPartitionGroupConsumer.class); + + private final String clientId; + private final IggyStreamConfig config; + private final int partitionId; + + private AsyncIggyTcpClient asyncClient; + private StreamId streamId; + private TopicId topicId; + private Consumer consumer; + private boolean consumerGroupJoined; + private long currentOffset; + + /** + * Creates a new partition consumer. + * + * @param clientId unique identifier for this consumer + * @param config Iggy stream configuration + * @param partitionId the partition to consume from + */ + public IggyPartitionGroupConsumer(String clientId, IggyStreamConfig config, int partitionId) { + this.clientId = clientId; + this.config = config; + this.partitionId = partitionId; + this.consumerGroupJoined = false; + this.currentOffset = 0; + + log.info( + "Created IggyPartitionGroupConsumer: clientId={}, partition={}, config={}", + clientId, + partitionId, + config); + } + + /** + * Fetches the next batch of messages from the Iggy partition. + * This method is called repeatedly by Pinot to poll for new messages. + * + * @param startOffset the offset to start consuming from (may be null) + * @param timeoutMillis timeout for the fetch operation + * @return batch of messages, or empty batch if no messages available + */ + public MessageBatch fetchMessages(StreamPartitionMsgOffset startOffset, long timeoutMillis) { Review Comment: please see: https://github.com/apache/pinot/blob/6c87d2e55a02bcc4f97a27e997cce096b92524f6/pinot-spi/src/main/java/org/apache/pinot/spi/stream/PartitionGroupConsumer.java#L58 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
