sijie commented on a change in pull request #6077: Support delete inactive 
topic when subscriptions caught up
URL: https://github.com/apache/pulsar/pull/6077#discussion_r367985450
 
 

 ##########
 File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
 ##########
 @@ -254,6 +255,23 @@
         doc = "How often to check for inactive topics"
     )
     private int brokerDeleteInactiveTopicsFrequencySeconds = 60;
+
+    @FieldContext(
+        category = CATEGORY_POLICIES,
+        doc = "Set the inactive topic delete mode. Default is 
delete_when_no_subscriptions\n"
+        + "'delete_when_no_subscriptions' mode only delete the topic which has 
no subscriptions and no active producers\n"
+        + "'delete_when_subscriptions_caught_up' mode only delete the topic 
that all subscriptions has no backlogs(caught up)"
+        + "and no active producers/consumers"
+    )
+    private InactiveTopicDeleteMode brokerDeleteInactiveTopicsMode = 
InactiveTopicDeleteMode.delete_when_no_subscriptions;
+
+    @FieldContext(
+        category = CATEGORY_POLICIES,
+        doc = "Max duration of topic inactivity in seconds, default is 60s\n"
+        + "Topics that are inactive for longer than this value will be deleted"
+    )
+    private int brokerDeleteInactiveTopicsMaxInactiveDurationSeconds = 60;
 
 Review comment:
   I like the idea of introducing 
`brokerDeleteInactiveTopicsMaxInactiveDurationSeconds`. However, I think we 
need to keep backward compatibility here since it was using 
`brokerDeleteInactiveTopicsFrequencySeconds`. So what you can do here are the 
followings:
   
   1. use boxed type not primitive type. so it is `null` when this setting is 
not specified.
   
   ```
   private Integer brokerDeleteInactiveTopicsMaxInactiveDurationSeconds = null
   ```
   
   2. implementing the getter for this field.
   
   ```
   int getBrokerDeleteInactiveTopicsMaxInactiveDurationSeconds() {
        if (brokerDeleteInactiveTopicsMaxInactiveDurationSeconds == null) {
            return brokerDeleteInactiveTopicsFrequencySeconds;
        } else {
            return brokerDeleteInactiveTopicsMaxInactiveDurationSeconds;
        }
   }
   ```

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