-
Notifications
You must be signed in to change notification settings - Fork 589
HDDS-7329. Extend ozone admin datanode usageinfo and list info to accept hostname parameter #3835
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 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
bf4c68e
hostname parameter for datanode subcommands
xBis7 6db1478
getNodesByIpAddress, getNodesByHostName used only by the CLI
xBis7 dd1c03f
--address parameter for datanode usageinfo
xBis7 e9e5317
removing datanode_use_hostname flag
xBis7 91d1608
checkstyle errors fixed
xBis7 dc6a421
test node register with updated ip or hostname
xBis7 ba86db4
list and usageinfo tests added in smoketest/admincli/datanode.robot
xBis7 aa323f9
rebasing with master
xBis7 d564fb8
datanode.robot test user for ozonesecure
xBis7 d345827
RatisHelper.toRaftPeerAddress hostname as the default option
xBis7 b6dfe33
DATANODE_USE_DN_HOSTNAME
xBis7 fa12ee4
Merge remote-tracking branch 'origin/master' into HDDS-7329
xBis7 c1df1ad
Merge remote-tracking branch 'origin/master' into HDDS-7329
adoroszlai a494d53
run testScmRegisterNodeWithNetworkTopology with both USE_DN_HOSTNAME=…
adoroszlai 52bafdc
reduce `ozone admin datanode list` invocations in robot test
adoroszlai 96976d5
fix checkstyle
adoroszlai 062312c
reuse ipAddress/hostName variables
adoroszlai 1e6f984
slightly more uniform log messages
adoroszlai a0d91da
reduce duplication in robot test
adoroszlai d091705
Merge remote-tracking branch 'origin/master' into HDDS-7329
adoroszlai dc5983c
Update IP and hostname in the same method call
adoroszlai 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ | |
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
| import java.util.UUID; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
@@ -379,34 +380,31 @@ public RegisteredCommand register( | |
| datanodeDetails.setIpAddress(dnAddress.getHostAddress()); | ||
| } | ||
|
|
||
| String dnsName; | ||
| String networkLocation; | ||
| final String ipAddress = datanodeDetails.getIpAddress(); | ||
| final String hostName = datanodeDetails.getHostName(); | ||
| datanodeDetails.setNetworkName(datanodeDetails.getUuidString()); | ||
| if (useHostname) { | ||
| dnsName = datanodeDetails.getHostName(); | ||
| } else { | ||
| dnsName = datanodeDetails.getIpAddress(); | ||
| } | ||
| networkLocation = nodeResolve(dnsName); | ||
| String networkLocation = nodeResolve(useHostname ? hostName : ipAddress); | ||
| if (networkLocation != null) { | ||
| datanodeDetails.setNetworkLocation(networkLocation); | ||
| } | ||
|
|
||
| final UUID uuid = datanodeDetails.getUuid(); | ||
| if (!isNodeRegistered(datanodeDetails)) { | ||
| try { | ||
| clusterMap.add(datanodeDetails); | ||
| nodeStateManager.addNode(datanodeDetails, layoutInfo); | ||
| // Check that datanode in nodeStateManager has topology parent set | ||
| DatanodeDetails dn = nodeStateManager.getNode(datanodeDetails); | ||
| Preconditions.checkState(dn.getParent() != null); | ||
| addToDnsToUuidMap(dnsName, datanodeDetails.getUuid()); | ||
| addToDnsToUuidMap(ipAddress, uuid); | ||
| addToDnsToUuidMap(hostName, uuid); | ||
| // Updating Node Report, as registration is successful | ||
| processNodeReport(datanodeDetails, nodeReport); | ||
| LOG.info("Registered Data node : {}", datanodeDetails.toDebugString()); | ||
| LOG.info("Registered datanode: {}", datanodeDetails.toDebugString()); | ||
| scmNodeEventPublisher.fireEvent(SCMEvents.NEW_NODE, datanodeDetails); | ||
| } catch (NodeAlreadyExistsException e) { | ||
| if (LOG.isTraceEnabled()) { | ||
| LOG.trace("Datanode is already registered. Datanode: {}", | ||
| LOG.trace("Datanode is already registered: {}", | ||
| datanodeDetails); | ||
| } | ||
| } catch (NodeNotFoundException e) { | ||
|
|
@@ -418,28 +416,24 @@ public RegisteredCommand register( | |
| try { | ||
| final DatanodeInfo datanodeInfo = | ||
| nodeStateManager.getNode(datanodeDetails); | ||
| if (!datanodeInfo.getIpAddress().equals(datanodeDetails.getIpAddress()) | ||
| || !datanodeInfo.getHostName() | ||
| .equals(datanodeDetails.getHostName())) { | ||
| LOG.info("Updating data node {} from {} to {}", | ||
| final String oldIpAddress = datanodeInfo.getIpAddress(); | ||
| final String oldHostName = datanodeInfo.getHostName(); | ||
| if (!Objects.equals(oldIpAddress, ipAddress) | ||
| || !Objects.equals(oldHostName, hostName)) { | ||
| LOG.info("Updating datanode {} from {} to {}", | ||
| datanodeDetails.getUuidString(), | ||
| datanodeInfo, | ||
| datanodeDetails); | ||
| clusterMap.update(datanodeInfo, datanodeDetails); | ||
|
|
||
| String oldDnsName; | ||
| if (useHostname) { | ||
| oldDnsName = datanodeInfo.getHostName(); | ||
| } else { | ||
| oldDnsName = datanodeInfo.getIpAddress(); | ||
| } | ||
| updateDnsToUuidMap(oldDnsName, dnsName, datanodeDetails.getUuid()); | ||
| updateDnsToUuidMap(oldIpAddress, ipAddress, uuid); | ||
| updateDnsToUuidMap(oldHostName, hostName, uuid); | ||
|
||
|
|
||
| nodeStateManager.updateNode(datanodeDetails, layoutInfo); | ||
| DatanodeDetails dn = nodeStateManager.getNode(datanodeDetails); | ||
| Preconditions.checkState(dn.getParent() != null); | ||
| processNodeReport(datanodeDetails, nodeReport); | ||
| LOG.info("Updated Datanode to: {}", dn); | ||
| LOG.info("Updated datanode to: {}", dn); | ||
| scmNodeEventPublisher | ||
| .fireEvent(SCMEvents.NODE_ADDRESS_UPDATE, dn); | ||
| } | ||
|
|
@@ -464,8 +458,10 @@ public RegisteredCommand register( | |
| * @param uuid the UUID of the registered node. | ||
| */ | ||
| private synchronized void addToDnsToUuidMap(String addr, UUID uuid) { | ||
| dnsToUuidMap.computeIfAbsent(addr, k -> ConcurrentHashMap.newKeySet()) | ||
| .add(uuid); | ||
| if (!Strings.isNullOrEmpty(addr)) { | ||
| dnsToUuidMap.computeIfAbsent(addr, k -> ConcurrentHashMap.newKeySet()) | ||
| .add(uuid); | ||
| } | ||
| } | ||
|
|
||
| private synchronized void removeFromDnsToUuidMap(String addr, UUID uuid) { | ||
|
|
||
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
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
Oops, something went wrong.
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.
Since these are synchronized methods, I think we should do both updates (ip & hostname) in a single method call.
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.
Thanks @sadanand48, updated.