首页 > 其他分享 >dremio ClassPathScanner 简单说明

dremio ClassPathScanner 简单说明

时间:2023-01-02 21:58:48浏览次数:67  
标签:scanning dremio scan common 简单 com ClassPathScanner

ClassPathScanner 实际上是dremio 基于配置+约定的类扫描处理,为了性能同时使用了开源的reflections 工具包

约定

主要扫描包含以下约定key 的类或者包

 /** Configuration pathname to list of names of packages to scan for implementations. */
  private static final String IMPLEMENTATIONS_SCAN_PACKAGES = "dremio.classpath.scanning.packages";
 
  /** Configuration pathname to list of names of base classes to scan for implementations. */
  private static final String IMPLEMENTATIONS_SCAN_CLASSES = "dremio.classpath.scanning.base.classes";
 
  /** Configuration pathname to list of names of annotations to scan for. */
  private static final String IMPLEMENTATIONS_SCAN_ANNOTATIONS = "dremio.classpath.scanning.annotations";
 
  /** Configuration pathname to turn off build time caching. */
  private static final String IMPLEMENTATIONS_SCAN_CACHE = "dremio.classpath.scanning.cache.enabled";

配置

基于了typesafe.config ,参考配置文件sabot-module.conf

dremio {
  classpath.scanning {
 
    base.classes : ${?dremio.classpath.scanning.base.classes} [
      com.dremio.common.logical.data.LogicalOperator,
      com.dremio.common.logical.FormatPluginConfig,
      com.dremio.common.store.StoragePluginConfig,
      com.dremio.service.Initializer
    ],
 
    packages : ${?dremio.classpath.scanning.packages} [
      com.dremio.exec.store.mock,
      com.dremio.common.logical,
      com.dremio.exec.store.dfs,
      com.dremio.exec.server.options,
      com.dremio.plugins.mongo
    ]
  },
 
  memory: {
      debug.error_on_leak: true,
      top.max: 1000000000000
  }
}

参考使用

会返回一个ScanResult

public static ScanResult fromPrescan(SabotConfig config) {
    List<String> packagePrefixes = ClassPathScanner.getPackagePrefixes(config);
    List<String> scannedBaseClasses = ClassPathScanner.getScannedBaseClasses(config);
    List<String> scannedAnnotations = ClassPathScanner.getScannedAnnotations(config);
    if (ClassPathScanner.isScanBuildTimeCacheEnabled(config)) {
      // scan only locations that have not been scanned yet
      ScanResult runtimeScan = ClassPathScanner.scan(
          NON_PRESCANNED_MARKED_PATHS,
          packagePrefixes,
          scannedBaseClasses,
          scannedAnnotations,
          PRESCANNED);
      return runtimeScan.merge(PRESCANNED);
    } else {
      // scan everything
      return ClassPathScanner.scan(
          ClassPathScanner.getMarkedPaths(),
          packagePrefixes,
          scannedBaseClasses,
          scannedAnnotations,
          ClassPathScanner.emptyResult());
    }
  }

说明

dremio 对于插件的加载就使用了动态创建以及类扫描的处理,灵活性还是很不错的

参考资料

common/src/main/java/com/dremio/common/scanner/ClassPathScanner.java
common/src/main/java/com/dremio/common/config/SabotConfig.java
https://github.com/ronmamo/reflections

标签:scanning,dremio,scan,common,简单,com,ClassPathScanner
From: https://www.cnblogs.com/rongfengliang/p/17020603.html

相关文章

  • JavaScript 简单类型与复杂类型
    JavaScript简单类型与复杂类型目录JavaScript简单类型与复杂类型1.简单类型与复杂类型2.堆和栈3.简单类型的内存分配4.复杂类型的内存分配5.简单类型传参6.复杂类......
  • certbot简单使用
    ssl一直用的是阿里的免费证书,但是每年需要定时更换证书,而且数量上也有限制,这就很烦,我这么懒,别说一年一换,就是两年一换证书我都懒得打开后台~科普为了加快推广https的普......
  • 简单指针实现两个数比较大小
    我们要先知道指针变量的作用是储存你指定变量所在的地址。因为按照计算机规则你所定义的值会被电脑储存在一个位置,只要是位置就会有地址。#include<stdio.h>intmain(){in......
  • 数字三角形 —— java蓝桥杯(简单)
    题目描述上图给出了一个数字三角形。从三角形的顶部到底部有很多条不同的路径。对于每条路径,把路径上面的数加起来可以得到一个和,你的任务就是找到最大的和。路径上的每......
  • 使用awk和grep做简单的统计
    grep或egrep或awk过滤两个或多个关键词: grep-E‘123|abc’filename//找出文件(filename)中包含123或者包含abc的行 egrep‘123|abc’filename//用egrep同样可......
  • 简单谈谈我眼中的程序
    普通用户看来,程序就是他们能看到的用户界面,比如电脑里面装的软件,手机上装的app,浏览器能打开的网页。但是,这只是一个程序的一小部分。程序最重要的是数据,用户感知最强ui,在......
  • dremio formatPlugin 调用链
    格式化插件在dremio中是比较核心的,包含了不少格式化插件,了解格式化插件的执行可以更好的开发自己的扩展以及了解dremio的内部机制以下是基于arthas分析的一个调用链可......
  • mybatisplus简单了解
    mybatisplus是加强版mybatis,里面提供了更加简便强大的功能。springboot整合mybatisplus,这个mybatisplus的jar包需要手动添加,不在起步依赖里面。  然后整合完之后,再在......
  • 微信公众号简单开发(4)普通消息
    我们在接收微信普通消息的时候呀,我们会发现我们有很多种普通消息。微信官方的文档:​​​https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140453​​微信官......
  • 在线工具:简单修改网址解锁新世界
    整理了几个自己经常会用到的在线小工具,简单改动一下网址,得到自己最想要的答案。Pandownload网页版之前介绍过,百度网盘链接替换baidu为baiduwp即可获取高速下载链接。如:​......