Search in sources :

Example 1 with NodeHeartbeatRequestPBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl in project hadoop by apache.

the class TestProtocolRecords method testNodeHeartBeatRequest.

@Test
public void testNodeHeartBeatRequest() throws IOException {
    NodeHeartbeatRequest record = Records.newRecord(NodeHeartbeatRequest.class);
    NodeStatus nodeStatus = Records.newRecord(NodeStatus.class);
    OpportunisticContainersStatus opportunisticContainersStatus = Records.newRecord(OpportunisticContainersStatus.class);
    opportunisticContainersStatus.setEstimatedQueueWaitTime(123);
    opportunisticContainersStatus.setWaitQueueLength(321);
    nodeStatus.setOpportunisticContainersStatus(opportunisticContainersStatus);
    record.setNodeStatus(nodeStatus);
    NodeHeartbeatRequestPBImpl pb = new NodeHeartbeatRequestPBImpl(((NodeHeartbeatRequestPBImpl) record).getProto());
    Assert.assertEquals(123, pb.getNodeStatus().getOpportunisticContainersStatus().getEstimatedQueueWaitTime());
    Assert.assertEquals(321, pb.getNodeStatus().getOpportunisticContainersStatus().getWaitQueueLength());
}
Also used : OpportunisticContainersStatus(org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus) NodeHeartbeatRequestPBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl) NodeStatus(org.apache.hadoop.yarn.server.api.records.NodeStatus) Test(org.junit.Test)

Example 2 with NodeHeartbeatRequestPBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl in project hadoop by apache.

the class TestYarnServerApiClasses method testNodeHeartbeatRequestPBImplWithNullLabels.

/**
   * Test NodeHeartbeatRequestPBImpl.
   */
@Test
public void testNodeHeartbeatRequestPBImplWithNullLabels() {
    NodeHeartbeatRequestPBImpl original = new NodeHeartbeatRequestPBImpl();
    NodeHeartbeatRequestPBImpl copy = new NodeHeartbeatRequestPBImpl(original.getProto());
    Assert.assertNull(copy.getNodeLabels());
}
Also used : NodeHeartbeatRequestPBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl) Test(org.junit.Test)

Example 3 with NodeHeartbeatRequestPBImpl

use of org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl in project hadoop by apache.

the class TestYarnServerApiClasses method testNodeHeartbeatRequestPBImpl.

/**
   * Test NodeHeartbeatRequestPBImpl.
   */
@Test
public void testNodeHeartbeatRequestPBImpl() {
    NodeHeartbeatRequestPBImpl original = new NodeHeartbeatRequestPBImpl();
    original.setLastKnownContainerTokenMasterKey(getMasterKey());
    original.setLastKnownNMTokenMasterKey(getMasterKey());
    original.setNodeStatus(getNodeStatus());
    original.setNodeLabels(getValidNodeLabels());
    Map<ApplicationId, String> collectors = getCollectors();
    original.setRegisteredCollectors(collectors);
    NodeHeartbeatRequestPBImpl copy = new NodeHeartbeatRequestPBImpl(original.getProto());
    assertEquals(1, copy.getLastKnownContainerTokenMasterKey().getKeyId());
    assertEquals(1, copy.getLastKnownNMTokenMasterKey().getKeyId());
    assertEquals("localhost", copy.getNodeStatus().getNodeId().getHost());
    assertEquals(collectors, copy.getRegisteredCollectors());
    // check labels are coming with valid values
    Assert.assertTrue(original.getNodeLabels().containsAll(copy.getNodeLabels()));
    // check for empty labels
    original.setNodeLabels(new HashSet<NodeLabel>());
    copy = new NodeHeartbeatRequestPBImpl(original.getProto());
    Assert.assertNotNull(copy.getNodeLabels());
    Assert.assertEquals(0, copy.getNodeLabels().size());
}
Also used : NodeLabel(org.apache.hadoop.yarn.api.records.NodeLabel) NodeHeartbeatRequestPBImpl(org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Test(org.junit.Test)

Aggregations

NodeHeartbeatRequestPBImpl (org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl)3 Test (org.junit.Test)3 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 NodeLabel (org.apache.hadoop.yarn.api.records.NodeLabel)1 NodeStatus (org.apache.hadoop.yarn.server.api.records.NodeStatus)1 OpportunisticContainersStatus (org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus)1