org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEvent Java Examples

The following examples show how to use org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnhealthyExpire() {
  RMNodeImpl node = getUnhealthyNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  Assert.assertEquals("Active Nodes", initialActive, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost + 1, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy - 1, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.LOST, node.getState());
}
 
Example #2
Source File: NMHeartBeatHandler.java    From incubator-myriad with Apache License 2.0 6 votes vote down vote up
@Override
public void beforeRMNodeEventHandled(RMNodeEvent event, RMContext context) {
  switch (event.getType()) {
    case STARTED:
      // Since the RMNode was just started, it should not have a non-zero capacity
      RMNode rmNode = context.getRMNodes().get(event.getNodeId());
      
      if (isNonZeroCapacityNode(rmNode)) {
        Resource totalCapability = rmNode.getTotalCapability();
        logger.warn(
            "FineGrainedScaling feature got invoked for a NM with non-zero capacity. Host: {}, Mem: {}, CPU: {}. Setting the " +
            "NM's capacity to (0G,0CPU)", rmNode.getHostName(), totalCapability.getMemory(), totalCapability.getVirtualCores());
        totalCapability.setMemory(0);
        totalCapability.setVirtualCores(0);
      }
      break;

    case STATUS_UPDATE:
      handleStatusUpdate(event, context);
      break;

    default:
      break;
  }
}
 
Example #3
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunningExpire() {
  RMNodeImpl node = getRunningNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  Assert.assertEquals("Active Nodes", initialActive - 1, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost + 1, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.LOST, node.getState());
}
 
Example #4
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnhealthyRebooting() {
  RMNodeImpl node = getUnhealthyNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.REBOOTING));
  Assert.assertEquals("Active Nodes", initialActive, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy - 1, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted + 1, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
}
 
Example #5
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunningRebooting() {
  RMNodeImpl node = getRunningNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.REBOOTING));
  Assert.assertEquals("Active Nodes", initialActive - 1, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted + 1, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
}
 
Example #6
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnhealthyDecommission() {
  RMNodeImpl node = getUnhealthyNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.DECOMMISSION));
  Assert.assertEquals("Active Nodes", initialActive, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy - 1, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned + 1, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.DECOMMISSIONED, node.getState());
}
 
Example #7
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunningDecommission() {
  RMNodeImpl node = getRunningNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.DECOMMISSION));
  Assert.assertEquals("Active Nodes", initialActive - 1, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned + 1, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.DECOMMISSIONED, node.getState());
}
 
Example #8
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnhealthyExpire() {
  RMNodeImpl node = getUnhealthyNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  Assert.assertEquals("Active Nodes", initialActive, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost + 1, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy - 1, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.LOST, node.getState());
}
 
Example #9
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunningExpire() {
  RMNodeImpl node = getRunningNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  Assert.assertEquals("Active Nodes", initialActive - 1, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost + 1, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.LOST, node.getState());
}
 
Example #10
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunningDecommission() {
  RMNodeImpl node = getRunningNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.DECOMMISSION));
  Assert.assertEquals("Active Nodes", initialActive - 1, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned + 1, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.DECOMMISSIONED, node.getState());
}
 
Example #11
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnhealthyDecommission() {
  RMNodeImpl node = getUnhealthyNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.DECOMMISSION));
  Assert.assertEquals("Active Nodes", initialActive, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy - 1, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned + 1, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.DECOMMISSIONED, node.getState());
}
 
Example #12
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunningRebooting() {
  RMNodeImpl node = getRunningNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.REBOOTING));
  Assert.assertEquals("Active Nodes", initialActive - 1, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted + 1, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
}
 
Example #13
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnhealthyRebooting() {
  RMNodeImpl node = getUnhealthyNode();
  ClusterMetrics cm = ClusterMetrics.getMetrics();
  int initialActive = cm.getNumActiveNMs();
  int initialLost = cm.getNumLostNMs();
  int initialUnhealthy = cm.getUnhealthyNMs();
  int initialDecommissioned = cm.getNumDecommisionedNMs();
  int initialRebooted = cm.getNumRebootedNMs();
  node.handle(new RMNodeEvent(node.getNodeID(),
      RMNodeEventType.REBOOTING));
  Assert.assertEquals("Active Nodes", initialActive, cm.getNumActiveNMs());
  Assert.assertEquals("Lost Nodes", initialLost, cm.getNumLostNMs());
  Assert.assertEquals("Unhealthy Nodes",
      initialUnhealthy - 1, cm.getUnhealthyNMs());
  Assert.assertEquals("Decommissioned Nodes",
      initialDecommissioned, cm.getNumDecommisionedNMs());
  Assert.assertEquals("Rebooted Nodes",
      initialRebooted + 1, cm.getNumRebootedNMs());
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
}
 
Example #14
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private RMNodeImpl getRebootedNode() {
  NodeId nodeId = BuilderUtils.newNodeId("localhost", 0);
  Resource capability = Resource.newInstance(4096, 4, 4);
  RMNodeImpl node = new RMNodeImpl(nodeId, rmContext,null, 0, 0,
      null, capability, null);
  node.handle(new RMNodeStartedEvent(node.getNodeID(), null, null));
  Assert.assertEquals(NodeState.RUNNING, node.getState());
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.REBOOTING));
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
  return node;
}
 
Example #15
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnhealthyExpireForSchedulerRemove() {
  RMNodeImpl node = getUnhealthyNode();
  verify(scheduler,times(2)).handle(any(NodeRemovedSchedulerEvent.class));
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  verify(scheduler,times(2)).handle(any(NodeRemovedSchedulerEvent.class));
  Assert.assertEquals(NodeState.LOST, node.getState());
}
 
Example #16
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test (timeout = 5000)
public void testStatusChange(){
  //Start the node
  node.handle(new RMNodeStartedEvent(null, null, null));
  //Add info to the queue first
  node.setNextHeartBeat(false);

  ContainerId completedContainerId1 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(0, 0), 0), 0);
  ContainerId completedContainerId2 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(1, 1), 1), 1);
      
  RMNodeStatusEvent statusEvent1 = getMockRMNodeStatusEvent();
  RMNodeStatusEvent statusEvent2 = getMockRMNodeStatusEvent();

  ContainerStatus containerStatus1 = mock(ContainerStatus.class);
  ContainerStatus containerStatus2 = mock(ContainerStatus.class);

  doReturn(completedContainerId1).when(containerStatus1).getContainerId();
  doReturn(Collections.singletonList(containerStatus1))
      .when(statusEvent1).getContainers();
   
  doReturn(completedContainerId2).when(containerStatus2).getContainerId();
  doReturn(Collections.singletonList(containerStatus2))
      .when(statusEvent2).getContainers();

  verify(scheduler,times(1)).handle(any(NodeUpdateSchedulerEvent.class)); 
  node.handle(statusEvent1);
  node.handle(statusEvent2);
  verify(scheduler,times(1)).handle(any(NodeUpdateSchedulerEvent.class));
  Assert.assertEquals(2, node.getQueueSize());
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  Assert.assertEquals(0, node.getQueueSize());
}
 
Example #17
Source File: ResourceManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(RMNodeEvent event) {
  NodeId nodeId = event.getNodeId();
  RMNode node = this.rmContext.getRMNodes().get(nodeId);
  if (node != null) {
    try {
      ((EventHandler<RMNodeEvent>) node).handle(event);
    } catch (Throwable t) {
      LOG.error("Error in handling event type " + event.getType()
          + " for node " + nodeId, t);
    }
  }
}
 
Example #18
Source File: TestRMNodeTransitions.java    From big-c with Apache License 2.0 5 votes vote down vote up
private RMNodeImpl getRebootedNode() {
  NodeId nodeId = BuilderUtils.newNodeId("localhost", 0);
  Resource capability = Resource.newInstance(4096, 4);
  RMNodeImpl node = new RMNodeImpl(nodeId, rmContext,null, 0, 0,
      null, capability, null);
  node.handle(new RMNodeStartedEvent(node.getNodeID(), null, null));
  Assert.assertEquals(NodeState.RUNNING, node.getState());
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.REBOOTING));
  Assert.assertEquals(NodeState.REBOOTED, node.getState());
  return node;
}
 
Example #19
Source File: NMHeartBeatHandler.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
protected void handleStatusUpdate(RMNodeEvent event, RMContext context) {
  if (!(event instanceof RMNodeStatusEvent)) {
    logger.error("{} not an instance of {}", event.getClass().getName(), RMNodeStatusEvent.class.getName());
    return;
  }

  RMNodeStatusEvent statusEvent = (RMNodeStatusEvent) event;
  RMNode rmNode = context.getRMNodes().get(event.getNodeId());
  String hostName = rmNode.getNodeID().getHost();

  Node host = nodeStore.getNode(hostName);
  if (host != null) {
    host.snapshotRunningContainers();
  }

  /*
   * Set the new node capacity which is the sum of the current node resources plus those offered by Mesos. 
   * If the sum is greater than the max capacity of the node, reject the offer.
   */
  Resource offeredResources = getNewResourcesOfferedByMesos(hostName);
  Resource currentResources = getResourcesUnderUse(statusEvent);
  
  if (offerWithinResourceLimits(currentResources, offeredResources)) {
    yarnNodeCapacityMgr.setNodeCapacity(rmNode, Resources.add(currentResources, offeredResources));
    logger.info("Updated resources for {} with {} cores and {} memory", rmNode.getNode().getName(), 
            offeredResources.getVirtualCores(), offeredResources.getMemory());
  } else {
    logger.info("Did not update {} with {} cores and {} memory, over max cpu cores and/or max memory", 
            rmNode.getNode().getName(), offeredResources.getVirtualCores(), offeredResources.getMemory());
  }
}
 
Example #20
Source File: ResourceManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public void handle(RMNodeEvent event) {
  NodeId nodeId = event.getNodeId();
  RMNode node = this.rmContext.getRMNodes().get(nodeId);
  if (node != null) {
    try {
      ((EventHandler<RMNodeEvent>) node).handle(event);
    } catch (Throwable t) {
      LOG.error("Error in handling event type " + event.getType()
          + " for node " + nodeId, t);
    }
  }
}
 
Example #21
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnhealthyExpireForSchedulerRemove() {
  RMNodeImpl node = getUnhealthyNode();
  verify(scheduler,times(2)).handle(any(NodeRemovedSchedulerEvent.class));
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  verify(scheduler,times(2)).handle(any(NodeRemovedSchedulerEvent.class));
  Assert.assertEquals(NodeState.LOST, node.getState());
}
 
Example #22
Source File: TestRMNodeTransitions.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test (timeout = 5000)
public void testStatusChange(){
  //Start the node
  node.handle(new RMNodeStartedEvent(null, null, null));
  //Add info to the queue first
  node.setNextHeartBeat(false);

  ContainerId completedContainerId1 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(0, 0), 0), 0);
  ContainerId completedContainerId2 = BuilderUtils.newContainerId(
      BuilderUtils.newApplicationAttemptId(
          BuilderUtils.newApplicationId(1, 1), 1), 1);
      
  RMNodeStatusEvent statusEvent1 = getMockRMNodeStatusEvent();
  RMNodeStatusEvent statusEvent2 = getMockRMNodeStatusEvent();

  ContainerStatus containerStatus1 = mock(ContainerStatus.class);
  ContainerStatus containerStatus2 = mock(ContainerStatus.class);

  doReturn(completedContainerId1).when(containerStatus1).getContainerId();
  doReturn(Collections.singletonList(containerStatus1))
      .when(statusEvent1).getContainers();
   
  doReturn(completedContainerId2).when(containerStatus2).getContainerId();
  doReturn(Collections.singletonList(containerStatus2))
      .when(statusEvent2).getContainers();

  verify(scheduler,times(1)).handle(any(NodeUpdateSchedulerEvent.class)); 
  node.handle(statusEvent1);
  node.handle(statusEvent2);
  verify(scheduler,times(1)).handle(any(NodeUpdateSchedulerEvent.class));
  Assert.assertEquals(2, node.getQueueSize());
  node.handle(new RMNodeEvent(node.getNodeID(), RMNodeEventType.EXPIRE));
  Assert.assertEquals(0, node.getQueueSize());
}
 
Example #23
Source File: CompositeInterceptor.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeRMNodeEventHandled(RMNodeEvent event, RMContext context) {
  for (YarnSchedulerInterceptor interceptor : interceptors.values()) {
    if (interceptor.getCallBackFilter().allowCallBacksForNode(event.getNodeId())) {
      interceptor.beforeRMNodeEventHandled(event, context);
    }
  }
}
 
Example #24
Source File: NMHeartBeatHandlerTest.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Test
public void testZeroNodeStartedEvent() throws Exception {
  NMHeartBeatHandler.CallBackFilter filter = handler.getCallBackFilter();
  filter.allowCallBacksForNode(nodeOne.getNodeID());
  RMNodeEvent event = new RMNodeEvent(nodeOne.getNodeID(), RMNodeEventType.STARTED);
  handler.beforeRMNodeEventHandled(event, context);
  assertEquals(0, nodeOne.getTotalCapability().getVirtualCores());
  assertEquals(0, nodeOne.getTotalCapability().getMemory());
}
 
Example #25
Source File: NMHeartBeatHandlerTest.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Test
public void testNonZeroNodeStartedEvent() throws Exception {
  NMHeartBeatHandler.CallBackFilter filter = handler.getCallBackFilter();
  filter.allowCallBacksForNode(nodeTwo.getNodeID());
  RMNodeEvent event = new RMNodeEvent(nodeTwo.getNodeID(), RMNodeEventType.STARTED);
  handler.beforeRMNodeEventHandled(event, context);
  /*
   * Confirm that, since fine-grained scaling does not work for non-zero nodes, the
   * capacity is set to zero for cores and memory
   */
  assertEquals(0, nodeTwo.getTotalCapability().getVirtualCores());
  assertEquals(0, nodeTwo.getTotalCapability().getMemory());
}
 
Example #26
Source File: TestNMReconnect.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public void handle(RMNodeEvent event) {
  rmNodeEvents.add(event);
}
 
Example #27
Source File: RMNodeEventHandler.java    From incubator-myriad with Apache License 2.0 4 votes vote down vote up
@Override
public void handle(RMNodeEvent event) {
  interceptor.beforeRMNodeEventHandled(event, rmContext);

}
 
Example #28
Source File: TestRMAppAttemptTransitions.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test
public void testFinishedContainer() {
  Container amContainer = allocateApplicationAttempt();
  launchApplicationAttempt(amContainer);
  runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false);

  // Complete one container
  ContainerId containerId1 = BuilderUtils.newContainerId(applicationAttempt
      .getAppAttemptId(), 2);
  Container container1 = mock(Container.class);
  ContainerStatus containerStatus1 = mock(ContainerStatus.class);
  when(container1.getId()).thenReturn(
      containerId1);
  when(containerStatus1.getContainerId()).thenReturn(containerId1);
  when(container1.getNodeId()).thenReturn(NodeId.newInstance("host", 1234));

  application.handle(new RMAppRunningOnNodeEvent(application
      .getApplicationId(),
      container1.getNodeId()));
  applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent(
      applicationAttempt.getAppAttemptId(), containerStatus1,
      container1.getNodeId()));

  ArgumentCaptor<RMNodeFinishedContainersPulledByAMEvent> captor =
      ArgumentCaptor.forClass(RMNodeFinishedContainersPulledByAMEvent.class);

  // Verify justFinishedContainers
  Assert.assertEquals(1, applicationAttempt.getJustFinishedContainers()
      .size());
  Assert.assertEquals(container1.getId(), applicationAttempt
      .getJustFinishedContainers().get(0).getContainerId());
  Assert.assertEquals(0, getFinishedContainersSentToAM(applicationAttempt)
      .size());

  // Verify finishedContainersSentToAM gets container after pull
  List<ContainerStatus> containerStatuses = applicationAttempt
      .pullJustFinishedContainers();
  Assert.assertEquals(1, containerStatuses.size());
  Mockito.verify(rmnodeEventHandler, never()).handle(Mockito
      .any(RMNodeEvent.class));
  Assert.assertTrue(applicationAttempt.getJustFinishedContainers().isEmpty());
  Assert.assertEquals(1, getFinishedContainersSentToAM(applicationAttempt)
      .size());

  // Verify container is acked to NM via the RMNodeEvent after second pull
  containerStatuses = applicationAttempt.pullJustFinishedContainers();
  Assert.assertEquals(0, containerStatuses.size());
  Mockito.verify(rmnodeEventHandler).handle(captor.capture());
  Assert.assertEquals(container1.getId(), captor.getValue().getContainers()
      .get(0));
  Assert.assertTrue(applicationAttempt.getJustFinishedContainers().isEmpty());
  Assert.assertEquals(0, getFinishedContainersSentToAM(applicationAttempt)
      .size());
}
 
Example #29
Source File: MockRM.java    From big-c with Apache License 2.0 4 votes vote down vote up
public void sendNodeLost(MockNM nm) throws Exception {
  RMNodeImpl node = (RMNodeImpl) getRMContext().getRMNodes().get(
      nm.getNodeId());
  node.handle(new RMNodeEvent(nm.getNodeId(), RMNodeEventType.EXPIRE));
}
 
Example #30
Source File: NMLivelinessMonitor.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
protected void expire(NodeId id) {
  dispatcher.handle(
      new RMNodeEvent(id, RMNodeEventType.EXPIRE)); 
}