-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-24628 Region normalizer now respects a rate limit (HMaster chore shutdown NPE ADDENDUM) #2540
HBASE-24628 Region normalizer now respects a rate limit (HMaster chore shutdown NPE ADDENDUM) #2540
Conversation
@@ -1638,7 +1638,9 @@ private void stopChores() { | |||
choreService.cancelChore(this.mobFileCleanerChore); | |||
choreService.cancelChore(this.mobFileCompactionChore); | |||
choreService.cancelChore(this.balancerChore); | |||
choreService.cancelChore(getRegionNormalizerManager().getRegionNormalizerChore()); | |||
Optional.ofNullable(this.regionNormalizerManager) |
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.
Why not just use a null check?
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.
Optional.ofNullable() is invoked twice, one here and another within mapper:
public<U> Optional<U> map(Function<? super T, ? extends U> mapper) {
Objects.requireNonNull(mapper);
if (!isPresent())
return empty();
else {
return Optional.ofNullable(mapper.apply(value));
}
}
And ofNullable() itself is going to check if value is null, and accordingly going to create new Optional object.
When we have direct Function to deal with, this approach would come with minimal complexity. I am not saying here it is too complex, but compared to one simple null check, yes it is bit complex :)
And in general, I think the design here is a bit strange. If we define RegionNormalizerManager as a separated feature, then we should schedule chore and cancel it in RegionNormalizerManager itself, in the start and stop methods. If not, we should do things like CatalogJanitor, where the class itself is a chore, so in HMaster we will schedule and cancel it. Anyway, let's see if this could fix the problem first. |
OK, tried locally, a simple null check could fix the problem. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
My objective was to make a normalizer subsystem that's as self-contained as possible. The rough edges are related to the non-modular design of HMaster. I didn't want to refactor the whole class in order to add this feature. As for the design, I'm open to suggestions, if you have anything more specific.
This was my original strategy. It doesn't work well, because master owns directly all these chores, and is picky about the order in which subsystems are initialized. Instantiation of the RegionNormalizerManager is also in an odd place, because of conditional initialization of ZKWatchers.
CatalogJanitor is a good deal simpler and conceptually makes sense being limited in scope to a Chore. It doesn't have a "switch" in ZooKeeper to manage, nor does it have a worker with a background thread. It appears there's been some time spent recently on the design of CatalogJanitor as a subsystem. Let me study it a bit and see what lessons I have to learn here.
Sure thing. Since you are both so allergic to the Optional class, I'll swap it for a null check. |
…e shutdown NPE ADDENDUM)
e4075b7
to
685ebb3
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Yes, the initialization order of HMaster is just a mess, too many dependencies... I like that you want to keep align with the current design of how to schedule chores. It is good to keep the code in one style so later developpers will not be confused. What I said is just suggestion, I'm OK with the current implementation. Let's see if this could fix the flaky tests. |
…e shutdown NPE ADDENDUM) (#2540) Signed-off-by: Michael Stack <stack@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org>
…e shutdown NPE ADDENDUM) (apache#2540) Signed-off-by: Michael Stack <stack@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org>
I think this variable is null for backup masters.
initializeZKBasedSystemTrackers
only called when a master transitions to active. I don't know why it impacts this test though, as an NPE in the backup master thread should cause the thread to halt.