divijvaidya commented on code in PR #14243:
URL: https://github.com/apache/kafka/pull/14243#discussion_r1319733428


##########
core/src/main/scala/kafka/server/DynamicBrokerConfig.scala:
##########
@@ -1125,3 +1128,48 @@ class DynamicProducerStateManagerConfig(val 
producerStateManagerConfig: Producer
   override def reconfigurableConfigs: Set[String] = 
ProducerStateManagerConfig.RECONFIGURABLE_CONFIGS.asScala
 
 }
+
+class DynamicRemoteLogConfig(server: KafkaBroker) extends BrokerReconfigurable 
with Logging {
+  override def reconfigurableConfigs: Set[String] = {
+    DynamicRemoteLogConfigs
+  }
+
+  override def validateReconfiguration(newConfig: KafkaConfig): Unit = {
+    newConfig.values.forEach { (k, v) =>
+      if (DynamicRemoteLogConfigs.contains(k)) {
+        val newValue = v.asInstanceOf[Long]
+        val oldValue = getValue(server.config, k)
+        if (newValue != oldValue) {
+          val errorMsg = s"Dynamic remote log manager config update validation 
failed for $k=$v"
+          if (newValue <= 0)
+            throw new ConfigException(s"$errorMsg, value should be at least 1")
+        }
+      }
+    }
+  }
+
+  override def reconfigure(oldConfig: KafkaConfig, newConfig: KafkaConfig): 
Unit = {
+    val oldValue = 
oldConfig.getLong(RemoteLogManagerConfig.REMOTE_LOG_INDEX_FILE_CACHE_TOTAL_SIZE_BYTES_PROP)
+    val newValue = 
newConfig.getLong(RemoteLogManagerConfig.REMOTE_LOG_INDEX_FILE_CACHE_TOTAL_SIZE_BYTES_PROP)
+    if (oldValue != newValue) {
+      val remoteLogManager = server.remoteLogManager
+      if (remoteLogManager.nonEmpty) {
+        remoteLogManager.get.resizeCacheSize(newValue)

Review Comment:
   perhaps add a info log here that mentions the old and resized value



##########
core/src/test/scala/unit/kafka/server/DynamicBrokerConfigTest.scala:
##########
@@ -787,6 +788,31 @@ class DynamicBrokerConfigTest {
     verifyIncorrectLogLocalRetentionProps(2000L, 1000L, -1, 100)
   }
 
+  @Test
+  def testUpdateDynamicRemoteLogManagerConfig(): Unit = {

Review Comment:
   Could we also write a test that asserts that the index files on disk (at 
$logdir/remote-log-index-cache) belonging to older cache gets deleted after 
resize if done? Otherwise, we may end up with a file leak after resize.
   
   You can create this test at RemoteIndexCacheTest.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to