-
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-24560 Add a new option of designatedfile in RegionMover #1901
Conversation
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
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.
Left some comments. Please take a look, we can improve readability, reuse some utility methods and make this concise overall.
/** | ||
* Set the designated file. Designated file contains hostnames where region moves. Designated file should | ||
* have 'host:port' per line. Port is mandatory here as we can have many RS running on a single | ||
* host. |
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.
Can you please bring these comment lines within 100 chars. Somehow build is not failing for 100+ char space usage on one line.
@@ -413,7 +429,7 @@ private void loadRegions(List<RegionInfo> regionsToMove) | |||
* Unload regions from given {@link #hostname} using ack/noAck mode and {@link #maxthreads}.In | |||
* noAck mode we do not make sure that region is successfully online on the target region | |||
* server,hence it is best effort.We do not unload regions to hostnames given in | |||
* {@link #excludeFile}. | |||
* {@link #excludeFile}. We only unload regions to hostnames given in {@link #designatedFile}. |
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.
Please put the condition:
If designatedFile is present with some contents, we will unload regions to hostnames provided in {@link #designatedFile}
@@ -435,6 +451,10 @@ public boolean unload() throws InterruptedException, ExecutionException, Timeout | |||
LOG.debug("List of region servers: {}", regionServers); | |||
return false; | |||
} | |||
// Remove RS present not in the designated file |
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: Remove RS not present in the designated file
|
||
private void filterDesignatedServers(List<ServerName> onlineServers) { | ||
List<String> designatedServers = readServersFromFile(designatedFile); | ||
if (designatedServers == null || designatedServers.isEmpty()) { |
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.
designatedServers == null
is redundant
.forEach(excludeServers::add); | ||
Files.readAllLines(Paths.get(filename)).stream().map(String::trim) | ||
.filter(((Predicate<String>) String::isEmpty).negate()).map(String::toLowerCase) | ||
.forEach(servers::add); | ||
} catch (IOException e) { | ||
LOG.warn("Exception while reading excludes file, continuing anyways", e); |
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.
We should not continue if file read fails right?
@@ -435,6 +451,10 @@ public boolean unload() throws InterruptedException, ExecutionException, Timeout | |||
LOG.debug("List of region servers: {}", regionServers); | |||
return false; | |||
} | |||
// Remove RS present not in the designated file | |||
if (designatedFile != null) { | |||
filterDesignatedServers(regionServers); |
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.
We should use stripExcludes()
for both purpose: exclude file and designated file.
Add filename as argument in stripExcludes()
.
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.
I haven't thought of how to elegantly combine excludeFile and designedFile in one method. Could you please give some advice?
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.
We can combine filterDesignatedServers()
and stripExcludes()
.
If you see carefully, both are doing the same thing except for one is excluding what is present in file and another is including. So whether to include/exclude all RS present in given file is something you can provide as boolean argument and act accordingly.
Something like:
private void includeExcludeRegionServers(String fileName, List<ServerName> regionServers, boolean isInclude)
For, filterDesignatedServers(), it can be:
includeExcludeRegionServers(designatedFile, onlineServers, true);
and stripExcludes can be replaced with:
includeExcludeRegionServers(excludeFile, regionServers, false);
Sounds good?
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.
Done as you said. Thanks for your advice.
*/ | ||
private List<String> readExcludes(String excludeFile) throws IOException { | ||
List<String> excludeServers = new ArrayList<>(); | ||
if (excludeFile == null) { |
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.
Please use inverted logic (improves readability):
if (excludeFile != null){
...
...
...
}
return excludeServers;
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs, TEST_UTIL.getConfiguration()) | ||
.designatedFile(designatedFile.getCanonicalPath()); | ||
try (RegionMover rm = rmBuilder.build()) { | ||
LOG.info("Unloading {} regions", rs); |
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.
Use debug log for test cases :)
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
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.
Just had a glance only. Some quick comments.
@@ -413,7 +429,7 @@ private void loadRegions(List<RegionInfo> regionsToMove) | |||
* Unload regions from given {@link #hostname} using ack/noAck mode and {@link #maxthreads}.In | |||
* noAck mode we do not make sure that region is successfully online on the target region | |||
* server,hence it is best effort.We do not unload regions to hostnames given in | |||
* {@link #excludeFile}. | |||
* {@link #excludeFile}. We only unload regions to hostnames given in {@link #designatedFile}. |
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.
Say it if this param is provided. This is anyways an optional stuff
private void filterDesignatedServers(List<ServerName> onlineServers) { | ||
List<String> designatedServers = readServersFromFile(designatedFile); | ||
if (designatedServers == null || designatedServers.isEmpty()) { | ||
LOG.warn("Designated server is null, use all online server."); |
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.
Pls make the log more meaningful.. We can say no designated servers provided in the file + this.designatedFile
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Ping @anoopsjohn @virajjasani |
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.
One example in comment should be good for understanding how isInclude
works. Mostly looks good.
One question: Are you planning to integrate this in any of HBase workflows internally?
} | ||
|
||
/** | ||
* Excludes the servername whose hostname and port portion matches the list given in exclude file | ||
* Designates or excludes the servername whose hostname and port portion matches the list given | ||
* in the file. |
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.
We can give examples of both designatedFile
and excludeFile
and how it works with isInclude
param specifically.
I want to add designatedFile and excludeFile options to the graceful_stop.sh @virajjasani |
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.
A couple of nits, else +1
* Example:<br> | ||
* If you want to designated RSs, suppose designatedFile has RS1, regionServers has RS1, RS2 and | ||
* RS3. When call includeExcludeRegionServers(designatedFile, regionServers, true), regionServers | ||
* left RS1. |
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: When we call includeExcludeRegionServers(designatedFile, regionServers, true), RS2 and RS3 are removed from regionServers list so that regions can move to only RS1.
* left RS1. | ||
* If you want to exclude RSs, suppose excludeFile has RS1, regionServers has RS1, RS2 and RS3. | ||
* When call includeExcludeRegionServers(excludeFile, servers, false), regionServers left RS2 and | ||
* RS3. |
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: When we call includeExcludeRegionServers(excludeFile, servers, false), RS1 is removed from regionServers list so that regions can move to only RS2 and RS3.
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.
done. Thank you @virajjasani
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@anoopsjohn would you like to take a look? |
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.
So in case same RS is mentioned in both include and exclude lists, it will get excluded finally. That should be ok.
+1
Closes #1901 Signed-off-by: Anoop Sam John <[email protected]> Signed-off-by: Viraj Jasani <[email protected]>
Closes apache#1901 Signed-off-by: Anoop Sam John <[email protected]> Signed-off-by: Viraj Jasani <[email protected]>
HBASE-24560