@@ -757,21 +757,42 @@ public CompletableFuture<Void> unloadNamespaceBundle(NamespaceBundle bundle) {
757
757
}
758
758
759
759
public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle , Optional <String > destinationBroker ) {
760
- if (ExtensibleLoadManagerImpl .isLoadManagerExtensionEnabled (config )) {
761
- return ExtensibleLoadManagerImpl .get (loadManager .get ())
762
- .unloadNamespaceBundleAsync (bundle , destinationBroker );
763
- }
760
+
764
761
// unload namespace bundle
765
- return unloadNamespaceBundle (bundle , config .getNamespaceBundleUnloadingTimeoutMs (), TimeUnit .MILLISECONDS );
762
+ return unloadNamespaceBundle (bundle , destinationBroker ,
763
+ config .getNamespaceBundleUnloadingTimeoutMs (), TimeUnit .MILLISECONDS );
764
+ }
765
+
766
+ public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle ,
767
+ Optional <String > destinationBroker ,
768
+ long timeout ,
769
+ TimeUnit timeoutUnit ) {
770
+ return unloadNamespaceBundle (bundle , destinationBroker , timeout , timeoutUnit , true );
771
+ }
772
+
773
+ public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle ,
774
+ long timeout ,
775
+ TimeUnit timeoutUnit ) {
776
+ return unloadNamespaceBundle (bundle , Optional .empty (), timeout , timeoutUnit , true );
766
777
}
767
778
768
- public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle , long timeout , TimeUnit timeoutUnit ) {
769
- return unloadNamespaceBundle (bundle , timeout , timeoutUnit , true );
779
+ public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle ,
780
+ long timeout ,
781
+ TimeUnit timeoutUnit ,
782
+ boolean closeWithoutWaitingClientDisconnect ) {
783
+ return unloadNamespaceBundle (bundle , Optional .empty (), timeout ,
784
+ timeoutUnit , closeWithoutWaitingClientDisconnect );
770
785
}
771
786
772
- public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle , long timeout ,
787
+ public CompletableFuture <Void > unloadNamespaceBundle (NamespaceBundle bundle ,
788
+ Optional <String > destinationBroker ,
789
+ long timeout ,
773
790
TimeUnit timeoutUnit ,
774
791
boolean closeWithoutWaitingClientDisconnect ) {
792
+ if (ExtensibleLoadManagerImpl .isLoadManagerExtensionEnabled (config )) {
793
+ return ExtensibleLoadManagerImpl .get (loadManager .get ())
794
+ .unloadNamespaceBundleAsync (bundle , destinationBroker );
795
+ }
775
796
// unload namespace bundle
776
797
OwnedBundle ob = ownershipCache .getOwnedBundle (bundle );
777
798
if (ob == null ) {
@@ -790,24 +811,34 @@ public CompletableFuture<Map<String, NamespaceOwnershipStatus>> getOwnedNameSpac
790
811
.getIsolationDataPoliciesAsync (pulsar .getConfiguration ().getClusterName ())
791
812
.thenApply (nsIsolationPoliciesOpt -> nsIsolationPoliciesOpt .orElseGet (NamespaceIsolationPolicies ::new ))
792
813
.thenCompose (namespaceIsolationPolicies -> {
814
+ if (ExtensibleLoadManagerImpl .isLoadManagerExtensionEnabled (config )) {
815
+ ExtensibleLoadManagerImpl extensibleLoadManager =
816
+ ExtensibleLoadManagerImpl .get (loadManager .get ());
817
+ var statusMap = extensibleLoadManager .getOwnedServiceUnits ().stream ()
818
+ .collect (Collectors .toMap (NamespaceBundle ::toString ,
819
+ bundle -> getNamespaceOwnershipStatus (true ,
820
+ namespaceIsolationPolicies .getPolicyByNamespace (
821
+ bundle .getNamespaceObject ()))));
822
+ return CompletableFuture .completedFuture (statusMap );
823
+ }
793
824
Collection <CompletableFuture <OwnedBundle >> futures =
794
825
ownershipCache .getOwnedBundlesAsync ().values ();
795
826
return FutureUtil .waitForAll (futures )
796
827
.thenApply (__ -> futures .stream ()
797
828
.map (CompletableFuture ::join )
798
829
.collect (Collectors .toMap (bundle -> bundle .getNamespaceBundle ().toString (),
799
- bundle -> getNamespaceOwnershipStatus (bundle ,
830
+ bundle -> getNamespaceOwnershipStatus (bundle . isActive () ,
800
831
namespaceIsolationPolicies .getPolicyByNamespace (
801
832
bundle .getNamespaceBundle ().getNamespaceObject ()))
802
833
))
803
834
);
804
835
});
805
836
}
806
837
807
- private NamespaceOwnershipStatus getNamespaceOwnershipStatus (OwnedBundle nsObj ,
838
+ private NamespaceOwnershipStatus getNamespaceOwnershipStatus (boolean isActive ,
808
839
NamespaceIsolationPolicy nsIsolationPolicy ) {
809
840
NamespaceOwnershipStatus nsOwnedStatus = new NamespaceOwnershipStatus (BrokerAssignment .shared , false ,
810
- nsObj . isActive () );
841
+ isActive );
811
842
if (nsIsolationPolicy == null ) {
812
843
// no matching policy found, this namespace must be an uncontrolled one and using shared broker
813
844
return nsOwnedStatus ;
@@ -1103,6 +1134,10 @@ public OwnershipCache getOwnershipCache() {
1103
1134
}
1104
1135
1105
1136
public Set <NamespaceBundle > getOwnedServiceUnits () {
1137
+ if (ExtensibleLoadManagerImpl .isLoadManagerExtensionEnabled (config )) {
1138
+ ExtensibleLoadManagerImpl extensibleLoadManager = ExtensibleLoadManagerImpl .get (loadManager .get ());
1139
+ return extensibleLoadManager .getOwnedServiceUnits ();
1140
+ }
1106
1141
return ownershipCache .getOwnedBundles ().values ().stream ().map (OwnedBundle ::getNamespaceBundle )
1107
1142
.collect (Collectors .toSet ());
1108
1143
}
0 commit comments