codelipenghui commented on a change in pull request #6183: Namespace level
offloader
URL: https://github.com/apache/pulsar/pull/6183#discussion_r373751420
##########
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:
Since the OffloadPolicies added, i think we can change this method to
createManagedLedgerOffloader(OffloadPolicies offloadPolicies). For default
offloader, just convert serverConfiguration to the OffloadPolicies.
----------------------------------------------------------------
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