-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KAFKA-17668: Clean-up LogCleaner#maxOverCleanerThreads and LogCleanerManager#maintainUncleanablePartitions #17390
Conversation
…anager#maintainUncleanablePartitions
Hi @chia7712 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
I don't see a unit test in this PR. |
58513e9
to
b835c1f
Compare
Hi @ijuma, However, I later decided to remove these tests as I realized they might not add much value. |
Yes, that's reasonable. |
Please update this description then. |
Ah, we do have a new unit test now - I'll review that. |
import scala.collection.mutable | ||
|
||
|
||
class ScalaCompatibilityTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test name isn't right. This is not about testing scala compatibility, it's about testing the relevant log cleaner method. Is there a test class where this test makes sense? If not, it's ok to add one, but the name should be about the thing being tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankvicky thanks for this patch. Those classes have ut file already, so it would be better to add unit test for the changed methods as there are many existent help methods in the test file.
@@ -116,12 +116,11 @@ class LogCleaner(initialConfig: CleanerConfig, | |||
private[log] val cleaners = mutable.ArrayBuffer[CleanerThread]() | |||
|
|||
/** | |||
* scala 2.12 does not support maxOption so we handle the empty manually. | |||
* @param f to compute the result | |||
* @return the max value (int value) or 0 if there is no cleaner | |||
*/ | |||
private def maxOverCleanerThreads(f: CleanerThread => Double): Int = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can add a unit test to LogCleanerTest
?
@@ -533,21 +533,15 @@ private[log] class LogCleanerManager(val logDirs: Seq[File], | |||
def maintainUncleanablePartitions(): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto. LogCleanerManagerTest
is a good place :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maintainUncleanablePartitions
is invoked by CleanerThread#doWork
, which is a daemon thread. It has been ㄎwidely tested through integration tests and unit tests related to LogCleaner. IMHO, we can leverage these existing tests and don't need to write new ones.
e93a377
to
e2ad6f6
Compare
cleaner3.lastStats.bufferUtilization = 0.65d | ||
cleaners += cleaner3 | ||
|
||
assertEquals(0, logCleaner.maxOverCleanerThreads(_.lastStats.bufferUtilization)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, can we also assert a non zero value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
I have just added it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In reviewing this test, I noticed that I introduced a bug in #8783 that I round down the double value when updating metrics max-buffer-utilization-percent
I open https://issues.apache.org/jira/browse/KAFKA-18597 to fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I'll backport this one to 4.0 to make it easier to backport the bug fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, given the fix, perhaps we don't need the case where we set the bufferUtilization to larger numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, given the fix, perhaps we don't need the case where we set the bufferUtilization to larger numbers.
you are right. I copy your comment to #18627
|
||
val cleaner1 = new logCleaner.CleanerThread(1) | ||
cleaner1.lastStats = new CleanerStats(time) | ||
cleaner1.lastStats.bufferUtilization = 0.75d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: d
is not needed, 0.75
is already a double. Same for a few more cases below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 😸
I have removed the redundant d
but still keep it for the integer.
8283d31
to
83d61d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
…Manager#maintainUncleanablePartitions (#17390) Since maxOverCleanerThreads does not have a corresponding unit test, I have added a unit test for it. maintainUncleanablePartitions has been thoroughly tested in tests, so I simply replaced the old implementation with the new one. Reviewers: Ismael Juma <[email protected]>, Chia-Ping Tsai <[email protected]>
…Manager#maintainUncleanablePartitions (apache#17390) Since maxOverCleanerThreads does not have a corresponding unit test, I have added a unit test for it. maintainUncleanablePartitions has been thoroughly tested in tests, so I simply replaced the old implementation with the new one. Reviewers: Ismael Juma <[email protected]>, Chia-Ping Tsai <[email protected]>
…Manager#maintainUncleanablePartitions (apache#17390) Since maxOverCleanerThreads does not have a corresponding unit test, I have added a unit test for it. maintainUncleanablePartitions has been thoroughly tested in tests, so I simply replaced the old implementation with the new one. Reviewers: Ismael Juma <[email protected]>, Chia-Ping Tsai <[email protected]>
JIRA: KAFKA-17668
Since
maxOverCleanerThreads
does not have a corresponding unit test, I have added a unit test for it.maintainUncleanablePartitions
has been thoroughly tested in tests, so I simply replaced the old implementation with the new one.Committer Checklist (excluded from commit message)