Example usage for org.apache.hadoop.yarn.server.resourcemanager.rmnode RMNode getHostName

List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.rmnode RMNode getHostName

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.resourcemanager.rmnode RMNode getHostName.

Prototype

public String getHostName();

Source Link

Document

the hostname of this node

Usage

From source file:io.hops.util.RmStreamingProcessor.java

License:Apache License

private void triggerEvent(final RMNode rmNode, PendingEvent pendingEvent) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("NodeUpdate event_pending event trigger event: " + pendingEvent.getId().getEventId() + " : "
                + pendingEvent.getId().getNodeId());
    }// w  w w .  j a  v a 2 s . c o m

    // TODO Maybe we should put back Hops Global Thread pool
    exec.submit(new Runnable() {
        @Override
        public void run() {
            NetUtils.normalizeHostName(rmNode.getHostName());
        }
    });

    if (pendingEvent.getType().equals(PendingEvent.Type.NODE_ADDED)) {
        LOG.debug("HOP :: PendingEventRetrieval event NodeAdded: " + pendingEvent);
        rmContext.getDispatcher().getEventHandler().handle(new NodeAddedSchedulerEvent(rmNode));
    } else if (pendingEvent.getType().equals(PendingEvent.Type.NODE_REMOVED)) {
        LOG.debug("HOP :: PendingEventRetrieval event NodeRemoved: " + pendingEvent);
        rmContext.getDispatcher().getEventHandler().handle(new NodeRemovedSchedulerEvent(rmNode));
    } else if (pendingEvent.getType().equals(PendingEvent.Type.NODE_UPDATED)) {
        if (pendingEvent.getStatus().equals(PendingEvent.Status.SCHEDULER_FINISHED_PROCESSING)) {
            LOG.debug("HOP :: NodeUpdate event - event_scheduler - finished_processing RMNode: "
                    + rmNode.getNodeID() + " pending event: " + pendingEvent.getId().getEventId());
            rmContext.getDispatcher().getEventHandler().handle(new NodeUpdateSchedulerEvent(rmNode));
        } else if (pendingEvent.getStatus().equals(PendingEvent.Status.SCHEDULER_NOT_FINISHED_PROCESSING)) {
            LOG.debug("NodeUpdate event - event_scheduler - NOT_finished_processing RMNode: "
                    + rmNode.getNodeID() + " pending event: " + pendingEvent.getId().getEventId());
        }
    }
}

From source file:org.apache.myriad.scheduler.fgs.NMHeartBeatHandler.java

License:Apache License

@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(/*from  w  w  w . java2 s .  c o  m*/
                    "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;
    }
}

From source file:org.apache.myriad.scheduler.fgs.YarnNodeCapacityManager.java

License:Apache License

/**
 * 1. Updates {@link RMNode#getTotalCapability()} with newCapacity.
 * 2. Sends out a {@link NodeResourceUpdateSchedulerEvent} that's handled by YARN's scheduler.
 * The scheduler updates the corresponding {@link SchedulerNode} with the newCapacity.
 *
 * @param rmNode//ww w .ja va2s. c  om
 * @param newCapacity
 */
@SuppressWarnings("unchecked")
public void setNodeCapacity(RMNode rmNode, Resource newCapacity) {
    //NOOP prevent YARN warning changing to same size
    if ((Resources.equals(rmNode.getTotalCapability(), newCapacity))) {
        return;
    }
    if (yarnScheduler.getSchedulerNode(rmNode.getNodeID()) == null) {
        LOGGER.info("Yarn Scheduler doesn't have node {}, probably UNHEALTHY", rmNode.getNodeID());
        return;
    }
    yarnSchedulerLock.lock();
    try {
        if (newCapacity.getMemory() < 0 || newCapacity.getVirtualCores() < 0) {
            Resource zeroed = ResourceUtils.componentwiseMax(ZERO_RESOURCE, newCapacity);
            rmNode.getTotalCapability().setMemory(zeroed.getMemory());
            rmNode.getTotalCapability().setVirtualCores(zeroed.getVirtualCores());
            LOGGER.warn("Asked to set Node {} to a value less than zero!  Had {}, setting to {}.",
                    rmNode.getHttpAddress(), rmNode.getTotalCapability().toString(), zeroed.toString());
        } else {
            rmNode.getTotalCapability().setMemory(newCapacity.getMemory());
            rmNode.getTotalCapability().setVirtualCores(newCapacity.getVirtualCores());
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info("Setting capacity for node {} to {}", rmNode.getHostName(), newCapacity);
            }
        }
        // updates the scheduler with the new capacity for the NM.
        // the event is handled by the scheduler asynchronously
        rmContext.getDispatcher().getEventHandler()
                .handle(new NodeResourceUpdateSchedulerEvent(rmNode, ResourceOption
                        .newInstance(rmNode.getTotalCapability(), RMNode.OVER_COMMIT_TIMEOUT_MILLIS_DEFAULT)));
    } finally {
        yarnSchedulerLock.unlock();
    }
}