YARN-2723. Fix rmadmin -replaceLabelsOnNode does not correctly parse

port. Contributed by Naganarasimha G R
This commit is contained in:
Xuan 2014-10-25 12:45:14 -07:00
parent 28051e4155
commit 65d95b1a52
3 changed files with 18 additions and 1 deletions

View File

@ -753,6 +753,9 @@ Release 2.6.0 - UNRELEASED
prevent creating thousands of threads in a large cluster. (Jason Lowe via prevent creating thousands of threads in a large cluster. (Jason Lowe via
jianhe) jianhe)
YARN-2723. Fix rmadmin -replaceLabelsOnNode does not correctly parse port.
(Naganarasimha G R via xgong)
Release 2.5.1 - 2014-09-05 Release 2.5.1 - 2014-09-05
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -454,7 +454,7 @@ public class RMAdminCLI extends HAAdmin {
int port; int port;
if (nodeIdStr.contains(":")) { if (nodeIdStr.contains(":")) {
nodeName = nodeIdStr.substring(0, nodeIdStr.indexOf(":")); nodeName = nodeIdStr.substring(0, nodeIdStr.indexOf(":"));
port = Integer.valueOf(nodeIdStr.substring(nodeIdStr.indexOf(":"))); port = Integer.valueOf(nodeIdStr.substring(nodeIdStr.indexOf(":") + 1));
} else { } else {
nodeName = nodeIdStr; nodeName = nodeIdStr;
port = 0; port = 0;

View File

@ -489,6 +489,20 @@ public class TestRMAdminCLI {
assertTrue(0 != rmAdminCLI.run(args)); assertTrue(0 != rmAdminCLI.run(args));
} }
@Test
public void testReplaceLabelsOnNodeWithPort() throws Exception {
// Successfully replace labels
dummyNodeLabelsManager.addToCluserNodeLabels(ImmutableSet.of("x", "y"));
String[] args =
{ "-replaceLabelsOnNode", "node1:8000,x,y node2:8000,y",
"-directlyAccessNodeLabelStore" };
assertEquals(0, rmAdminCLI.run(args));
assertTrue(dummyNodeLabelsManager.getNodeLabels().containsKey(
NodeId.newInstance("node1", 8000)));
assertTrue(dummyNodeLabelsManager.getNodeLabels().containsKey(
NodeId.newInstance("node2", 8000)));
}
@Test @Test
public void testGetClusterNodeLabels() throws Exception { public void testGetClusterNodeLabels() throws Exception {
// Successfully get labels // Successfully get labels