Class BundleRangeCache

java.lang.Object
org.apache.pulsar.broker.loadbalance.impl.BundleRangeCache

public class BundleRangeCache extends Object
The cache for the bundle ranges. The first key is the broker id and the second key is the namespace name, the value is the set of bundle ranges of that namespace. When the broker key is accessed if the associated value is not present, an empty map will be created as the initial value that will never be removed. Therefore, for each broker, there could only be one internal map during the whole lifetime. Then it will be safe to apply the synchronized key word on the value for thread safe operations.
  • Constructor Details

    • BundleRangeCache

      public BundleRangeCache()
  • Method Details

    • reloadFromBundles

      public void reloadFromBundles(String broker, Stream<String> bundles)
    • add

      public void add(String broker, String namespace, String bundleRange)
    • getBundleRangeCount

      public int getBundleRangeCount(String broker, String namespace)
    • getBrokerToNamespacesMap

      public Map<String,List<String>> getBrokerToNamespacesMap()
      Get the map whose key is the broker and value is the namespace that has at least 1 cached bundle range.