Example usage for org.apache.hadoop.yarn.event DrainDispatcher await

List of usage examples for org.apache.hadoop.yarn.event DrainDispatcher await

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.event DrainDispatcher await.

Prototype

public void await() 

Source Link

Document

Busy loop waiting for all queued events to drain.

Usage

From source file:org.apache.tez.dag.app.rm.node.TestAMNodeMap.java

License:Apache License

@Test
@SuppressWarnings({ "resource", "rawtypes" })
public void testHealthUpdateKnownNode() {

    DrainDispatcher dispatcher = new DrainDispatcher();
    dispatcher.init(new Configuration());
    dispatcher.start();/*from w  w w  .j a  v  a2 s.  c  o m*/
    EventHandler eventHandler = dispatcher.getEventHandler();

    AppContext appContext = mock(AppContext.class);

    AMNodeMap amNodeMap = new AMNodeMap(eventHandler, appContext);

    NodeId nodeId = NodeId.newInstance("host1", 2342);
    amNodeMap.nodeSeen(nodeId);

    NodeReport nodeReport = generateNodeReport(nodeId, NodeState.UNHEALTHY);
    amNodeMap.handle(new AMNodeEventStateChanged(nodeReport));
    dispatcher.await();
    assertEquals(AMNodeState.UNHEALTHY, amNodeMap.get(nodeId).getState());
    dispatcher.stop();
}