首页 > 其他分享 >dremio 的配置处理简单说明

dremio 的配置处理简单说明

时间:2023-01-19 16:00:24浏览次数:50  
标签:dremio reference 配置 简单 null com final append

dremio 的配置基于了typesafe 的config

参考配置

  • 模块级别的配置
    sabot-module.conf
 
dremio.classpath.scanning {
    base.classes += "com.dremio.dac.cmd.upgrade.UpgradeTask"
    packages += "com.dremio.dac"
    packages += "com.dremio.dac.support.SupportService"
    package += "com.dremio.dac.support.QueryLogBundleService"
 
    annotations += "com.dremio.dac.cmd.AdminCommand"
    packages += "com.dremio.dac.cmd"
    packages += "com.dremio.dac.cmd.upgrade"
}
  • 参考配置(基础默认的)
    dremio.conf 运行配置
 
paths: {
  # the local path for dremio to store data.
  local: ${DREMIO_HOME}"/data"
 
  # the distributed path Dremio data including job results, downloads, uploads, etc
  #dist: "pdfs://"${paths.local}"/pdfs"
}
 
services: {
  coordinator.enabled: true,
  coordinator.master.enabled: true,
  executor.enabled: true,
  flight.use_session_service: true
}
   

参考类图

typesafe Config 类图

 

 

公共配置加载处理

DremioConfig 配置

 
public static DremioConfig create(final URL userConfigPath, SabotConfig sabotConfig) {
    Config reference = null;
 
    final ClassLoader[] classLoaders = ClasspathHelper.classLoaders();
    for (ClassLoader classLoader : classLoaders) {
      final URL configUrl = classLoader.getResource(REFERENCE_CONFIG);
      if(configUrl == null){
        continue;
      }
      Preconditions.checkArgument(reference == null, "Attempted to load more than one reference configuration.");
      // 参考配置 dremio-reference.conf 
      reference = ConfigFactory.parseResources(classLoader, REFERENCE_CONFIG);
    }
 
    Preconditions.checkNotNull(reference, "Unable to find the reference configuration.");
   
    Config userConfig = null;
 
    if(userConfigPath == null){
 
      for (ClassLoader classLoader : classLoaders) {
       // 默认配置 dremio.conf
        final URL configUrl = classLoader.getResource(DEFAULT_USER_CONFIG);
        if(configUrl == null){
          continue;
        }
        Preconditions.checkArgument(userConfig == null, "Attempted to load more than one user configuration.");
        userConfig = ConfigFactory.parseResources(classLoader, DEFAULT_USER_CONFIG);
      }
 
    } else {
 
      userConfig = ConfigFactory.parseURL(userConfigPath, ConfigParseOptions.defaults().setAllowMissing(false));
    }
 
    final Config effective;
 
    if(userConfig != null){
 
      effective = userConfig;
    } else {
      effective = reference;
    }
 
    final Config skinned =
        applySystemProperties(
          applyLegacySystemProperties(effective),
          reference);
 
    return new DremioConfig(sabotConfig, skinned, reference, determineNode());
  }

SabotConfig 配置加载

sabot-override.conf 加载处理

private static SabotConfig doCreate(String overrideFileResourcePathname,
                                      Properties overriderProps) {
    final StringBuilder logString = new StringBuilder();
    final Stopwatch watch = Stopwatch.createStarted();
    overrideFileResourcePathname =
        overrideFileResourcePathname == null
            ? CommonConstants.CONFIG_OVERRIDE_RESOURCE_PATHNAME
            : overrideFileResourcePathname;
 
    // 1. Load defaults configuration file.
    Config fallback = null;
    final ClassLoader[] classLoaders = ClasspathHelper.classLoaders();
    for (ClassLoader classLoader : classLoaders) {
     //  加载默认的
      final URL url =
          classLoader.getResource(CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME);
      if (null != url) {
        logString.append("Base Configuration:\n\t- ").append(url).append("\n");
        fallback =
            ConfigFactory.load(classLoader,
                               CommonConstants.CONFIG_DEFAULT_RESOURCE_PATHNAME);
        break;
      }
    }
    // 加载模块的配置
    // 2. Load per-module configuration files.
    final Collection<URL> urls = ClassPathScanner.getConfigURLs();
    logString.append("\nIntermediate Configuration and Plugin files, in order of precedence:\n");
    for (URL url : urls) {
      logString.append("\t- ").append(url).append("\n");
      fallback = ConfigFactory.parseURL(url).withFallback(fallback);
    }
    logString.append("\n");
    // 基于环境变量的配置
    // 3. Load any specified overrides configuration file along with any
    //    overrides from JVM system properties (e.g., {-Dname=value").
 
    // (Per ConfigFactory.load(...)'s mention of using Thread.getContextClassLoader():)
    final URL overrideFileUrl =
        Thread.currentThread().getContextClassLoader().getResource(overrideFileResourcePathname);
    if (null != overrideFileUrl ) {
      logString.append("Override File: ").append(overrideFileUrl).append("\n");
    }
    Config effectiveConfig =
        ConfigFactory.load(overrideFileResourcePathname).withFallback(fallback);
 
    // 4. Apply any overriding properties.
    if (overriderProps != null) {
      logString.append("Overridden Properties:\n");
      for(Entry<Object, Object> entry : overriderProps.entrySet()){
        logString.append("\t-").append(entry.getKey()).append(" = ").append(entry.getValue()).append("\n");
      }
      logString.append("\n");
      effectiveConfig =
          ConfigFactory.parseProperties(overriderProps).withFallback(effectiveConfig);
    }
 
    // 5. Create SabotConfig object from Config object.
    logger.info("Configuration and plugin file(s) identified in {}ms.\n{}",
        watch.elapsed(TimeUnit.MILLISECONDS),
        logString);
    return new SabotConfig(effectiveConfig.resolve());
  }

说明

dremio 基于了typesafe 的config提供了强大的配置管理是一个值得借鉴的设计

参考资料

common/src/main/java/com/dremio/common/config/SabotConfig.java
common/src/main/java/com/dremio/config/DremioConfig.java
common/src/main/java/com/dremio/common/scanner/ClassPathScanner.java
common/src/main/java/com/dremio/common/config/CommonConstants.java
https://github.com/lightbend/config

标签:dremio,reference,配置,简单,null,com,final,append
From: https://www.cnblogs.com/rongfengliang/p/17061676.html

相关文章

  • redis配置文件
    Redis的配置文件位于Redis安装目录下,文件名为redis.conf(Windows名为redis.windows.conf)。可以在登入Redis后通过CONFIG命令查看或设置配置项通过config命令查......
  • RT-Thread Studio使用——创建工程并配置外部时钟(转)
    硬件:正点原子阿波罗F429开发板,主控STM32F429IGT6,晶振25MHz。软件:RT-ThreadStudioRT-Thread版本:4.1.01.创建工程  根据所使用的硬件信息,配置以上信息,注意红色框中......
  • dremio DACModule 模块加载简单说明
    dremioDACModule主要是模块加载初始化以及组合,是一个比较重要的模式,同时也支持基于配置进行加载(有点很多了,后边简单介绍)加载机制支持配置加载可以通过dremio运行配......
  • Redis下载安装与配置(linux)
    一、Redis下载与安装1.下载安装包官网下载地址:Download|Redis点击"Download7.0.7",即可进行下载。2.将安装包上传至服务器2.1将安装包上传至/usr/local目录并解压......
  • Swagger UI接入配置
     SwaggerUI接入配置这里的接入我们依赖于DRF官方推荐的一个第三方包: drf-yasg,下面的接入步骤其实都是按照这个第三方库的文档进行配置,这里只是个最最入门的使用,对于......
  • MetadataReader、ClassMetadata、AnnotationMetadata的简单使用
    在Spring源码中有很多场景会去解析类的信息,比如类名、类中的方法、类上的注解,这些都可以称之为类的元数据,在Spring中对类的元数据做了抽象,并提供了一些工具类。MetadataRead......
  • Django[三]配置文件settings.py
    一.配置文件详细说明参考:http://c.biancheng.net/view/7475.html二、根据自己的需要修改配置文件1.修改DATABASES连接mysqlDATABASES={'default':{'E......
  • CentOS7下配置使用JumpServer 堡垒机 (图文教程)
    前面介绍了如何在《CentOS7下搭建JumpServer堡垒机》,基于这篇文章的环境搭建过程,接着介绍安装后的的功能配置使用。首次wbe登录,https://ip:80,默认账号密码:admin,admin;这......
  • 第四十九章 使用 ^SystemPerformance 监视性能 - 复制配置文件
    第四十九章使用^SystemPerformance监视性能-复制配置文件复制配置文件可以使用以下API命令将现有配置文件复制到具有不同名称的文件:setrc=$$copyprofile^System......
  • 一个想活得简单的程序猿的2022年终总结!
    前言今年的总结相比以往来说,可写的太少了,但看到我17年开始写的年终总结,已定下每年写下的承诺,因此即便可写的不多,但是还是写下吧,毕竟又过了一年,总有东西会留下!今年事件......