-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-1480. Prefer resolved datanode ip address over persisted ip address #7495
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e35572c
HDDS-1480. Verify if the saved ip address differs from the current da…
ptlrs 4afc551
HDDS-1480. Fix review comments
ptlrs f1fdd50
Update hadoop-hdds/container-service/src/main/java/org/apache/hadoop/…
ptlrs 0e5e5b7
HDDS-1480. Fix review comments
ptlrs 1f0d6df
Merge remote-tracking branch 'upstream/master' into HDDS-1480-remove-…
ptlrs 6a5a32c
fix merge conflicts
ptlrs df4def4
do not update the IP address when reading the datanode file
ptlrs 6657805
improve readability
ptlrs 6c36940
fix checkstyle error
ptlrs b830a30
fix unit test failure
ptlrs c77df91
Merge remote-tracking branch 'upstream/master' into HDDS-1480-remove-…
ptlrs 78d6479
fix checkstyle error
ptlrs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,13 +27,16 @@ | |
| import com.google.common.base.Strings; | ||
| import com.google.common.collect.ImmutableSet; | ||
| import com.google.protobuf.ByteString; | ||
| import java.net.InetAddress; | ||
| import java.net.UnknownHostException; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.EnumSet; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import java.util.UUID; | ||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.hadoop.hdds.DatanodeVersion; | ||
| import org.apache.hadoop.hdds.HddsUtils; | ||
| import org.apache.hadoop.hdds.annotation.InterfaceAudience; | ||
|
|
@@ -175,13 +178,41 @@ public void setIpAddress(String ip) { | |
| this.ipAddress = StringWithByteString.valueOf(ip); | ||
| } | ||
|
|
||
| /** | ||
| * Resolves and validates the IP address of the datanode based on its hostname. | ||
| * If the resolved IP address differs from the current IP address, | ||
| * it updates the IP address to the newly resolved value. | ||
| */ | ||
| public void validateDatanodeIpAddress() { | ||
| final String oldIP = getIpAddress(); | ||
| final String hostname = getHostName(); | ||
| if (StringUtils.isBlank(hostname)) { | ||
| LOG.warn("Could not resolve IP address of datanode '{}'", this); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| final String newIP = InetAddress.getByName(hostname).getHostAddress(); | ||
| if (StringUtils.isBlank(newIP)) { | ||
| throw new UnknownHostException("New IP address is invalid: " + newIP); | ||
| } | ||
|
|
||
| if (!newIP.equals(oldIP)) { | ||
| LOG.info("Updating IP address of datanode {} to {}", this, newIP); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this.toString() format is "UUID(hostname/old_ip_address)" so this log would become It may look confusing initially but okay. |
||
| setIpAddress(newIP); | ||
| } | ||
| } catch (UnknownHostException e) { | ||
| LOG.warn("Could not resolve IP address of datanode '{}'", this, e); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns IP address of DataNode. | ||
| * | ||
| * @return IP address | ||
| */ | ||
| public String getIpAddress() { | ||
| return ipAddress.getString(); | ||
| return ipAddress == null ? null : ipAddress.getString(); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -208,7 +239,7 @@ public void setHostName(String host) { | |
| * @return Hostname | ||
| */ | ||
| public String getHostName() { | ||
| return hostName.getString(); | ||
| return hostName == null ? null : hostName.getString(); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry, it looks like we need to handle
ipAddress == nullcase ingetIpAddress()andgetHostName().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.
Fixed.