JavaScript is disabled on your browser.
public class SharePartitionCache
extends Object
The SharePartitionCache is used to cache the SharePartition objects. The cache is thread-safe.
Method Summary
All Methods Instance Methods Concrete Methods
Set <org.apache.kafka.server.share.SharePartitionKey>
Returns the set of all share partition keys in the cache.
Computes the value for the given key if it is not already present in the cache.
get (org.apache.kafka.server.share.SharePartitionKey partitionKey)
Returns the share partition for the given key.
remove (org.apache.kafka.server.share.SharePartitionKey partitionKey)
Removes the share partition from the cache.
Set <org.apache.kafka.common.TopicIdPartition>
Returns the set of topic-partitions for the given group id.
Method Details
get
public SharePartition get (org.apache.kafka.server.share.SharePartitionKey partitionKey)
Returns the share partition for the given key.
Parameters:
partitionKey - The key to get the share partition for.
Returns:
The share partition for the key or null if not found.
topicIdPartitionsForGroup
public Set <org.apache.kafka.common.TopicIdPartition> topicIdPartitionsForGroup (String groupId)
Returns the set of topic-partitions for the given group id.
Parameters:
groupId - The group id to get the topic-partitions for.
Returns:
The set of topic-partitions for the group id.
remove
public SharePartition remove (org.apache.kafka.server.share.SharePartitionKey partitionKey)
Removes the share partition from the cache. The method also removes the topic-partition from
the group map.
Parameters:
partitionKey - The key to remove.
Returns:
The removed value or null if not found.
computeIfAbsent
public SharePartition computeIfAbsent (org.apache.kafka.server.share.SharePartitionKey partitionKey,
Function <org.apache.kafka.server.share.SharePartitionKey,SharePartition > mappingFunction)
Computes the value for the given key if it is not already present in the cache. Method also
updates the group map with the topic-partition for the group id.
Parameters:
partitionKey - The key to compute the value for.
mappingFunction - The function to compute the value.
Returns:
The computed or existing value.
cachedSharePartitionKeys
public Set <org.apache.kafka.server.share.SharePartitionKey> cachedSharePartitionKeys ()
Returns the set of all share partition keys in the cache. As the cache can't be cleaned without
marking the share partitions fenced and detaching the partition listener in the replica manager,
hence rather providing a method to clean the cache directly, this method is provided to fetch
all the keys in the cache.
Returns:
The set of all share partition keys.