Example usage for org.apache.hadoop.yarn.util.resource Resources clone

List of usage examples for org.apache.hadoop.yarn.util.resource Resources clone

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.util.resource Resources clone.

Prototype

public static Resource clone(Resource res) 

Source Link

Usage

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

License:Apache License

@Override
public float getProgress() {
    if (stopRequested) {
        return 1;
    }//from  w w  w  .j ava2s.  com

    Collection<ContainerId> preemptedContainers;
    synchronized (this) {
        Resource freeResources = getAvailableResources();
        if (totalResources.getMemory() == 0) {
            // assume this is the first allocate callback. nothing is allocated.
            // available resource = totalResource
            // TODO this will not handle dynamic changes in resources
            totalResources = Resources.clone(freeResources);
            LOG.info("App total resource memory: {} cpu: {} activeAssignments: {}", totalResources.getMemory(),
                    totalResources.getVirtualCores(), taskAssignments.size());
        }

        ++numHeartbeats;
        if (LOG.isDebugEnabled() || numHeartbeats % 50 == 1) {
            LOG.info(constructPeriodicLog(freeResources));
        }

        preemptedContainers = maybePreempt(freeResources);
        if (preemptedContainers != null && !preemptedContainers.isEmpty()) {
            lastPreemptionHeartbeat = numHeartbeats;
        }
    }

    // perform app callback outside of locks
    if (preemptedContainers != null && !preemptedContainers.isEmpty()) {
        for (ContainerId cid : preemptedContainers) {
            LOG.info("Preempting container {} currently allocated to a task", cid);
            getContext().preemptContainer(cid);
        }
    }

    return getContext().getProgress();
}

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

License:Apache License

@Override
public float getProgress() {
    if (isStopped) {
        return 1;
    }//from  www.j  a  va 2s  .c  o  m

    if (totalResources.getMemory() == 0) {
        // assume this is the first allocate callback. nothing is allocated.
        // available resource = totalResource
        // TODO this will not handle dynamic changes in resources
        totalResources = Resources.clone(getAvailableResources());
        LOG.info("App total resource memory: " + totalResources.getMemory() + " cpu: "
                + totalResources.getVirtualCores() + " taskAllocations: " + taskAllocations.size());
    }

    preemptIfNeeded();

    return appClient.getProgress();
}

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

License:Apache License

@Override
public float getProgress() {
    if (isStopped.get()) {
        return 1;
    }//from  ww  w.j  ava2 s  . c  om

    if (totalResources.getMemory() == 0) {
        // assume this is the first allocate callback. nothing is allocated.
        // available resource = totalResource
        // TODO this will not handle dynamic changes in resources
        totalResources = Resources.clone(getAvailableResources());
        LOG.info("App total resource memory: " + totalResources.getMemory() + " cpu: "
                + totalResources.getVirtualCores() + " taskAllocations: " + taskAllocations.size());
    }

    numHeartbeats++;
    preemptIfNeeded();

    return appClientDelegate.getProgress();
}