YARN-10315. Avoid sending RMNodeResourceupdate event if resource is same. Contributed by Sushil Ks.

This commit is contained in:
bibinchundatt 2020-07-23 16:40:24 +05:30
parent 2d12496643
commit bfcd775381
4 changed files with 30 additions and 1 deletions

View File

@ -1188,7 +1188,9 @@ public abstract class AbstractYarnScheduler
// If the node is decommissioning, send an update to have the total
// resource equal to the used resource, so no available resource to
// schedule.
if (nm.getState() == NodeState.DECOMMISSIONING && schedulerNode != null) {
if (nm.getState() == NodeState.DECOMMISSIONING && schedulerNode != null
&& schedulerNode.getTotalResource().compareTo(
schedulerNode.getAllocatedResource()) != 0) {
this.rmContext
.getDispatcher()
.getEventHandler()

View File

@ -38,6 +38,8 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.IOException;
@ -4726,6 +4728,13 @@ public class TestCapacityScheduler extends CapacitySchedulerTestBase {
availableResource.getMemorySize());
Assert.assertEquals("Available Resource Memory Size should be 0", 0,
availableResource.getVirtualCores());
// Kick off another heartbeat where the RMNodeResourceUpdateEvent would
// be skipped for DECOMMISSIONING state since the total resource is
// already equal to used resource from the previous heartbeat.
when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
resourceManager.getResourceScheduler().handle(
new NodeUpdateSchedulerEvent(spyNode));
verify(mockDispatcher, times(4)).getEventHandler();
}
@Test

View File

@ -136,6 +136,8 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@SuppressWarnings("unchecked")
@ -4956,6 +4958,13 @@ public class TestFairScheduler extends FairSchedulerTestBase {
.getSchedulerNode(nm_0.getNodeId()).getUnallocatedResource();
assertThat(availableResource.getMemorySize()).isEqualTo(0);
assertThat(availableResource.getVirtualCores()).isEqualTo(0);
// Kick off another heartbeat where the RMNodeResourceUpdateEvent would
// be skipped for DECOMMISSIONING state since the total resource is
// already equal to used resource from the previous heartbeat.
when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
resourceManager.getResourceScheduler().handle(
new NodeUpdateSchedulerEvent(spyNode));
verify(mockDispatcher, times(1)).getEventHandler();
}
private NodeManager registerNode(String hostName, int containerManagerPort,

View File

@ -24,6 +24,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.io.IOException;
@ -1314,6 +1316,13 @@ public class TestFifoScheduler {
.getSchedulerNode(nm_0.getNodeId()).getUnallocatedResource();
assertThat(availableResource.getMemorySize()).isEqualTo(0);
assertThat(availableResource.getVirtualCores()).isEqualTo(0);
// Kick off another heartbeat where the RMNodeResourceUpdateEvent would
// be skipped for DECOMMISSIONING state since the total resource is
// already equal to used resource from the previous heartbeat.
when(spyNode.getState()).thenReturn(NodeState.DECOMMISSIONING);
resourceManager.getResourceScheduler().handle(
new NodeUpdateSchedulerEvent(spyNode));
verify(mockDispatcher, times(4)).getEventHandler();
}
private void checkApplicationResourceUsage(int expected,