-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
YARN-11161. Support getAttributesToNodes, getClusterNodeAttributes, getNodesToAttributes API's for Federation #4610
Conversation
…etNodesToAttributes API's for Federation.
🎊 +1 overall
This message was automatically generated. |
…etNodesToAttributes API's for Federation.
🎊 +1 overall
This message was automatically generated. |
...src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java
Show resolved
Hide resolved
} | ||
} | ||
attributesToNodesResponse.setAttributeToNodes(nodeAttributeMap); | ||
return attributesToNodesResponse; |
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 we do something like:
return GetAttributesToNodesResponse.newInstance(nodeAttributeMap);
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 for your suggestion, I will modify the code.
Set<NodeAttributeInfo> nodeAttributeInfos = response.getNodeAttributes(); | ||
Assert.assertEquals(2, nodeAttributeInfos.size()); | ||
|
||
Object[] objectArr = nodeAttributeInfos.toArray(); |
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.
Assert the size of the array here too?
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.
Actually, this thing about converting a set into an array to then check in a specific order is not very clean.
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 will refactor this code to use the methods provided by Set directly.
Assert.assertEquals("rm.yarn.io/CPU(STRING)", objectArr[1].toString()); | ||
} | ||
|
||
private boolean findHostnameAndValInMapping(String hostname, String attrVal, |
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.
static
Assert.assertEquals(2, response.getAttributesToNodes().size()); | ||
|
||
Map<NodeAttributeKey, List<NodeToAttributeValue>> attrs = response.getAttributesToNodes(); | ||
Assert.assertTrue(findHostnameAndValInMapping("node2", "docker0", |
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.
Not the cleanest. Is there a better way of writing this?
…etNodesToAttributes API's for Federation.
...src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java
Outdated
Show resolved
Hide resolved
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
...r/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestRouterYarnClientUtils.java
Show resolved
Hide resolved
🎊 +1 overall
This message was automatically generated. |
@@ -196,11 +195,11 @@ public void init(String userName) { | |||
} | |||
|
|||
numSubmitRetries = |
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 indentation is not very clean.
Let's make it numSubmitRetries = conf.getInt(
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@goiri I added a part of Junit Test code in TestFederationClientInterceptor.java, please help to review the code again, thank you very much! |
@goiri |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
…etNodesToAttributes API's for Federation (apache#4610)
JIRA:YARN-11161. Support getAttributesToNodes, getClusterNodeAttributes, getNodesToAttributes API's for Federation.