Example usage for org.apache.hadoop.yarn.api.records Container setNodeId

List of usage examples for org.apache.hadoop.yarn.api.records Container setNodeId

Introduction

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

Prototype

@Private
    @Unstable
    public abstract void setNodeId(NodeId nodeId);

Source Link

Usage

From source file:alluxio.yarn.ContainerAllocatorTest.java

License:Apache License

private Answer<Void> allocateFirstHostAnswer(final ContainerAllocator containerAllocator) {
    return new Answer<Void>() {
        @Override//  ww w  .  j  av  a2  s.  com
        public Void answer(InvocationOnMock invocation) throws Throwable {
            ContainerRequest containerRequest = invocation.getArgumentAt(0, ContainerRequest.class);
            Container container = Records.newRecord(Container.class);
            container.setNodeId(NodeId.newInstance(containerRequest.getNodes().get(0), 0));
            containerAllocator.allocateContainer(container);
            return null;
        }
    };
}

From source file:org.apache.hoya.yarn.appmaster.state.AppState.java

License:Apache License

/**
 * build up the special master node, which lives
 * in the live node set but has a lifecycle bonded to the AM
 * @param containerId the AM master/*w ww  . jav a2s. co m*/
 * @param host
 * @param nodeHttpAddress
 */
public void buildAppMasterNode(ContainerId containerId, String host, int amPort, String nodeHttpAddress) {
    Container container = new ContainerPBImpl();
    container.setId(containerId);
    NodeId nodeId = NodeId.newInstance(host, amPort);
    container.setNodeId(nodeId);
    container.setNodeHttpAddress(nodeHttpAddress);
    RoleInstance am = new RoleInstance(container);
    am.role = HoyaKeys.COMPONENT_AM;
    appMasterNode = am;
    //it is also added to the set of live nodes
    getLiveNodes().put(containerId, am);
}

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

License:Apache License

/**
 * build up the special master node, which lives
 * in the live node set but has a lifecycle bonded to the AM
 * @param containerId the AM master//from w w w  . j  a va2  s . c o m
 * @param host hostname
 * @param amPort port
 * @param nodeHttpAddress http address: may be null
 */
public void buildAppMasterNode(ContainerId containerId, String host, int amPort, String nodeHttpAddress) {
    Container container = new ContainerPBImpl();
    container.setId(containerId);
    NodeId nodeId = NodeId.newInstance(host, amPort);
    container.setNodeId(nodeId);
    container.setNodeHttpAddress(nodeHttpAddress);
    RoleInstance am = new RoleInstance(container);
    am.role = SliderKeys.COMPONENT_AM;
    appMasterNode = am;
    //it is also added to the set of live nodes
    getLiveNodes().put(containerId, am);

    // patch up the role status
    RoleStatus roleStatus = roleStatusMap.get((SliderKeys.ROLE_AM_PRIORITY_INDEX));
    roleStatus.setDesired(1);
    roleStatus.incActual();
    roleStatus.incStarted();
}

From source file:org.springframework.yarn.examples.grid.yarn.YarnManagedContainerGroupsTests.java

License:Apache License

/**
 * Mocks a yarn container with hostname hostname1 and container id {@link #CID1}
 *
 * @return the mocked Yarn Container//  ww  w  .  j  a va 2  s  .co  m
 */
private Container mockContainer1() {
    Container container = Records.newRecord(Container.class);
    NodeId nodeId = Records.newRecord(NodeId.class);
    nodeId.setHost(HOST1);
    container.setNodeId(nodeId);
    ContainerId containerId = ConverterUtils.toContainerId(CID1);
    container.setId(containerId);
    return container;
}

From source file:org.springframework.yarn.examples.grid.yarn.YarnManagedContainerGroupsTests.java

License:Apache License

/**
 * Mocks a yarn container with hostname hostname2 and container id {@link #CID2}
 *
 * @return the mocked Yarn Container//from  ww w . java 2s. com
 */
private Container mockContainer2() {
    Container container = Records.newRecord(Container.class);
    NodeId nodeId = Records.newRecord(NodeId.class);
    nodeId.setHost(HOST2);
    container.setNodeId(nodeId);
    ContainerId containerId = ConverterUtils.toContainerId(CID2);
    container.setId(containerId);
    return container;
}

From source file:org.springframework.yarn.examples.grid.yarn.YarnManagedContainerGroupsTests.java

License:Apache License

/**
 * Mocks a yarn container with hostname hostname3 and container id {@link #CID3}
 *
 * @return the mocked Yarn Container/*  w ww  . jav  a  2  s .c o m*/
 */
private Container mockContainer3() {
    Container container = Records.newRecord(Container.class);
    NodeId nodeId = Records.newRecord(NodeId.class);
    nodeId.setHost(HOST3);
    container.setNodeId(nodeId);
    ContainerId containerId = ConverterUtils.toContainerId(CID3);
    container.setId(containerId);
    return container;
}