Example usage for org.apache.hadoop.yarn.client.api AMRMClient.ContainerRequest toString

List of usage examples for org.apache.hadoop.yarn.client.api AMRMClient.ContainerRequest toString

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.client.api AMRMClient.ContainerRequest toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:com.toy.TOYMaster.java

License:Apache License

private AMRMClient.ContainerRequest newTomcatContainer() {
    Priority pri = Records.newRecord(Priority.class);
    pri.setPriority(0);//  www.j  a  v  a 2s .co  m
    Resource capability = Records.newRecord(Resource.class);
    capability.setMemory(32);
    AMRMClient.ContainerRequest request = new AMRMClient.ContainerRequest(capability, null, null, pri);
    LOG.info("Requested Tomcat container: " + request.toString());
    return request;
}

From source file:org.apache.hama.bsp.ApplicationMaster.java

License:Apache License

/**
 * Setup the request that will be sent to the RM for the container ask.
 * /*from  w  w  w  .ja  va2 s .com*/
 * @return the setup ResourceRequest to be sent to RM
 */
private AMRMClient.ContainerRequest setupContainerAskForRM() {
    // setup requirements for hosts
    // using * as any host will do for the distributed shell app
    // set the priority for the request
    // TODO - what is the range for priority? how to decide?
    Priority pri = Priority.newInstance(requestPriority);

    // Set up resource type requirements
    // For now, memory and CPU are supported so we set memory and cpu
    // requirements
    Resource capability = Resource.newInstance(containerMemory, containerVirtualCores);

    AMRMClient.ContainerRequest request = new AMRMClient.ContainerRequest(capability, null, null, pri);
    LOG.info("Requested container ask: " + request.toString());
    return request;
}

From source file:org.apache.reef.runtime.yarn.driver.YarnContainerManager.java

License:Apache License

/**
 * Handles new container allocations. Calls come from YARN.
 *
 * @param container newly allocated//from www  .  jav  a  2s  . c  o  m
 */
private void handleNewContainer(final Container container, final boolean isRecoveredContainer) {

    LOG.log(Level.FINE, "allocated container: id[ {0} ]", container.getId());
    // recovered container is not new allocation, it is just checking back from previous driver failover
    if (!isRecoveredContainer) {
        synchronized (this) {
            if (matchContainerWithPendingRequest(container)) {
                final AMRMClient.ContainerRequest matchedRequest = this.requestsAfterSentToRM.peek();
                this.containerRequestCounter.decrement();
                this.containers.add(container);

                LOG.log(Level.FINEST, "{0} matched with {1}",
                        new Object[] { container.toString(), matchedRequest.toString() });

                // Due to the bug YARN-314 and the workings of AMRMCClientAsync, when x-priority m-capacity zero-container request
                // and x-priority n-capacity nonzero-container request are sent together, where m > n, RM ignores the latter.
                // Therefore it is necessary avoid sending zero-container request, even it means getting extra containers.
                // It is okay to send nonzero m-capacity and n-capacity request together since bigger containers can be matched.
                // TODO: revisit this when implementing locality-strictness (i.e. a specific rack request can be ignored)
                if (this.requestsAfterSentToRM.size() > 1) {
                    try {
                        this.resourceManager.removeContainerRequest(matchedRequest);
                    } catch (final Exception e) {
                        LOG.log(Level.WARNING,
                                "Nothing to remove from Async AMRM client's queue, removal attempt failed with exception",
                                e);
                    }
                }

                this.requestsAfterSentToRM.remove();
                doHomogeneousRequests();

                LOG.log(Level.FINEST, "Allocated Container: memory = {0}, core number = {1}", new Object[] {
                        container.getResource().getMemory(), container.getResource().getVirtualCores() });
                this.reefEventHandlers.onResourceAllocation(ResourceAllocationProto.newBuilder()
                        .setIdentifier(container.getId().toString()).setNodeId(container.getNodeId().toString())
                        .setResourceMemory(container.getResource().getMemory())
                        .setVirtualCores(container.getResource().getVirtualCores()).build());
                // we only add this to Container log after the Container has been registered as an REEF Evaluator.
                logContainerAddition(container.getId().toString());
                this.updateRuntimeStatus();
            } else {
                LOG.log(Level.WARNING, "Got an extra container {0} that doesn't match, releasing...",
                        container.getId());
                this.resourceManager.releaseAssignedContainer(container.getId());
            }
        }
    }
}