Search in sources :

Example 1 with OpportunisticContainersStatus

use of org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus in project hadoop by apache.

the class NodeQueueLoadMonitor method updateNode.

@Override
public void updateNode(RMNode rmNode) {
    LOG.debug("Node update event from: " + rmNode.getNodeID());
    OpportunisticContainersStatus opportunisticContainersStatus = rmNode.getOpportunisticContainersStatus();
    int estimatedQueueWaitTime = opportunisticContainersStatus.getEstimatedQueueWaitTime();
    int waitQueueLength = opportunisticContainersStatus.getWaitQueueLength();
    // Add nodes to clusterNodes. If estimatedQueueTime is -1, ignore node
    // UNLESS comparator is based on queue length.
    ReentrantReadWriteLock.WriteLock writeLock = clusterNodesLock.writeLock();
    writeLock.lock();
    try {
        ClusterNode currentNode = this.clusterNodes.get(rmNode.getNodeID());
        if (currentNode == null) {
            if (estimatedQueueWaitTime != -1 || comparator == LoadComparator.QUEUE_LENGTH) {
                this.clusterNodes.put(rmNode.getNodeID(), new ClusterNode(rmNode.getNodeID()).setQueueWaitTime(estimatedQueueWaitTime).setQueueLength(waitQueueLength));
                LOG.info("Inserting ClusterNode [" + rmNode.getNodeID() + "] " + "with queue wait time [" + estimatedQueueWaitTime + "] and " + "wait queue length [" + waitQueueLength + "]");
            } else {
                LOG.warn("IGNORING ClusterNode [" + rmNode.getNodeID() + "] " + "with queue wait time [" + estimatedQueueWaitTime + "] and " + "wait queue length [" + waitQueueLength + "]");
            }
        } else {
            if (estimatedQueueWaitTime != -1 || comparator == LoadComparator.QUEUE_LENGTH) {
                currentNode.setQueueWaitTime(estimatedQueueWaitTime).setQueueLength(waitQueueLength).updateTimestamp();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Updating ClusterNode [" + rmNode.getNodeID() + "] " + "with queue wait time [" + estimatedQueueWaitTime + "] and " + "wait queue length [" + waitQueueLength + "]");
                }
            } else {
                this.clusterNodes.remove(rmNode.getNodeID());
                LOG.info("Deleting ClusterNode [" + rmNode.getNodeID() + "] " + "with queue wait time [" + currentNode.queueWaitTime + "] and " + "wait queue length [" + currentNode.queueLength + "]");
            }
        }
    } finally {
        writeLock.unlock();
    }
}
Also used : OpportunisticContainersStatus(org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock)

Example 2 with OpportunisticContainersStatus

use of org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus in project hadoop by apache.

the class TestRMWebServicesNodes method verifyNodeInfoGeneric.

public void verifyNodeInfoGeneric(RMNode node, String state, String rack, String id, String nodeHostName, String nodeHTTPAddress, long lastHealthUpdate, String healthReport, int numContainers, long usedMemoryMB, long availMemoryMB, long usedVirtualCores, long availVirtualCores, String version, int nodePhysicalMemoryMB, int nodeVirtualMemoryMB, double nodeCPUUsage, int containersPhysicalMemoryMB, int containersVirtualMemoryMB, double containersCPUUsage, int numRunningOpportContainers, long usedMemoryOpportGB, int usedVirtualCoresOpport, int numQueuedContainers) throws JSONException, Exception {
    ResourceScheduler sched = rm.getResourceScheduler();
    SchedulerNodeReport report = sched.getNodeReport(node.getNodeID());
    OpportunisticContainersStatus opportunisticStatus = node.getOpportunisticContainersStatus();
    WebServicesTestUtils.checkStringMatch("state", node.getState().toString(), state);
    WebServicesTestUtils.checkStringMatch("rack", node.getRackName(), rack);
    WebServicesTestUtils.checkStringMatch("id", node.getNodeID().toString(), id);
    WebServicesTestUtils.checkStringMatch("nodeHostName", node.getNodeID().getHost(), nodeHostName);
    WebServicesTestUtils.checkStringMatch("healthReport", String.valueOf(node.getHealthReport()), healthReport);
    String expectedHttpAddress = node.getNodeID().getHost() + ":" + node.getHttpPort();
    WebServicesTestUtils.checkStringMatch("nodeHTTPAddress", expectedHttpAddress, nodeHTTPAddress);
    WebServicesTestUtils.checkStringMatch("version", node.getNodeManagerVersion(), version);
    if (node.getNodeUtilization() != null) {
        ResourceUtilization nodeResource = ResourceUtilization.newInstance(nodePhysicalMemoryMB, nodeVirtualMemoryMB, (float) nodeCPUUsage);
        assertEquals("nodeResourceUtilization doesn't match", node.getNodeUtilization(), nodeResource);
    }
    if (node.getAggregatedContainersUtilization() != null) {
        ResourceUtilization containerResource = ResourceUtilization.newInstance(containersPhysicalMemoryMB, containersVirtualMemoryMB, (float) containersCPUUsage);
        assertEquals("containerResourceUtilization doesn't match", node.getAggregatedContainersUtilization(), containerResource);
    }
    long expectedHealthUpdate = node.getLastHealthReportTime();
    assertEquals("lastHealthUpdate doesn't match, got: " + lastHealthUpdate + " expected: " + expectedHealthUpdate, expectedHealthUpdate, lastHealthUpdate);
    if (report != null) {
        assertEquals("numContainers doesn't match: " + numContainers, report.getNumContainers(), numContainers);
        assertEquals("usedMemoryMB doesn't match: " + usedMemoryMB, report.getUsedResource().getMemorySize(), usedMemoryMB);
        assertEquals("availMemoryMB doesn't match: " + availMemoryMB, report.getAvailableResource().getMemorySize(), availMemoryMB);
        assertEquals("usedVirtualCores doesn't match: " + usedVirtualCores, report.getUsedResource().getVirtualCores(), usedVirtualCores);
        assertEquals("availVirtualCores doesn't match: " + availVirtualCores, report.getAvailableResource().getVirtualCores(), availVirtualCores);
    }
    if (opportunisticStatus != null) {
        assertEquals("numRunningOpportContainers doesn't match: " + numRunningOpportContainers, opportunisticStatus.getRunningOpportContainers(), numRunningOpportContainers);
        assertEquals("usedMemoryOpportGB doesn't match: " + usedMemoryOpportGB, opportunisticStatus.getOpportMemoryUsed(), usedMemoryOpportGB);
        assertEquals("usedVirtualCoresOpport doesn't match: " + usedVirtualCoresOpport, opportunisticStatus.getOpportCoresUsed(), usedVirtualCoresOpport);
        assertEquals("numQueuedContainers doesn't match: " + numQueuedContainers, opportunisticStatus.getQueuedOpportContainers(), numQueuedContainers);
    }
}
Also used : OpportunisticContainersStatus(org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus) SchedulerNodeReport(org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport) ResourceScheduler(org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler) ResourceUtilization(org.apache.hadoop.yarn.api.records.ResourceUtilization)

Example 3 with OpportunisticContainersStatus

use of org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus in project hadoop by apache.

the class TestNodeQueueLoadMonitor method createRMNode.

private RMNode createRMNode(String host, int port, int waitTime, int queueLength) {
    RMNode node1 = Mockito.mock(RMNode.class);
    NodeId nID1 = new FakeNodeId(host, port);
    Mockito.when(node1.getNodeID()).thenReturn(nID1);
    OpportunisticContainersStatus status1 = Mockito.mock(OpportunisticContainersStatus.class);
    Mockito.when(status1.getEstimatedQueueWaitTime()).thenReturn(waitTime);
    Mockito.when(status1.getWaitQueueLength()).thenReturn(queueLength);
    Mockito.when(node1.getOpportunisticContainersStatus()).thenReturn(status1);
    return node1;
}
Also used : OpportunisticContainersStatus(org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus) RMNode(org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode) NodeId(org.apache.hadoop.yarn.api.records.NodeId)

Example 4 with OpportunisticContainersStatus

use of org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus in project hadoop by apache.

the class TestOpportunisticContainerAllocatorAMService method getOppurtunisticStatus.

private OpportunisticContainersStatus getOppurtunisticStatus(int waitTime, int queueLength) {
    OpportunisticContainersStatus status1 = Mockito.mock(OpportunisticContainersStatus.class);
    Mockito.when(status1.getEstimatedQueueWaitTime()).thenReturn(waitTime);
    Mockito.when(status1.getWaitQueueLength()).thenReturn(queueLength);
    return status1;
}
Also used : OpportunisticContainersStatus(org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus)

Example 5 with OpportunisticContainersStatus

use of org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus 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)

Aggregations

OpportunisticContainersStatus (org.apache.hadoop.yarn.server.api.records.OpportunisticContainersStatus)5 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 NodeId (org.apache.hadoop.yarn.api.records.NodeId)1 ResourceUtilization (org.apache.hadoop.yarn.api.records.ResourceUtilization)1 NodeHeartbeatRequestPBImpl (org.apache.hadoop.yarn.server.api.protocolrecords.impl.pb.NodeHeartbeatRequestPBImpl)1 NodeStatus (org.apache.hadoop.yarn.server.api.records.NodeStatus)1 RMNode (org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode)1 ResourceScheduler (org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler)1 SchedulerNodeReport (org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport)1 Test (org.junit.Test)1