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

 ##########
 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());
+            return getManagedLedgerOffloaderByPolicies(offloadPolicies);
+        } catch (Exception e) {
+            LOG.error("Failed to get ledgerOffloader for namespaceName {}", 
namespaceName, e);
+            return new NullLedgerOffloader();
+        }
     }
 
-    public synchronized LedgerOffloader 
createManagedLedgerOffloader(ServiceConfiguration conf)
+    public synchronized LedgerOffloader 
createManagedLedgerOffloader(ServiceConfiguration conf, OffloadPolicies 
offloadPolicies)
 
 Review comment:
   And current method checks the `conf.getManagedLedgerOffloadDriver()` is not 
blank, users may disable the default offloader but enable it at namespace level.

----------------------------------------------------------------
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