private void setupConf(Properties propsDirectOptions) throws Exception {
    // needed so that the file is actually loaded into configuration.
    for (String f : LlapDaemonConfiguration.DAEMON_CONFIGS) {
      conf.addResource(f);
      if (conf.getResource(f) == null) {
        throw new Exception("Unable to find required config file: " + f);
      }
    }
    for (String f : LlapDaemonConfiguration.SSL_DAEMON_CONFIGS) {
      conf.addResource(f);
    }

    conf.reloadConfiguration();

    populateConfWithLlapProperties(conf, cl.getConfig());

    if (cl.getName() != null) {
      // update service registry configs - caveat: this has nothing to do with the actual settings as read by the AM
      // if needed, use --hiveconf llap.daemon.service.hosts=@llap0 to dynamically switch between instances
      conf.set(ConfVars.LLAP_DAEMON_SERVICE_HOSTS.varname, "@" + cl.getName());
      propsDirectOptions.setProperty(ConfVars.LLAP_DAEMON_SERVICE_HOSTS.varname, "@" + cl.getName());
    }

    if (cl.getLogger() != null) {
      HiveConf.setVar(conf, ConfVars.LLAP_DAEMON_LOGGER, cl.getLogger());
      propsDirectOptions.setProperty(ConfVars.LLAP_DAEMON_LOGGER.varname, cl.getLogger());
    }

    boolean isDirect = HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_ALLOCATOR_DIRECT);

    String cacheStr = LlapUtil.humanReadableByteCount(cl.getCache());
    String sizeStr = LlapUtil.humanReadableByteCount(cl.getSize());
    String xmxStr = LlapUtil.humanReadableByteCount(cl.getXmx());

    if (cl.getSize() != -1) {
      if (cl.getCache() != -1) {
        if (!HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_ALLOCATOR_MAPPED)) {
          // direct heap allocations need to be safer
          Preconditions.checkArgument(cl.getCache() < cl.getSize(), "Cache size (" + cacheStr + ") has to be smaller" +
              " than the container sizing (" + sizeStr + ")");
        } else if (cl.getCache() < cl.getSize()) {
          LOG.warn("Note that this might need YARN physical memory monitoring to be turned off "
              + "(yarn.nodemanager.pmem-check-enabled=false)");
        }
      }
      if (cl.getXmx() != -1) {
        Preconditions.checkArgument(cl.getXmx() < cl.getSize(), "Working memory (Xmx=" + xmxStr + ") has to be" +
            " smaller than the container sizing (" + sizeStr + ")");
      }
      if (isDirect && !HiveConf.getBoolVar(conf, HiveConf.ConfVars.LLAP_ALLOCATOR_MAPPED)) {
        // direct and not memory mapped
        Preconditions.checkArgument(cl.getXmx() + cl.getCache() <= cl.getSize(), "Working memory (Xmx=" +
            xmxStr + ") + cache size (" + cacheStr + ") has to be smaller than the container sizing (" + sizeStr + ")");
      }
    }

    if (cl.getExecutors() != -1) {
      conf.setLong(ConfVars.LLAP_DAEMON_NUM_EXECUTORS.varname, cl.getExecutors());
      propsDirectOptions.setProperty(ConfVars.LLAP_DAEMON_NUM_EXECUTORS.varname, String.valueOf(cl.getExecutors()));
      // TODO: vcpu settings - possibly when DRFA works right
    }

    if (cl.getIoThreads() != -1) {
      conf.setLong(ConfVars.LLAP_IO_THREADPOOL_SIZE.varname, cl.getIoThreads());
      propsDirectOptions.setProperty(ConfVars.LLAP_IO_THREADPOOL_SIZE.varname, String.valueOf(cl.getIoThreads()));
    }

    long cache = cl.getCache();
    if (cache != -1) {
      conf.set(HiveConf.ConfVars.LLAP_IO_MEMORY_MAX_SIZE.varname, Long.toString(cache));
      propsDirectOptions.setProperty(HiveConf.ConfVars.LLAP_IO_MEMORY_MAX_SIZE.varname, Long.toString(cache));
    }

    long xmx = cl.getXmx();
    if (xmx != -1) {
      // Needs more explanation here
      // Xmx is not the max heap value in JDK8. You need to subtract 50% of the survivor fraction
      // from this, to get actual usable memory before it goes into GC
      long xmxMb = (xmx / (1024L * 1024L));
      conf.setLong(ConfVars.LLAP_DAEMON_MEMORY_PER_INSTANCE_MB.varname, xmxMb);
      propsDirectOptions.setProperty(ConfVars.LLAP_DAEMON_MEMORY_PER_INSTANCE_MB.varname, String.valueOf(xmxMb));
    }

    long containerSize = cl.getSize();
    if (containerSize == -1) {
      long heapSize = xmx;
      if (!isDirect) {
        heapSize += cache;
      }
      containerSize = Math.min((long)(heapSize * 1.2), heapSize + 1024L * 1024 * 1024);
      if (isDirect) {
        containerSize += cache;
      }
    }
    long containerSizeMB = containerSize / (1024 * 1024);
    long minAllocMB = conf.getInt(YarnConfiguration.RM_SCHEDULER_MINIMUM_ALLOCATION_MB, -1);
    String containerSizeStr = LlapUtil.humanReadableByteCount(containerSize);
    Preconditions.checkArgument(containerSizeMB >= minAllocMB, "Container size (" + containerSizeStr + ") should be " +
        "greater than minimum allocation(" + LlapUtil.humanReadableByteCount(minAllocMB * 1024L * 1024L) + ")");
    conf.setLong(ConfVars.LLAP_DAEMON_YARN_CONTAINER_MB.varname, containerSizeMB);
    propsDirectOptions.setProperty(ConfVars.LLAP_DAEMON_YARN_CONTAINER_MB.varname, String.valueOf(containerSizeMB));

    LOG.info("Memory settings: container memory: {} executor memory: {} cache memory: {}", containerSizeStr, xmxStr,
        cacheStr);

    if (!StringUtils.isEmpty(cl.getLlapQueueName())) {
      conf.set(ConfVars.LLAP_DAEMON_QUEUE_NAME.varname, cl.getLlapQueueName());
      propsDirectOptions.setProperty(ConfVars.LLAP_DAEMON_QUEUE_NAME.varname, cl.getLlapQueueName());
    }
  }
This is a working configuration for the instance to merge various variables.
It is not written out for llap server usage
llap-server/src/java/org/apache/hadoop/hive/llap/cli/service/LlapServiceDriver.java