YARN-4345. yarn rmadmin -updateNodeResource doesn't work. Contributed by Junping Du
(cherry picked from commit 06a70311b9
)
This commit is contained in:
parent
3214c2331f
commit
9050078005
|
@ -996,6 +996,9 @@ Release 2.8.0 - UNRELEASED
|
|||
YARN-3840. Resource Manager web ui issue when sorting application by id (with
|
||||
application having id > 9999) (Mohammad Shahid Khan via jianhe)
|
||||
|
||||
YARN-4345. yarn rmadmin -updateNodeResource doesn't work (Junping Du via
|
||||
jlowe)
|
||||
|
||||
Release 2.7.3 - UNRELEASED
|
||||
|
||||
INCOMPATIBLE CHANGES
|
||||
|
|
|
@ -428,6 +428,7 @@ public class RMAdminCLI extends HAAdmin {
|
|||
new HashMap<NodeId, ResourceOption>();
|
||||
resourceMap.put(
|
||||
nodeId, ResourceOption.newInstance(resource, overCommitTimeout));
|
||||
request.setNodeResourceMap(resourceMap);
|
||||
adminProtocol.updateNodeResource(request);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.client.cli;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
|
@ -35,6 +36,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.ha.HAServiceProtocol;
|
||||
|
@ -43,6 +45,8 @@ import org.apache.hadoop.ha.HAServiceTarget;
|
|||
import org.apache.hadoop.service.Service.STATE;
|
||||
import org.apache.hadoop.yarn.api.records.DecommissionType;
|
||||
import org.apache.hadoop.yarn.api.records.NodeId;
|
||||
import org.apache.hadoop.yarn.api.records.Resource;
|
||||
import org.apache.hadoop.yarn.api.records.ResourceOption;
|
||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.nodelabels.CommonNodeLabelsManager;
|
||||
|
@ -59,9 +63,13 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshQueuesRequest;
|
|||
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshServiceAclsRequest;
|
||||
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshSuperUserGroupsConfigurationRequest;
|
||||
import org.apache.hadoop.yarn.server.api.protocolrecords.RefreshUserToGroupsMappingsRequest;
|
||||
import org.apache.hadoop.yarn.server.api.protocolrecords.UpdateNodeResourceRequest;
|
||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
@ -186,6 +194,30 @@ public class TestRMAdminCLI {
|
|||
verify(admin).refreshServiceAcls(any(RefreshServiceAclsRequest.class));
|
||||
}
|
||||
|
||||
@Test(timeout=500)
|
||||
public void testUpdateNodeResource() throws Exception {
|
||||
String nodeIdStr = "0.0.0.0:0";
|
||||
int memSize = 2048;
|
||||
int cores = 2;
|
||||
String[] args = { "-updateNodeResource", nodeIdStr,
|
||||
Integer.toString(memSize), Integer.toString(cores) };
|
||||
assertEquals(0, rmAdminCLI.run(args));
|
||||
ArgumentCaptor<UpdateNodeResourceRequest> argument =
|
||||
ArgumentCaptor.forClass(UpdateNodeResourceRequest.class);
|
||||
verify(admin).updateNodeResource(argument.capture());
|
||||
UpdateNodeResourceRequest request = argument.getValue();
|
||||
Map<NodeId, ResourceOption> resourceMap = request.getNodeResourceMap();
|
||||
NodeId nodeId = ConverterUtils.toNodeId(nodeIdStr);
|
||||
Resource expectedResource = Resources.createResource(memSize, cores);
|
||||
ResourceOption resource = resourceMap.get(nodeId);
|
||||
assertNotNull("resource for " + nodeIdStr + " shouldn't be null.",
|
||||
resource);
|
||||
assertEquals("resource value for " + nodeIdStr + " is not as expected.",
|
||||
ResourceOption.newInstance(expectedResource,
|
||||
ResourceOption.OVER_COMMIT_TIMEOUT_MILLIS_DEFAULT),
|
||||
resource);
|
||||
}
|
||||
|
||||
@Test(timeout=500)
|
||||
public void testRefreshNodes() throws Exception {
|
||||
String[] args = { "-refreshNodes" };
|
||||
|
|
Loading…
Reference in New Issue