public class OwnershipCache extends Object
| Constructor and Description |
|---|
OwnershipCache(PulsarService pulsar,
NamespaceBundleFactory bundleFactory,
NamespaceService namespaceService)
Constructor of
OwnershipCache. |
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<Boolean> |
checkOwnershipAsync(NamespaceBundle bundle)
Check whether this broker owns given namespace bundle.
|
CompletableFuture<Void> |
disableOwnership(NamespaceBundle bundle)
Disable bundle in local cache and on zk.
|
OwnedBundle |
getOwnedBundle(NamespaceBundle bundle)
Return the
OwnedBundle instance from the local cache. |
Optional<CompletableFuture<OwnedBundle>> |
getOwnedBundleAsync(NamespaceBundle bundle) |
Map<NamespaceBundle,OwnedBundle> |
getOwnedBundles()
Method to access the map of all
ServiceUnit objects owned by the local broker. |
CompletableFuture<Optional<NamespaceEphemeralData>> |
getOwnerAsync(NamespaceBundle suName)
Method to get the current owner of the
ServiceUnit. |
void |
invalidateLocalOwnerCache() |
boolean |
isNamespaceBundleOwned(NamespaceBundle bundle)
Checked whether a particular bundle is currently owned by this broker.
|
boolean |
refreshSelfOwnerInfo() |
CompletableFuture<Void> |
removeOwnership(NamespaceBundle bundle)
Method to remove the ownership of local broker on the
NamespaceBundle, if owned. |
CompletableFuture<Void> |
removeOwnership(NamespaceBundles bundles)
Method to remove ownership of all owned bundles.
|
CompletableFuture<NamespaceEphemeralData> |
tryAcquiringOwnership(NamespaceBundle bundle)
Method to get the current owner of the
ServiceUnit or set the local broker as the owner if absent. |
CompletableFuture<Void> |
updateBundleState(NamespaceBundle bundle,
boolean isActive)
Update bundle state in a local cache.
|
public OwnershipCache(PulsarService pulsar, NamespaceBundleFactory bundleFactory, NamespaceService namespaceService)
OwnershipCache.
the local broker URL that will be set as owner for the ServiceUnitpublic CompletableFuture<Boolean> checkOwnershipAsync(NamespaceBundle bundle)
bundle - namespace bundlepublic CompletableFuture<Optional<NamespaceEphemeralData>> getOwnerAsync(NamespaceBundle suName)
ServiceUnit.suName - name of the ServiceUnitZooKeeperException - throws exception if no ownership info is foundpublic CompletableFuture<NamespaceEphemeralData> tryAcquiringOwnership(NamespaceBundle bundle) throws Exception
ServiceUnit or set the local broker as the owner if absent.bundle - the NamespaceBundleZooKeeperExceptionpublic CompletableFuture<Void> removeOwnership(NamespaceBundle bundle)
NamespaceBundle, if owned.public CompletableFuture<Void> removeOwnership(NamespaceBundles bundles)
bundles - NamespaceBundles to remove from ownership cachepublic Map<NamespaceBundle,OwnedBundle> getOwnedBundles()
ServiceUnit objects owned by the local broker.ServiceUnit objectspublic boolean isNamespaceBundleOwned(NamespaceBundle bundle)
bundle - public OwnedBundle getOwnedBundle(NamespaceBundle bundle)
OwnedBundle instance from the local cache. Does not block.bundle - public Optional<CompletableFuture<OwnedBundle>> getOwnedBundleAsync(NamespaceBundle bundle)
public CompletableFuture<Void> disableOwnership(NamespaceBundle bundle)
bundle - Exceptionpublic CompletableFuture<Void> updateBundleState(NamespaceBundle bundle, boolean isActive)
bundle - Exceptionpublic void invalidateLocalOwnerCache()
public boolean refreshSelfOwnerInfo()
Copyright © 2017–2022 Apache Software Foundation. All rights reserved.