You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/13 20:32:14 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #13679: Support dynamic update cache config

eolivelli commented on a change in pull request #13679:
URL: https://github.com/apache/pulsar/pull/13679#discussion_r825499966



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -2233,6 +2263,13 @@ private void updateBrokerPublisherThrottlingMaxRate() {
         }
     }
 
+    private void updateCacheSizeAndThreshold(long maxSize) {
+        ManagedLedgerFactoryImpl managedLedgerFactory = (ManagedLedgerFactoryImpl) pulsar().getManagedLedgerFactory();
+        double thresholdPercent = managedLedgerFactory.getEntryCacheManager().getEvictionTriggerThresholdPercent();
+        managedLedgerFactory.getEntryCacheManager().setMaxSize(maxSize);

Review comment:
       We should move these lines into  method in ManagedLedgerFactoryImpl
   Otherwise we are breaking incapsulation
   
   Probably it is better to add the new method to the interface and not only in the Impl classe

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -2233,6 +2263,13 @@ private void updateBrokerPublisherThrottlingMaxRate() {
         }
     }
 
+    private void updateCacheSizeAndThreshold(long maxSize) {
+        ManagedLedgerFactoryImpl managedLedgerFactory = (ManagedLedgerFactoryImpl) pulsar().getManagedLedgerFactory();
+        double thresholdPercent = managedLedgerFactory.getEntryCacheManager().getEvictionTriggerThresholdPercent();
+        managedLedgerFactory.getEntryCacheManager().setMaxSize(maxSize);

Review comment:
       The same applies to setCacheEvictionTimeThresholdNanos

##########
File path: managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/EntryCacheManager.java
##########
@@ -45,9 +47,12 @@
 @SuppressWarnings("checkstyle:javadoctype")
 public class EntryCacheManager {
 
-    private final long maxSize;
-    private final long evictionTriggerThreshold;
-    private final double cacheEvictionWatermark;
+    @Setter
+    private volatile long maxSize;
+    @Setter

Review comment:
       See my comments below
   We should add a new method and do not expose internals otherwise we are breaking encapsulation




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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org