Search in sources :

Example 1 with QueuePlacementPolicy

use of org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueuePlacementPolicy in project hive by apache.

the class FairSchedulerShim method refreshDefaultQueue.

@Override
public void refreshDefaultQueue(Configuration conf, String userName) throws IOException {
    String requestedQueue = YarnConfiguration.DEFAULT_QUEUE_NAME;
    final AtomicReference<AllocationConfiguration> allocConf = new AtomicReference<AllocationConfiguration>();
    AllocationFileLoaderService allocsLoader = new AllocationFileLoaderService();
    allocsLoader.init(conf);
    allocsLoader.setReloadListener(new AllocationFileLoaderService.Listener() {

        @Override
        public void onReload(AllocationConfiguration allocs) {
            allocConf.set(allocs);
        }
    });
    try {
        allocsLoader.reloadAllocations();
    } catch (Exception ex) {
        throw new IOException("Failed to load queue allocations", ex);
    }
    if (allocConf.get() == null) {
        allocConf.set(new AllocationConfiguration(conf));
    }
    QueuePlacementPolicy queuePolicy = allocConf.get().getPlacementPolicy();
    if (queuePolicy != null) {
        requestedQueue = queuePolicy.assignAppToQueue(requestedQueue, userName);
        if (StringUtils.isNotBlank(requestedQueue)) {
            LOG.debug("Setting queue name to " + requestedQueue + " for user " + userName);
            conf.set(MR2_JOB_QUEUE_PROPERTY, requestedQueue);
        }
    }
}
Also used : QueuePlacementPolicy(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueuePlacementPolicy) AllocationConfiguration(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AllocationConfiguration) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException) AllocationFileLoaderService(org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AllocationFileLoaderService) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 AllocationConfiguration (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AllocationConfiguration)1 AllocationFileLoaderService (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.AllocationFileLoaderService)1 QueuePlacementPolicy (org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.QueuePlacementPolicy)1