Class SharePartitionManager

java.lang.Object
kafka.server.share.SharePartitionManager
All Implemented Interfaces:
AutoCloseable

public class SharePartitionManager extends Object implements AutoCloseable
The SharePartitionManager is responsible for managing the SharePartitions and ShareSessions. It is responsible for fetching messages from the log and acknowledging the messages.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SharePartitionManager(kafka.server.ReplicaManager replicaManager, org.apache.kafka.common.utils.Time time, org.apache.kafka.server.share.session.ShareSessionCache cache, int defaultRecordLockDurationMs, int maxDeliveryCount, int maxInFlightMessages, long remoteFetchMaxWaitMs, org.apache.kafka.server.share.persister.Persister persister, org.apache.kafka.coordinator.group.GroupConfigManager groupConfigManager, org.apache.kafka.storage.log.metrics.BrokerTopicStats brokerTopicStats)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    CompletableFuture<Map<org.apache.kafka.common.TopicIdPartition,org.apache.kafka.common.message.ShareAcknowledgeResponseData.PartitionData>>
    acknowledge(String memberId, String groupId, Map<org.apache.kafka.common.TopicIdPartition,List<org.apache.kafka.server.share.acknowledge.ShareAcknowledgementBatch>> acknowledgeTopics)
    The acknowledge method is used to acknowledge the messages that have been fetched.
    void
    acknowledgeSessionUpdate(String groupId, org.apache.kafka.common.requests.ShareRequestMetadata reqMetadata)
    The acknowledgeSessionUpdate method is used to update the request epoch and lastUsed time of the share session.
    void
     
    The method creates a timer task to delay the share fetch request for maxWaitMs duration.
    CompletableFuture<Map<org.apache.kafka.common.TopicIdPartition,org.apache.kafka.common.message.ShareFetchResponseData.PartitionData>>
    fetchMessages(String groupId, String memberId, org.apache.kafka.server.storage.log.FetchParams fetchParams, int sessionEpoch, int maxFetchRecords, int batchSize, List<org.apache.kafka.common.TopicIdPartition> topicIdPartitions)
    The fetch messages method is used to fetch messages from the log for the specified topic-partitions.
    org.apache.kafka.server.share.context.ShareFetchContext
    newContext(String groupId, List<org.apache.kafka.common.TopicIdPartition> shareFetchData, List<org.apache.kafka.common.TopicIdPartition> toForget, org.apache.kafka.common.requests.ShareRequestMetadata reqMetadata, Boolean isAcknowledgeDataPresent, String clientConnectionId)
    The newContext method is used to create a new share fetch context for every share fetch request.
    void
    onShareVersionToggle(org.apache.kafka.server.common.ShareVersion shareVersion, boolean isEnabledFromConfig)
    The handler for share version feature metadata changes.
    CompletableFuture<Map<org.apache.kafka.common.TopicIdPartition,org.apache.kafka.common.message.ShareAcknowledgeResponseData.PartitionData>>
    releaseSession(String groupId, String memberId)
    The release session method is used to release the session for the memberId of respective group.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SharePartitionManager

      public SharePartitionManager(kafka.server.ReplicaManager replicaManager, org.apache.kafka.common.utils.Time time, org.apache.kafka.server.share.session.ShareSessionCache cache, int defaultRecordLockDurationMs, int maxDeliveryCount, int maxInFlightMessages, long remoteFetchMaxWaitMs, org.apache.kafka.server.share.persister.Persister persister, org.apache.kafka.coordinator.group.GroupConfigManager groupConfigManager, org.apache.kafka.storage.log.metrics.BrokerTopicStats brokerTopicStats)
  • Method Details

    • fetchMessages

      public CompletableFuture<Map<org.apache.kafka.common.TopicIdPartition,org.apache.kafka.common.message.ShareFetchResponseData.PartitionData>> fetchMessages(String groupId, String memberId, org.apache.kafka.server.storage.log.FetchParams fetchParams, int sessionEpoch, int maxFetchRecords, int batchSize, List<org.apache.kafka.common.TopicIdPartition> topicIdPartitions)
      The fetch messages method is used to fetch messages from the log for the specified topic-partitions. The method returns a future that will be completed with the fetched messages.
      Parameters:
      groupId - The group id, this is used to identify the share group.
      memberId - The member id, generated by the group-coordinator, this is used to identify the client.
      fetchParams - The fetch parameters from the share fetch request.
      sessionEpoch - The session epoch for the member.
      maxFetchRecords - The maximum number of records to fetch.
      batchSize - The number of records per acquired records batch.
      topicIdPartitions - The topic partitions to fetch for.
      Returns:
      A future that will be completed with the fetched messages.
    • acknowledge

      public CompletableFuture<Map<org.apache.kafka.common.TopicIdPartition,org.apache.kafka.common.message.ShareAcknowledgeResponseData.PartitionData>> acknowledge(String memberId, String groupId, Map<org.apache.kafka.common.TopicIdPartition,List<org.apache.kafka.server.share.acknowledge.ShareAcknowledgementBatch>> acknowledgeTopics)
      The acknowledge method is used to acknowledge the messages that have been fetched. The method returns a future that will be completed with the acknowledge response.
      Parameters:
      memberId - The member id, generated by the group-coordinator, this is used to identify the client.
      groupId - The group id, this is used to identify the share group.
      acknowledgeTopics - The acknowledge topics and their corresponding acknowledge batches.
      Returns:
      A future that will be completed with the acknowledge response.
    • releaseSession

      public CompletableFuture<Map<org.apache.kafka.common.TopicIdPartition,org.apache.kafka.common.message.ShareAcknowledgeResponseData.PartitionData>> releaseSession(String groupId, String memberId)
      The release session method is used to release the session for the memberId of respective group. The method post removing session also releases acquired records for the respective member. The method returns a future that will be completed with the release response.
      Parameters:
      groupId - The group id, this is used to identify the share group.
      memberId - The member id, generated by the group-coordinator, this is used to identify the client.
      Returns:
      A future that will be completed with the release response.
    • createIdleShareFetchTimerTask

      public CompletableFuture<Void> createIdleShareFetchTimerTask(long maxWaitMs)
      The method creates a timer task to delay the share fetch request for maxWaitMs duration. A future is created and returned which will be completed when the timer task is completed.
      Parameters:
      maxWaitMs - The duration after which the timer task will be completed.
      Returns:
      A future that will be completed when the timer task is completed.
    • newContext

      public org.apache.kafka.server.share.context.ShareFetchContext newContext(String groupId, List<org.apache.kafka.common.TopicIdPartition> shareFetchData, List<org.apache.kafka.common.TopicIdPartition> toForget, org.apache.kafka.common.requests.ShareRequestMetadata reqMetadata, Boolean isAcknowledgeDataPresent, String clientConnectionId)
      The newContext method is used to create a new share fetch context for every share fetch request.
      Parameters:
      groupId - The group id in the share fetch request.
      shareFetchData - The topic-partitions in the share fetch request.
      toForget - The topic-partitions to forget present in the share fetch request.
      reqMetadata - The metadata in the share fetch request.
      isAcknowledgeDataPresent - This tells whether the fetch request received includes piggybacked acknowledgements or not.
      clientConnectionId - The client connection id.
      Returns:
      The new share fetch context object
    • acknowledgeSessionUpdate

      public void acknowledgeSessionUpdate(String groupId, org.apache.kafka.common.requests.ShareRequestMetadata reqMetadata)
      The acknowledgeSessionUpdate method is used to update the request epoch and lastUsed time of the share session.
      Parameters:
      groupId - The group id in the share fetch request.
      reqMetadata - The metadata in the share acknowledge request.
    • onShareVersionToggle

      public void onShareVersionToggle(org.apache.kafka.server.common.ShareVersion shareVersion, boolean isEnabledFromConfig)
      The handler for share version feature metadata changes.
      Parameters:
      shareVersion - the new share version feature
      isEnabledFromConfig - whether the share version feature is enabled from config
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception