You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2024/07/16 12:48:04 UTC
[PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
FrankYang0529 opened a new pull request, #16601:
URL: https://github.com/apache/kafka/pull/16601
* Reuse `org.apache.kafka.common.utils.LogCaptureAppender`.
* Refactor `AclCommandTest` and `ControllerIntegrationTest`.
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on PR #16601:
URL: https://github.com/apache/kafka/pull/16601#issuecomment-2235439116
> > [2024-07-17T12:14:23.174Z] java.io.IOException: No space left on device
>
> @FrankYang0529 please rebase code to trigger QA again. not lucky today :cry
Yes, rebased it. Thank you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #16601:
URL: https://github.com/apache/kafka/pull/16601
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #16601:
URL: https://github.com/apache/kafka/pull/16601#discussion_r1682986486
##########
clients/src/test/java/org/apache/kafka/common/utils/LogCaptureAppender.java:
##########
@@ -80,6 +86,17 @@ public static LogCaptureAppender createAndRegister(final Class<?> clazz) {
return logCaptureAppender;
}
+ public void setClassLoggerToInfo(final Class<?> clazz) {
Review Comment:
Agree, updated it. Thank you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #16601:
URL: https://github.com/apache/kafka/pull/16601#discussion_r1684192782
##########
core/src/test/scala/unit/kafka/admin/AclCommandTest.scala:
##########
@@ -217,17 +217,16 @@ class AclCommandTest extends QuorumTestHarness with Logging {
createServer(Some(adminClientConfig))
val appender = LogCaptureAppender.createAndRegister()
- val previousLevel = LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], Level.WARN)
+ appender.setClassLogger(classOf[AppInfoParser], Level.WARN)
try {
testAclCli(adminArgs)
} finally {
- LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], previousLevel)
- LogCaptureAppender.unregister(appender)
+ appender.close()
}
- val warning = appender.getMessages.find(e => e.getLevel == Level.WARN &&
- e.getThrowableInformation != null &&
- e.getThrowableInformation.getThrowable.getClass.getName == classOf[InstanceAlreadyExistsException].getName)
- assertFalse(warning.isDefined, "There should be no warnings about multiple registration of mbeans")
+ val warning = appender.getEvents.stream.filter(e => e.getLevel == Level.WARN.toString &&
Review Comment:
Could you please decorate it a bit?
```scala
assertEquals(0, appender.getEvents.stream
.filter(e => e.getLevel == Level.WARN.toString)
.filter(_.getThrowableClassName.filter(_ == classOf[InstanceAlreadyExistsException].getName).isPresent())
.count(), "There should be no warnings about multiple registration of mbeans")
```
##########
core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala:
##########
@@ -1881,14 +1882,13 @@ class ControllerIntegrationTest extends QuorumTestHarness {
TestUtils.waitUntilTrue(() => !controller.isActive, "Controller fails to resign")
// Expect to capture the ControllerMovedException in the log of ControllerEventThread
- val event = appender.getMessages.find(e => e.getLevel == Level.INFO
- && e.getThrowableInformation != null
- && e.getThrowableInformation.getThrowable.getClass.getName.equals(classOf[ControllerMovedException].getName))
- assertTrue(event.isDefined)
+ val event = appender.getEvents.stream().filter(e => e.getLevel == Level.INFO.toString
Review Comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #16601:
URL: https://github.com/apache/kafka/pull/16601#discussion_r1680801404
##########
core/src/test/scala/unit/kafka/admin/AclCommandTest.scala:
##########
@@ -217,17 +217,17 @@ class AclCommandTest extends QuorumTestHarness with Logging {
createServer(Some(adminClientConfig))
val appender = LogCaptureAppender.createAndRegister()
- val previousLevel = LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], Level.WARN)
+ appender.setClassLoggerToWarn(classOf[AppInfoParser])
try {
testAclCli(adminArgs)
} finally {
- LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], previousLevel)
- LogCaptureAppender.unregister(appender)
+ appender.close()
}
- val warning = appender.getMessages.find(e => e.getLevel == Level.WARN &&
- e.getThrowableInformation != null &&
- e.getThrowableInformation.getThrowable.getClass.getName == classOf[InstanceAlreadyExistsException].getName)
- assertFalse(warning.isDefined, "There should be no warnings about multiple registration of mbeans")
+ val warning = appender.getEvents.stream.filter(e => e.getLevel == Level.WARN.toString &&
+ e.getThrowableClassName.isPresent &&
Review Comment:
Thanks for the suggestion. Updated it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #16601:
URL: https://github.com/apache/kafka/pull/16601#issuecomment-2235197219
> [2024-07-17T12:14:23.174Z] java.io.IOException: No space left on device
@FrankYang0529 please rebase code to trigger QA again. not lucky today :cry
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #16601:
URL: https://github.com/apache/kafka/pull/16601#discussion_r1679946355
##########
core/src/test/scala/unit/kafka/controller/ControllerIntegrationTest.scala:
##########
@@ -1881,14 +1882,14 @@ class ControllerIntegrationTest extends QuorumTestHarness {
TestUtils.waitUntilTrue(() => !controller.isActive, "Controller fails to resign")
// Expect to capture the ControllerMovedException in the log of ControllerEventThread
- val event = appender.getMessages.find(e => e.getLevel == Level.INFO
- && e.getThrowableInformation != null
- && e.getThrowableInformation.getThrowable.getClass.getName.equals(classOf[ControllerMovedException].getName))
- assertTrue(event.isDefined)
+ val event = appender.getEvents.stream().filter(e => e.getLevel == Level.INFO.toString
+ && e.getThrowableClassName.isPresent
Review Comment:
ditto
##########
core/src/test/scala/unit/kafka/admin/AclCommandTest.scala:
##########
@@ -217,17 +217,17 @@ class AclCommandTest extends QuorumTestHarness with Logging {
createServer(Some(adminClientConfig))
val appender = LogCaptureAppender.createAndRegister()
- val previousLevel = LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], Level.WARN)
+ appender.setClassLoggerToWarn(classOf[AppInfoParser])
try {
testAclCli(adminArgs)
} finally {
- LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], previousLevel)
- LogCaptureAppender.unregister(appender)
+ appender.close()
}
- val warning = appender.getMessages.find(e => e.getLevel == Level.WARN &&
- e.getThrowableInformation != null &&
- e.getThrowableInformation.getThrowable.getClass.getName == classOf[InstanceAlreadyExistsException].getName)
- assertFalse(warning.isDefined, "There should be no warnings about multiple registration of mbeans")
+ val warning = appender.getEvents.stream.filter(e => e.getLevel == Level.WARN.toString &&
+ e.getThrowableClassName.isPresent &&
Review Comment:
`e.getThrowableClassName.filter(_ ==classOf[InstanceAlreadyExistsException].getName).isPresent)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #16601:
URL: https://github.com/apache/kafka/pull/16601#discussion_r1685470793
##########
core/src/test/scala/unit/kafka/admin/AclCommandTest.scala:
##########
@@ -217,17 +217,16 @@ class AclCommandTest extends QuorumTestHarness with Logging {
createServer(Some(adminClientConfig))
val appender = LogCaptureAppender.createAndRegister()
- val previousLevel = LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], Level.WARN)
+ appender.setClassLogger(classOf[AppInfoParser], Level.WARN)
try {
testAclCli(adminArgs)
} finally {
- LogCaptureAppender.setClassLoggerLevel(classOf[AppInfoParser], previousLevel)
- LogCaptureAppender.unregister(appender)
+ appender.close()
}
- val warning = appender.getMessages.find(e => e.getLevel == Level.WARN &&
- e.getThrowableInformation != null &&
- e.getThrowableInformation.getThrowable.getClass.getName == classOf[InstanceAlreadyExistsException].getName)
- assertFalse(warning.isDefined, "There should be no warnings about multiple registration of mbeans")
+ val warning = appender.getEvents.stream.filter(e => e.getLevel == Level.WARN.toString &&
Review Comment:
Thanks for the suggestion. Update it!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-17082: replace kafka.utils.LogCaptureAppender with org.apache.kafka.common.utils.LogCaptureAppender [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #16601:
URL: https://github.com/apache/kafka/pull/16601#discussion_r1682574586
##########
clients/src/test/java/org/apache/kafka/common/utils/LogCaptureAppender.java:
##########
@@ -80,6 +86,17 @@ public static LogCaptureAppender createAndRegister(final Class<?> clazz) {
return logCaptureAppender;
}
+ public void setClassLoggerToInfo(final Class<?> clazz) {
Review Comment:
Could we add new method `setClassLogger` to replace those `setClassLoggerToXXX`?
```java
public void setClassLogger(final Class<?> clazz, Level level) {
logLevelChanges.add(new LogLevelChange(Logger.getLogger(clazz).getLevel(), clazz));
Logger.getLogger(clazz).setLevel(level);
}
```
That is more simple and not verbose to me
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org