Example usage for org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair AllocationFileLoaderService AllocationFileLoaderService

List of usage examples for org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair AllocationFileLoaderService AllocationFileLoaderService

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair AllocationFileLoaderService AllocationFileLoaderService.

Prototype

public AllocationFileLoaderService() 

Source Link

Usage

From source file:com.cloudera.impala.util.RequestPoolService.java

License:Apache License

/**
 * Creates a RequestPoolService instance with a configuration containing the specified
 * fair-scheduler.xml and llama-site.xml.
 *
 * @param fsAllocationPath path to the fair scheduler allocation file.
 * @param llamaSitePath path to the Llama configuration file.
 *///  w  w  w . j a v a 2 s  .c om
public RequestPoolService(final String fsAllocationPath, final String llamaSitePath) {
    Preconditions.checkNotNull(fsAllocationPath);
    running_ = new AtomicBoolean(false);
    allocationConf_ = new AtomicReference<AllocationConfiguration>();
    URL fsAllocationURL = getURL(fsAllocationPath);
    if (fsAllocationURL == null) {
        throw new IllegalArgumentException("Unable to find allocation configuration file: " + fsAllocationPath);
    }
    Configuration allocConf = new Configuration(false);
    allocConf.set(FairSchedulerConfiguration.ALLOCATION_FILE, fsAllocationURL.getPath());
    allocLoader_ = new AllocationFileLoaderService();
    allocLoader_.init(allocConf);

    if (!Strings.isNullOrEmpty(llamaSitePath)) {
        llamaConfUrl_ = getURL(llamaSitePath);
        if (llamaConfUrl_ == null) {
            throw new IllegalArgumentException("Unable to find Llama configuration file: " + llamaSitePath);
        }
        llamaConf_ = new Configuration(false);
        llamaConf_.addResource(llamaConfUrl_);
        llamaConfWatcher_ = new FileWatchService(new File(llamaConfUrl_.getPath()), new LlamaConfWatcher());
    } else {
        llamaConfWatcher_ = null;
        llamaConfUrl_ = null;
    }
}

From source file:com.cloudera.llama.am.LlamaAMServer.java

License:Apache License

@Override
protected void startService() {
    startHttpServer();/*from  w  w w .  j av a2 s .c  o  m*/
    try {
        Security.loginToHadoop(getServerConf());
        Class<? extends NodeMapper> klass = getServerConf().getNodeMappingClass();
        nodeMapper = ReflectionUtils.newInstance(klass, getConf());
        clientNotificationService = new ClientNotificationService(getServerConf(), nodeMapper,
                getMetricRegistry());
        clientNotificationService.addListener(this);
        clientNotificationService.start();
        clientNotificationService.addListener(restData);

        // For mapping reservations to queues and checking queue ACLs
        YarnConfiguration yarnConf = new YarnConfiguration();

        // Check the token renew interval and set the default here so that we can
        // renew the RMConnectors properly.
        long renewInterval = yarnConf.getLong(YarnConfiguration.DELEGATION_TOKEN_MAX_LIFETIME_KEY,
                YarnConfiguration.DELEGATION_TOKEN_RENEW_INTERVAL_DEFAULT);
        LlamaAM.RM_CONNECTOR_RECYCLE_INTERVAL_DEFAULT = renewInterval * 3 / 4;

        allocConf = new AtomicReference<AllocationConfiguration>();
        allocsLoader = new AllocationFileLoaderService();
        allocsLoader.init(yarnConf);
        allocsLoader.setReloadListener(new AllocationFileLoaderService.Listener() {
            @Override
            public void onReload(AllocationConfiguration allocs) {
                allocConf.set(allocs);
            }
        });
        try {
            allocsLoader.reloadAllocations();
            allocsLoader.start();
        } catch (Exception ex) {
            LOG.warn("Failed to load queue allocations");
        }
        if (allocConf.get() == null) {
            allocConf.set(new AllocationConfiguration(yarnConf));
        }

        getConf().set(YarnRMConnector.ADVERTISED_HOSTNAME_KEY,
                ThriftEndPoint.getServerAddress(getServerConf()));
        getConf().setInt(YarnRMConnector.ADVERTISED_PORT_KEY, ThriftEndPoint.getServerPort(getServerConf()));
        getConf().set(YarnRMConnector.ADVERTISED_TRACKING_URL_KEY, getHttpLlamaUI());
        llamaAm = LlamaAM.create(getConf());
        asyncListener = new AsyncLlamaAMListener(restData);
        asyncListener.setMetricRegistry(getMetricRegistry());
        asyncListener.start();
        llamaAm.addListener(asyncListener);
        llamaAm.setMetricRegistry(getMetricRegistry());
        llamaAm.start();
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}