You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/12/23 08:47:00 UTC

[jira] [Commented] (KAFKA-6141) Errors logs when running integration/kafka/tools/MirrorMakerIntegrationTest

    [ https://issues.apache.org/jira/browse/KAFKA-6141?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16302283#comment-16302283 ] 

ASF GitHub Bot commented on KAFKA-6141:
---------------------------------------

ijuma closed pull request #4153: KAFKA-6141: add disabling of useless embedded zookeeper error logs
URL: https://github.com/apache/kafka/pull/4153
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/core/src/test/scala/unit/kafka/zk/EmbeddedZookeeper.scala b/core/src/test/scala/unit/kafka/zk/EmbeddedZookeeper.scala
index adc8d052f57..27d69715caa 100755
--- a/core/src/test/scala/unit/kafka/zk/EmbeddedZookeeper.scala
+++ b/core/src/test/scala/unit/kafka/zk/EmbeddedZookeeper.scala
@@ -17,13 +17,15 @@
 
 package kafka.zk
 
-import org.apache.zookeeper.server.ZooKeeperServer
-import org.apache.zookeeper.server.NIOServerCnxnFactory
-import kafka.utils.TestUtils
+import java.lang.reflect.{Constructor, Field}
 import java.net.InetSocketAddress
+import java.util.concurrent.CountDownLatch
 
-import kafka.utils.CoreUtils
+import kafka.utils.{CoreUtils, TestUtils}
 import org.apache.kafka.common.utils.Utils
+import org.apache.zookeeper.server.{NIOServerCnxnFactory, ZooKeeperServer}
+
+import scala.util.Try
 
 /**
  * ZooKeeperServer wrapper that starts the server with temporary directories during construction and deletes
@@ -41,6 +43,9 @@ class EmbeddedZookeeper() {
   val logDir = TestUtils.tempDir()
   val tickTime = 500
   val zookeeper = new ZooKeeperServer(snapshotDir, logDir, tickTime)
+
+  disableZKShutdownHandlerIsNotRegisteredError(zookeeper)
+
   val factory = new NIOServerCnxnFactory()
   private val addr = new InetSocketAddress("127.0.0.1", TestUtils.RandomPort)
   factory.configure(addr, 0)
@@ -63,5 +68,37 @@ class EmbeddedZookeeper() {
     Utils.delete(logDir)
     Utils.delete(snapshotDir)
   }
+
+  /**
+    * There are some useless log appeared when running a lot of tests:
+    *
+    *   ERROR ZKShutdownHandler is not registered, so ZooKeeper server won't take any action on ERROR or SHUTDOWN server state changes (org.apache.zookeeper.server.ZooKeeperServer:472)
+    *   ERROR ZKShutdownHandler is not registered, so ZooKeeper server won't take any action on ERROR or SHUTDOWN server state changes (org.apache.zookeeper.server.ZooKeeperServer:472)
+    *
+    * To disable such logs this method is used.
+    *
+    * If the API of ZooKeeperServer will be changed the method will not cause tests to fail because
+    * the method is wrapped with [[Try]]
+    *
+    * @param zooKeeperServer instance of [[ZooKeeperServer]] used for testing
+    * @return attempt to disable
+    */
+  def disableZKShutdownHandlerIsNotRegisteredError(zooKeeperServer: ZooKeeperServer): Try[Unit] = {
+    Try {
+      val zkShutdownHandlerField: Field = zooKeeperServer.getClass.getDeclaredField("zkShutdownHandler")
+      val clazz: Class[_] = Class.forName("org.apache.zookeeper.server.ZooKeeperServerShutdownHandler")
+      val constructor: Constructor[_] = clazz.getDeclaredConstructor(classOf[CountDownLatch])
+
+      // make filed and constructor constructor accessible
+      constructor.setAccessible(true)
+      zkShutdownHandlerField.setAccessible(true)
+
+      // new ZooKeeperServerShutdownHandler(new CountDownLatch(1))
+      val zkShutdownHandler = constructor.newInstance(new CountDownLatch(1))
+
+      // ZKServer.zkShutdownHandler = new ZooKeeperServerShutdownHandler(new CountDownLatch(1))
+      zkShutdownHandlerField.set(zooKeeperServer, zkShutdownHandler)
+    }
+  }
   
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Errors logs when running integration/kafka/tools/MirrorMakerIntegrationTest
> ---------------------------------------------------------------------------
>
>                 Key: KAFKA-6141
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6141
>             Project: Kafka
>          Issue Type: Improvement
>          Components: unit tests
>            Reporter: Pavel
>            Priority: Trivial
>
> There are some error logs when running Tests extended from ZooKeeperTestHarness, for example integration/kafka/tools/MirrorMakerIntegrationTest:
> [2017-10-27 18:28:02,557] ERROR ZKShutdownHandler is not registered, so ZooKeeper server won't take any action on ERROR or SHUTDOWN server state changes (org.apache.zookeeper.server.ZooKeeperServer:472)
> [2017-10-27 18:28:09,110] ERROR ZKShutdownHandler is not registered, so ZooKeeper server won't take any action on ERROR or SHUTDOWN server state changes (org.apache.zookeeper.server.ZooKeeperServer:472)
> And these logs have no impact on test results. I think it would be great to eliminate these logs from output by providing a ZKShutdownHandler.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)