Example usage for org.apache.hadoop.yarn.api.records NodeId getHost

List of usage examples for org.apache.hadoop.yarn.api.records NodeId getHost

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records NodeId getHost.

Prototype

@Public
@Stable
public abstract String getHost();

Source Link

Document

Get the hostname of the node.

Usage

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

License:Apache License

@Override
public void afterSchedulerEventHandled(SchedulerEvent event) {
    switch (event.getType()) {
    case NODE_ADDED:
        if (!(event instanceof NodeAddedSchedulerEvent)) {
            LOGGER.error("{} not an instance of {}", event.getClass().getName(),
                    NodeAddedSchedulerEvent.class.getName());
            return;
        }/*from w w  w . j a  va  2  s.  co  m*/

        NodeAddedSchedulerEvent nodeAddedEvent = (NodeAddedSchedulerEvent) event;
        NodeId nodeId = nodeAddedEvent.getAddedRMNode().getNodeID();
        String host = nodeId.getHost();

        SchedulerNode node = yarnScheduler.getSchedulerNode(nodeId);
        nodeStore.add(node);
        LOGGER.info("afterSchedulerEventHandled: NM registration from node {}", host);
        break;

    case NODE_UPDATE:
        if (!(event instanceof NodeUpdateSchedulerEvent)) {
            LOGGER.error("{} not an instance of {}", event.getClass().getName(),
                    NodeUpdateSchedulerEvent.class.getName());
            return;
        }

        RMNode rmNode = ((NodeUpdateSchedulerEvent) event).getRMNode();
        handleContainerAllocation(rmNode);

        break;

    default:
        break;
    }
}

From source file:org.apache.myriad.TestObjectFactory.java

License:Apache License

public static RMNode getRMNode(String host, int port, Resource resource) {
    NodeId id = NodeId.newInstance(host, port);
    RMContext context = new MockRMContext();
    return new RMNodeImpl(id, context, id.getHost(), id.getPort(), id.getPort(), new NodeBase(host, "/tmp"),
            resource, "version-one");
}

From source file:org.apache.slider.server.appmaster.state.RoleHistoryUtils.java

License:Apache License

public static String hostnameOf(Container container) {
    NodeId nodeId = container.getNodeId();
    if (nodeId == null) {
        throw new RuntimeException("Container has no node ID: %s" + SliderUtils.containerToString(container));
    }//  www .j ava2 s.  c om
    return nodeId.getHost();
}

From source file:org.apache.tajo.master.YarnContainerProxy.java

License:Apache License

public YarnContainerProxy(QueryMasterTask.QueryMasterTaskContext context, Configuration conf, YarnRPC yarnRPC,
        Container container, ExecutionBlockId executionBlockId) {
    super(context, conf, executionBlockId, container);
    this.yarnRPC = yarnRPC;

    NodeId nodeId = container.getNodeId();
    this.containerMgrAddress = nodeId.getHost() + ":" + nodeId.getPort();
    this.containerToken = container.getContainerToken();
}

From source file:org.apache.tajo.worker.TajoResourceAllocator.java

License:Apache License

private void stopExecutionBlock(ExecutionBlockId executionBlockId, NodeId worker) {
    NettyClientBase tajoWorkerRpc = null;
    try {//from w  ww .j a v  a 2 s  .  c  om
        InetSocketAddress addr = new InetSocketAddress(worker.getHost(), worker.getPort());
        tajoWorkerRpc = RpcConnectionPool.getPool().getConnection(addr, TajoWorkerProtocol.class, true);
        TajoWorkerProtocol.TajoWorkerProtocolService tajoWorkerRpcClient = tajoWorkerRpc.getStub();

        tajoWorkerRpcClient.stopExecutionBlock(null, executionBlockId.getProto(), NullCallback.get());
    } catch (Throwable e) {
        LOG.error(e.getMessage(), e);
    } finally {
        RpcConnectionPool.getPool().releaseConnection(tajoWorkerRpc);
    }
}

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

License:Apache License

@Override
public synchronized void blacklistNode(NodeId nodeId) {
    LOG.info("Blacklisting node: {}", nodeId);
    blacklistedNodes.add(nodeId);//w  w  w .  j  a  v a 2s  .co m
    client.updateBlacklist(Collections.singletonList(nodeId.getHost()), null);
}

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

License:Apache License

@Override
public synchronized void unblacklistNode(NodeId nodeId) {
    if (blacklistedNodes.remove(nodeId)) {
        LOG.info("Removing blacklist for node: {}", nodeId);
        client.updateBlacklist(null, Collections.singletonList(nodeId.getHost()));
    }/*from   w  w  w .j a  va2  s .c  o m*/
}

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

License:Apache License

private void addToBlackList(NodeId nodeId) {
    String host = nodeId.getHost();
    Set<NodeId> nodes;//from  www.ja v a  2  s  . co m

    if (!blacklistMap.containsKey(host)) {
        nodes = new HashSet<NodeId>();
        blacklistMap.put(host, nodes);
    } else {
        nodes = blacklistMap.get(host);
    }

    if (!nodes.contains(nodeId)) {
        nodes.add(nodeId);
    }
}

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

License:Apache License

private void addToBlackList(NodeId nodeId) {
    String host = nodeId.getHost();

    if (!blacklistMap.containsKey(host)) {
        blacklistMap.putIfAbsent(host, new HashSet<NodeId>());
    }//w  ww  .ja  va 2  s  .  c  o  m
    Set<NodeId> nodes = blacklistMap.get(host);

    if (!nodes.contains(nodeId)) {
        nodes.add(nodeId);
    }
}

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

License:Apache License

private static NodeReport generateNodeReport(NodeId nodeId, NodeState nodeState) {
    NodeReport nodeReport = NodeReport.newInstance(nodeId, nodeState, nodeId.getHost() + ":3433",
            "/default-rack", Resource.newInstance(0, 0), Resource.newInstance(10240, 12), 10,
            nodeState.toString(), System.currentTimeMillis());
    return nodeReport;
}