kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject [kafka] branch 2.7 updated: MINOR rename kafka.utils.Whitelist to IncludeList
Date Tue, 13 Oct 2020 19:39:07 GMT
This is an automated email from the ASF dual-hosted git repository.

gwenshap pushed a commit to branch 2.7
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.7 by this push:
     new dacd569  MINOR rename kafka.utils.Whitelist to IncludeList
dacd569 is described below

commit dacd5693ed0cd23aeae58dd3d5af576ea6632bb8
Author: Xavier Léauté <xvrl@apache.org>
AuthorDate: Tue Oct 13 12:36:52 2020 -0700

    MINOR rename kafka.utils.Whitelist to IncludeList
    
    rename internal classes, methods, and related constants for KIP-629
    
    Author: Xavier Léauté <xvrl@apache.org>
    
    Reviewers: Gwen Shapira
    
    Closes #9400 from xvrl/rename-topic-includelist
    
    (cherry picked from commit 0c044a77cb6a93130bf2f357f478c00344e0aad6)
    Signed-off-by: Gwen Shapira <cshapi@gmail.com>
---
 core/src/main/scala/kafka/admin/TopicCommand.scala | 16 ++++++++--------
 core/src/main/scala/kafka/tools/MirrorMaker.scala  |  2 +-
 .../kafka/tools/ReplicaVerificationTool.scala      |  4 ++--
 core/src/main/scala/kafka/utils/TopicFilter.scala  |  2 +-
 .../admin/TopicCommandWithAdminClientTest.scala    |  2 +-
 .../kafka/admin/TopicCommandWithZKClientTest.scala |  2 +-
 .../scala/unit/kafka/utils/TopicFilterTest.scala   | 22 +++++++++++-----------
 7 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/core/src/main/scala/kafka/admin/TopicCommand.scala b/core/src/main/scala/kafka/admin/TopicCommand.scala
index 25bb7c2..b9171bb 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 a899c86..c1146f2 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 ace06db..0060f3c 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 64e7d2a..075c147 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 31b8af9..a0051df 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 3568cd9..c43240f 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 4b623e9..b89f58c 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))
   }


Mime
View raw message