codelipenghui commented on a change in pull request #6183: Namespace level 
offloader
URL: https://github.com/apache/pulsar/pull/6183#discussion_r373751287
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java
 ##########
 @@ -764,11 +768,31 @@ public ManagedLedgerClientFactory 
getManagedLedgerClientFactory() {
         return managedLedgerClientFactory;
     }
 
-    public LedgerOffloader getManagedLedgerOffloader() {
-        return offloader;
+    public LedgerOffloader getManagedLedgerOffloaderByPolicies(OffloadPolicies 
offloadPolicies) {
+        if (offloadPolicies == null) {
+            return getDefaultOffloader();
+        }
+        return ledgerOffloaderMap.computeIfAbsent(offloadPolicies, op -> {
+            try {
+                return createManagedLedgerOffloader(getConfiguration(), 
offloadPolicies);
+            } catch (PulsarServerException e) {
+                LOG.error("create ledgerOffloader failed for {}", 
offloadPolicies.toString(), e);
+                return new NullLedgerOffloader();
+            }
+        });
+    }
+
+    public LedgerOffloader getManagedLedgerOffloader(NamespaceName 
namespaceName) {
+        try {
+            OffloadPolicies offloadPolicies = 
getAdminClient().namespaces().getOffload(namespaceName.toString());
 
 Review comment:
   Broker already have namespace policies caches, don't need to get it by admin 
client.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to