diff --git a/core/src/main/scala/kafka/admin/TopicCommand.scala b/core/src/main/scala/kafka/admin/TopicCommand.scala index 25bb7c272d972..b9171bb7d34d6 100755 --- a/core/src/main/scala/kafka/admin/TopicCommand.scala +++ b/core/src/main/scala/kafka/admin/TopicCommand.scala @@ -216,7 +216,7 @@ object TopicCommand extends Logging { def alterTopic(opts: TopicCommandOptions): Unit def describeTopic(opts: TopicCommandOptions): Unit def deleteTopic(opts: TopicCommandOptions): Unit - def getTopics(topicWhitelist: Option[String], excludeInternalTopics: Boolean = false): Seq[String] + def getTopics(topicIncludelist: Option[String], excludeInternalTopics: Boolean = false): Seq[String] } object AdminClientTopicService { @@ -359,13 +359,13 @@ object TopicCommand extends Logging { .all().get() } - override def getTopics(topicWhitelist: Option[String], excludeInternalTopics: Boolean = false): Seq[String] = { + override def getTopics(topicIncludelist: Option[String], excludeInternalTopics: Boolean = false): Seq[String] = { val allTopics = if (excludeInternalTopics) { adminClient.listTopics() } else { adminClient.listTopics(new ListTopicsOptions().listInternal(true)) } - doGetTopics(allTopics.names().get().asScala.toSeq.sorted, topicWhitelist, excludeInternalTopics) + doGetTopics(allTopics.names().get().asScala.toSeq.sorted, topicIncludelist, excludeInternalTopics) } override def close(): Unit = adminClient.close() @@ -515,9 +515,9 @@ object TopicCommand extends Logging { } } - override def getTopics(topicWhitelist: Option[String], excludeInternalTopics: Boolean = false): Seq[String] = { + override def getTopics(topicIncludelist: Option[String], excludeInternalTopics: Boolean = false): Seq[String] = { val allTopics = zkClient.getAllTopicsInCluster().toSeq.sorted - doGetTopics(allTopics, topicWhitelist, excludeInternalTopics) + doGetTopics(allTopics, topicIncludelist, excludeInternalTopics) } override def close(): Unit = zkClient.close() @@ -540,9 +540,9 @@ object TopicCommand extends Logging { } } - private def doGetTopics(allTopics: Seq[String], topicWhitelist: Option[String], excludeInternalTopics: Boolean): Seq[String] = { - if (topicWhitelist.isDefined) { - val topicsFilter = Whitelist(topicWhitelist.get) + private def doGetTopics(allTopics: Seq[String], topicIncludeList: Option[String], excludeInternalTopics: Boolean): Seq[String] = { + if (topicIncludeList.isDefined) { + val topicsFilter = IncludeList(topicIncludeList.get) allTopics.filter(topicsFilter.isTopicAllowed(_, excludeInternalTopics)) } else allTopics.filterNot(Topic.isInternal(_) && excludeInternalTopics) diff --git a/core/src/main/scala/kafka/tools/MirrorMaker.scala b/core/src/main/scala/kafka/tools/MirrorMaker.scala index a899c86be69d2..c1146f2026503 100755 --- a/core/src/main/scala/kafka/tools/MirrorMaker.scala +++ b/core/src/main/scala/kafka/tools/MirrorMaker.scala @@ -306,7 +306,7 @@ object MirrorMaker extends Logging with KafkaMetricsGroup { val consumerRebalanceListener = new InternalRebalanceListener(this, customRebalanceListener) whitelistOpt.foreach { whitelist => try { - consumer.subscribe(Pattern.compile(Whitelist(whitelist).regex), consumerRebalanceListener) + consumer.subscribe(Pattern.compile(IncludeList(whitelist).regex), consumerRebalanceListener) } catch { case pse: RuntimeException => error(s"Invalid expression syntax: $whitelist") diff --git a/core/src/main/scala/kafka/tools/ReplicaVerificationTool.scala b/core/src/main/scala/kafka/tools/ReplicaVerificationTool.scala index ace06dbef6ac7..0060f3c69f909 100644 --- a/core/src/main/scala/kafka/tools/ReplicaVerificationTool.scala +++ b/core/src/main/scala/kafka/tools/ReplicaVerificationTool.scala @@ -27,7 +27,7 @@ import java.util.{Date, Optional, Properties} import joptsimple.OptionParser import kafka.api._ -import kafka.utils.Whitelist +import kafka.utils.IncludeList import kafka.utils._ import org.apache.kafka.clients._ import org.apache.kafka.clients.admin.{Admin, ListTopicsOptions, TopicDescription} @@ -121,7 +121,7 @@ object ReplicaVerificationTool extends Logging { CommandLineUtils.checkRequiredArgs(parser, options, brokerListOpt) val regex = options.valueOf(topicWhiteListOpt) - val topicWhiteListFiler = new Whitelist(regex) + val topicWhiteListFiler = new IncludeList(regex) try Pattern.compile(regex) catch { diff --git a/core/src/main/scala/kafka/utils/TopicFilter.scala b/core/src/main/scala/kafka/utils/TopicFilter.scala index 64e7d2acea830..075c14722ee96 100644 --- a/core/src/main/scala/kafka/utils/TopicFilter.scala +++ b/core/src/main/scala/kafka/utils/TopicFilter.scala @@ -43,7 +43,7 @@ sealed abstract class TopicFilter(rawRegex: String) extends Logging { def isTopicAllowed(topic: String, excludeInternalTopics: Boolean): Boolean } -case class Whitelist(rawRegex: String) extends TopicFilter(rawRegex) { +case class IncludeList(rawRegex: String) extends TopicFilter(rawRegex) { override def isTopicAllowed(topic: String, excludeInternalTopics: Boolean) = { val allowed = topic.matches(regex) && !(Topic.isInternal(topic) && excludeInternalTopics) diff --git a/core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala b/core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala index 31b8af9f229db..a0051dfa12fac 100644 --- a/core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala +++ b/core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala @@ -337,7 +337,7 @@ class TopicCommandWithAdminClientTest extends KafkaServerTestHarness with Loggin } @Test - def testListTopicsWithWhitelist(): Unit = { + def testListTopicsWithIncludeList(): Unit = { val topic1 = "kafka.testTopic1" val topic2 = "kafka.testTopic2" val topic3 = "oooof.testTopic1" diff --git a/core/src/test/scala/unit/kafka/admin/TopicCommandWithZKClientTest.scala b/core/src/test/scala/unit/kafka/admin/TopicCommandWithZKClientTest.scala index 3568cd9010e5f..c43240f0797ea 100644 --- a/core/src/test/scala/unit/kafka/admin/TopicCommandWithZKClientTest.scala +++ b/core/src/test/scala/unit/kafka/admin/TopicCommandWithZKClientTest.scala @@ -183,7 +183,7 @@ class TopicCommandWithZKClientTest extends ZooKeeperTestHarness with Logging wit } @Test - def testListTopicsWithWhitelist(): Unit = { + def testListTopicsWithIncludeList(): Unit = { val brokers = List(0, 1, 2) TestUtils.createBrokersInZk(zkClient, brokers) diff --git a/core/src/test/scala/unit/kafka/utils/TopicFilterTest.scala b/core/src/test/scala/unit/kafka/utils/TopicFilterTest.scala index 4b623e978c707..b89f58c28d114 100644 --- a/core/src/test/scala/unit/kafka/utils/TopicFilterTest.scala +++ b/core/src/test/scala/unit/kafka/utils/TopicFilterTest.scala @@ -24,24 +24,24 @@ import org.junit.Test class TopicFilterTest { @Test - def testWhitelists(): Unit = { + def testIncludeLists(): Unit = { - val topicFilter1 = Whitelist("white1,white2") - assertTrue(topicFilter1.isTopicAllowed("white2", excludeInternalTopics = true)) - assertTrue(topicFilter1.isTopicAllowed("white2", excludeInternalTopics = false)) - assertFalse(topicFilter1.isTopicAllowed("black1", excludeInternalTopics = true)) - assertFalse(topicFilter1.isTopicAllowed("black1", excludeInternalTopics = false)) + val topicFilter1 = IncludeList("yes1,yes2") + assertTrue(topicFilter1.isTopicAllowed("yes2", excludeInternalTopics = true)) + assertTrue(topicFilter1.isTopicAllowed("yes2", excludeInternalTopics = false)) + assertFalse(topicFilter1.isTopicAllowed("no1", excludeInternalTopics = true)) + assertFalse(topicFilter1.isTopicAllowed("no1", excludeInternalTopics = false)) - val topicFilter2 = Whitelist(".+") + val topicFilter2 = IncludeList(".+") assertTrue(topicFilter2.isTopicAllowed("alltopics", excludeInternalTopics = true)) assertFalse(topicFilter2.isTopicAllowed(Topic.GROUP_METADATA_TOPIC_NAME, excludeInternalTopics = true)) assertTrue(topicFilter2.isTopicAllowed(Topic.GROUP_METADATA_TOPIC_NAME, excludeInternalTopics = false)) - val topicFilter3 = Whitelist("white_listed-topic.+") - assertTrue(topicFilter3.isTopicAllowed("white_listed-topic1", excludeInternalTopics = true)) - assertFalse(topicFilter3.isTopicAllowed("black1", excludeInternalTopics = true)) + val topicFilter3 = IncludeList("included-topic.+") + assertTrue(topicFilter3.isTopicAllowed("included-topic1", excludeInternalTopics = true)) + assertFalse(topicFilter3.isTopicAllowed("no1", excludeInternalTopics = true)) - val topicFilter4 = Whitelist("test-(?!bad\\b)[\\w]+") + val topicFilter4 = IncludeList("test-(?!bad\\b)[\\w]+") assertTrue(topicFilter4.isTopicAllowed("test-good", excludeInternalTopics = true)) assertFalse(topicFilter4.isTopicAllowed("test-bad", excludeInternalTopics = true)) }