KAFKA-1398 Dynamic config follow-on-comments.
Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/4bcb22f4 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/4bcb22f4 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/4bcb22f4 Branch: refs/heads/0.8.1 Commit: 4bcb22f47e594c127b02d001620fd1f453034b2a Parents: 2ce7ff6 Author: Jay Kreps <jay.kr...@gmail.com> Authored: Fri Apr 18 11:03:37 2014 -0700 Committer: Joel Koshy <jjko...@gmail.com> Committed: Fri Apr 18 16:16:02 2014 -0700 ---------------------------------------------------------------------- .../scala/kafka/server/TopicConfigManager.scala | 6 +++--- .../unit/kafka/server/DynamicConfigChangeTest.scala | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/4bcb22f4/core/src/main/scala/kafka/server/TopicConfigManager.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/server/TopicConfigManager.scala b/core/src/main/scala/kafka/server/TopicConfigManager.scala index 4a4274e..47295d4 100644 --- a/core/src/main/scala/kafka/server/TopicConfigManager.scala +++ b/core/src/main/scala/kafka/server/TopicConfigManager.scala @@ -40,6 +40,7 @@ import org.I0Itec.zkclient.{IZkChildListener, ZkClient} * To update a topic config we first update the topic config properties. Then we create a new sequential * znode under the change path which contains the name of the topic that was updated, say * /brokers/config_changes/config_change_13321 + * This is just a notification--the actual config change is stored only once under the /brokers/topics/<topic_name>/config path. * * This will fire a watcher on all brokers. This watcher works as follows. It reads all the config change notifications. * It keeps track of the highest config change suffix number it has applied previously. For any previously applied change it finds @@ -94,7 +95,7 @@ class TopicConfigManager(private val zkClient: ZkClient, val changeId = changeNumber(notification) if (changeId > lastExecutedChange) { val changeZnode = ZkUtils.TopicConfigChangesPath + "/" + notification - val (jsonOpt, stat) = ZkUtils.readDataMaybeNull(zkClient, ZkUtils.TopicConfigChangesPath + "/" + notification) + val (jsonOpt, stat) = ZkUtils.readDataMaybeNull(zkClient, changeZnode) if(jsonOpt.isDefined) { val json = jsonOpt.get val topic = json.substring(1, json.length - 1) // hacky way to dequote @@ -116,8 +117,7 @@ class TopicConfigManager(private val zkClient: ZkClient, } private def purgeObsoleteNotifications(now: Long, notifications: Seq[String]) { - val eligible = notifications.sorted.dropRight(1) // never purge newest notification--we need it for the seq number - for(notification <- eligible) { + for(notification <- notifications.sorted) { val (jsonOpt, stat) = ZkUtils.readDataMaybeNull(zkClient, ZkUtils.TopicConfigChangesPath + "/" + notification) if(jsonOpt.isDefined) { val changeZnode = ZkUtils.TopicConfigChangesPath + "/" + notification http://git-wip-us.apache.org/repos/asf/kafka/blob/4bcb22f4/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala ---------------------------------------------------------------------- diff --git a/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala b/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala index 5a1d5cc..5c48796 100644 --- a/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala +++ b/core/src/test/scala/unit/kafka/server/DynamicConfigChangeTest.scala @@ -1,3 +1,19 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package kafka.server import junit.framework.Assert._