Skip to content

Commit

Permalink
MINOR: Remove zkclient dependency (apache#7036)
Browse files Browse the repository at this point in the history
ZkUtils was removed so we don't need this anymore.

Also:
* Fix ZkSecurityMigrator and ReplicaManagerTest not to
reference ZkClient classes.
* Remove references to zkclient in various `log4j.properties`
and `import-control.xml`.

Reviewers: Manikumar Reddy <[email protected]>, Stanislav Kozlovski <[email protected]>
  • Loading branch information
ijuma authored Jul 5, 2019
1 parent 2b529d1 commit 57903be
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 23 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,6 @@ project(':core') {
compile libs.scalaReflect
compile libs.scalaLogging
compile libs.slf4jApi
compile(libs.zkclient) {
exclude module: 'zookeeper'
}
compile(libs.zookeeper) {
exclude module: 'slf4j-log4j12'
exclude module: 'log4j'
Expand Down
1 change: 0 additions & 1 deletion checkstyle/import-control.xml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@

<subpackage name="processor">
<subpackage name="internals">
<allow pkg="org.I0Itec.zkclient" />
<allow pkg="com.fasterxml.jackson" />
<allow pkg="org.apache.zookeeper" />
<allow pkg="org.apache.zookeeper" />
Expand Down
1 change: 0 additions & 1 deletion config/connect-log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n

log4j.logger.org.apache.zookeeper=ERROR
log4j.logger.org.I0Itec.zkclient=ERROR
log4j.logger.org.reflections=ERROR
3 changes: 1 addition & 2 deletions config/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ log4j.appender.authorizerAppender.File=${kafka.logs.dir}/kafka-authorizer.log
log4j.appender.authorizerAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.authorizerAppender.layout.ConversionPattern=[%d] %p %m (%c)%n

# Change the two lines below to adjust ZK client logging
log4j.logger.org.I0Itec.zkclient.ZkClient=INFO
# Change the line below to adjust ZK client logging
log4j.logger.org.apache.zookeeper=INFO

# Change the two lines below to adjust the general broker logging level (output to server.log and stdout)
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/scala/kafka/admin/ZkSecurityMigrator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package kafka.admin

import kafka.utils.{CommandDefaultOptions, CommandLineUtils, Logging}
import kafka.zk.{KafkaZkClient, ZkData, ZkSecurityMigratorUtils}
import org.I0Itec.zkclient.exception.ZkException
import org.apache.kafka.common.security.JaasUtils
import org.apache.kafka.common.utils.Time
import org.apache.zookeeper.AsyncCallback.{ChildrenCallback, StatCallback}
Expand Down Expand Up @@ -182,10 +181,10 @@ class ZkSecurityMigrator(zkClient: KafkaZkClient) extends Logging {
// Starting a new session isn't really a problem, but it'd complicate
// the logic of the tool, so we quit and let the user re-run it.
System.out.println("ZooKeeper session expired while changing ACLs")
promise failure ZkException.create(KeeperException.create(Code.get(rc)))
promise failure KeeperException.create(Code.get(rc))
case _ =>
System.out.println("Unexpected return code: %d".format(rc))
promise failure ZkException.create(KeeperException.create(Code.get(rc)))
promise failure KeeperException.create(Code.get(rc))
}
}
}
Expand All @@ -211,10 +210,10 @@ class ZkSecurityMigrator(zkClient: KafkaZkClient) extends Logging {
// Starting a new session isn't really a problem, but it'd complicate
// the logic of the tool, so we quit and let the user re-run it.
System.out.println("ZooKeeper session expired while changing ACLs")
promise failure ZkException.create(KeeperException.create(Code.get(rc)))
promise failure KeeperException.create(Code.get(rc))
case _ =>
System.out.println("Unexpected return code: %d".format(rc))
promise failure ZkException.create(KeeperException.create(Code.get(rc)))
promise failure KeeperException.create(Code.get(rc))
}
}
}
Expand Down
1 change: 0 additions & 1 deletion core/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ log4j.logger.kafka=ERROR
log4j.logger.org.apache.kafka=ERROR

# zkclient can be verbose, during debugging it is common to adjust it separately
log4j.logger.org.I0Itec.zkclient.ZkClient=WARN
log4j.logger.org.apache.zookeeper=WARN
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import kafka.utils.TestUtils.createBroker
import kafka.utils.timer.MockTimer
import kafka.utils.{MockScheduler, MockTime, TestUtils}
import kafka.zk.KafkaZkClient
import org.I0Itec.zkclient.ZkClient
import org.apache.kafka.common.metrics.Metrics
import org.apache.kafka.common.protocol.{ApiKeys, Errors}
import org.apache.kafka.common.record._
Expand All @@ -50,7 +49,6 @@ import org.apache.kafka.common.requests.{EpochEndOffset, IsolationLevel, LeaderA
import org.apache.kafka.common.security.auth.KafkaPrincipal
import org.apache.kafka.common.utils.Time
import org.apache.kafka.common.{Node, TopicPartition}
import org.apache.zookeeper.data.Stat
import org.easymock.EasyMock
import org.junit.Assert._
import org.junit.{After, Before, Test}
Expand All @@ -63,7 +61,6 @@ class ReplicaManagerTest {
val topic = "test-topic"
val time = new MockTime
val metrics = new Metrics
var zkClient: ZkClient = _
var kafkaZkClient: KafkaZkClient = _

// Constants defined for readability
Expand All @@ -74,12 +71,9 @@ class ReplicaManagerTest {

@Before
def setUp() {
zkClient = EasyMock.createMock(classOf[ZkClient])
kafkaZkClient = EasyMock.createMock(classOf[KafkaZkClient])
EasyMock.expect(kafkaZkClient.getEntityConfigs(EasyMock.anyString(), EasyMock.anyString())).andReturn(new Properties()).anyTimes()
EasyMock.replay(kafkaZkClient)
EasyMock.expect(zkClient.readData(EasyMock.anyString(), EasyMock.anyObject[Stat])).andReturn(null).anyTimes()
EasyMock.replay(zkClient)
}

@After
Expand Down
2 changes: 0 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ versions += [
spotbugs: "3.1.12",
spotbugsPlugin: "1.6.9",
spotlessPlugin: "3.23.0",
zkclient: "0.11",
zookeeper: "3.4.14",
zstd: "1.4.0-1"
]
Expand Down Expand Up @@ -178,7 +177,6 @@ libs += [
slf4jApi: "org.slf4j:slf4j-api:$versions.slf4j",
slf4jlog4j: "org.slf4j:slf4j-log4j12:$versions.slf4j",
snappy: "org.xerial.snappy:snappy-java:$versions.snappy",
zkclient: "com.101tec:zkclient:$versions.zkclient",
zookeeper: "org.apache.zookeeper:zookeeper:$versions.zookeeper",
jfreechart: "jfreechart:jfreechart:$versions.jfreechart",
mavenArtifact: "org.apache.maven:maven-artifact:$versions.mavenArtifact",
Expand Down
1 change: 0 additions & 1 deletion tests/kafkatest/services/kafka/templates/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ log4j.logger.kafka.producer.async.DefaultEventHandler={{ log_level|default("DEBU
log4j.logger.kafka.client.ClientUtils={{ log_level|default("DEBUG") }}, kafkaInfoAppender, kafkaDebugAppender
log4j.logger.kafka.perf={{ log_level|default("DEBUG") }}, kafkaInfoAppender, kafkaDebugAppender
log4j.logger.kafka.perf.ProducerPerformance$ProducerThread={{ log_level|default("DEBUG") }}, kafkaInfoAppender, kafkaDebugAppender
log4j.logger.org.I0Itec.zkclient.ZkClient={{ log_level|default("DEBUG") }}, kafkaInfoAppender, kafkaDebugAppender
log4j.logger.kafka={{ log_level|default("DEBUG") }}, kafkaInfoAppender, kafkaDebugAppender

log4j.logger.kafka.network.RequestChannel$={{ log_level|default("DEBUG") }}, requestInfoAppender, requestDebugAppender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=[%d] %p %m (%c)%n

log4j.logger.org.apache.zookeeper=ERROR
log4j.logger.org.I0Itec.zkclient=ERROR
log4j.logger.org.reflections=ERROR

0 comments on commit 57903be

Please sign in to comment.