首页 > 其他分享 >dremio SourceCatalog 服务说明

dremio SourceCatalog 服务说明

时间:2023-01-05 13:11:06浏览次数:35  
标签:dremio java getName 说明 source SourceCatalog attributes config

SourceCatalog 主要进行source 的管理,包含了获取信息,创建,更新,删除,包含了不同的实现

SourceCatalog 服务定义

/**
 * Interface to perform actions on sources.
 */
// PrivilegeCatalog 可以实现权限处理,具体实际上是SqlGrant 提供的能力
public interface SourceCatalog extends PrivilegeCatalog {
 
  SourceState refreshSourceStatus(NamespaceKey key) throws Exception;
 
  /**
   * Get a source based on the provided name. If the source doesn't exist, synchronize with the
   * KVStore to confirm creation status.
   *
   * @param name
   * @return A StoragePlugin casted to the expected output.
   */
  <T extends StoragePlugin> T getSource(String name);
 
  /**
   * Create a source based on the provided configuration. Includes both the creation as well the
   * startup of the source. If the source fails to start, no creation will be done. The provided
   * configuration should have a null version. Failure to create or failure to start with throw an
   * exception. Additionally, if "store.plugin.check_state" is enabled, a plugin that starts but
   * then reveals a bad state, will also result in exception.
   *
   * @param config Configuration for the source.
   * @param attributes Optional namespace attributes to pass to namespace entity creation
   */
  void createSource(SourceConfig config, NamespaceAttribute... attributes);
 
  /**
   * Update an existing source with the given config. The config version must be the same as the
   * currently active source. If it isn't, this call will fail with an exception.
   *
   * @param config Configuration for the source.
   * @param attributes Optional namespace attributes to pass to namespace entity creation
   */
  void updateSource(SourceConfig config, NamespaceAttribute... attributes);
 
  /**
   * Delete a source with the provided config. If the source doesn't exist or the config doesn't
   * match, the method with throw an exception.
   *
   * @param config
   */
  void deleteSource(SourceConfig config);
}

实现子类

参考下图,还是比较复杂的,实际实现是CatalogImpl,内部会调用CatalogServiceImpl

创建source创建处理

参考处理

private void createSource(SourceConfig config, CatalogIdentity subject, NamespaceAttribute... attributes) {
    boolean afterUnknownEx = false;
 
    try(final AutoCloseable sourceDistributedLock = getDistributedLock(config.getName())) {
      logger.debug("Obtained distributed lock for source {}", "-source-"+config.getName());
      setInfluxSource(config.getName());
      // 通过 PluginsManager 插件管理进行实际source 的创建
      getPlugins().create(config, subject.getName(), attributes);
      communicateChange(config, RpcType.REQ_SOURCE_CONFIG);
    } catch (SourceAlreadyExistsException e) {
      throw UserException.concurrentModificationError(e).message("Source already exists with name %s.", config.getName()).buildSilently();
    } catch (ConcurrentModificationException ex) {
      throw ex;
    } catch (UserException ue) {
      // If it's a UserException, message is probably helpful, so rethrow
      throw ue;
    } catch (IllegalArgumentException e) {
      throw e;
    } catch (Exception ex) {
      afterUnknownEx = true;
      logger.error("Exception encountered: {}", ex.getMessage(), ex);
      throw UserException.validationError(ex).message("Failed to create source with name %s.", config.getName()).buildSilently();
    } finally {
      logger.debug("Releasing distributed lock for source {}", "-source-"+config.getName());
      removeInfluxSource(config.getName(), afterUnknownEx);
    }
  }
PluginsManager start 部分会对于注册插件的获取基于了NamespaceService.Factory
```code
   ImmutableMap.Builder<String, CompletableFuture<SourceState>> futuresBuilder = ImmutableMap.builder();
    // 此处获取已经注册的插件,转化为dremio 托管的存储插件
    for (SourceConfig source : datasetListing.getSources(SystemUser.SYSTEM_USERNAME)) {
      ManagedStoragePlugin plugin = newPlugin(source);
 
      futuresBuilder.put(source.getName(), plugin.startAsync());
      plugins.put(c(source.getName()), plugin);
    }

ConnectionReader 进行插件信息获取

ConnectionReaderImpl 中,方便页面加载
参考处理

 
protected static Collection<Class<? extends ConnectionConf<?, ?>>> getCandidateSources(ScanResult scanResult) {
    ImmutableList.Builder<Class<? extends ConnectionConf<?, ?>>> candidates = new ImmutableList.Builder<>();
    for(Class<?> input : scanResult.getAnnotatedClasses(SourceType.class)) {
      try {
        if (Modifier.isAbstract(input.getModifiers())
          || Modifier.isInterface(input.getModifiers())
          || !ConnectionConf.class.isAssignableFrom(input)) {
          logger.warn("Failure trying to recognize SourceConf for {}. Expected a concrete implementation of SourceConf.", input.getName());
          continue;
        }
      } catch (Exception e) {
        logger.warn("Failure trying to recognize SourceConf for {}", input.getName(), e);
        continue;
      }
      // Check done just above
      candidates.add((Class<? extends ConnectionConf<?, ?>>) input);
    }
    return candidates.build();
  }

说明

source 类型,主要面向的是可以界面可见的存储扩展处理,实际上dremio 还包含了不少内置的存储扩展,系统存储扩展(比如加速,home)
同时通过阅读我们发现官方还是提供了一个PrivilegeCatalog 支持权限能力的扩展的,自己扩展下就可以实现一些企业版的特性了

参考资料

sabot/kernel/src/main/java/com/dremio/exec/catalog/SourceCatalog.java
sabot/kernel/src/main/java/com/dremio/exec/planner/sql/parser/SqlGrant.java
dac/backend/src/main/java/com/dremio/dac/api/SourceResource.java
sabot/kernel/src/main/java/com/dremio/exec/catalog/ConnectionReader.java
sabot/kernel/src/main/java/com/dremio/exec/catalog/ConnectionReaderImpl.java

标签:dremio,java,getName,说明,source,SourceCatalog,attributes,config
From: https://www.cnblogs.com/rongfengliang/p/17027259.html

相关文章

  • Unity3D常用函数说明
    Unity3D中所有控制脚本的基类MonoBehaviour有一些虚函数用于绘制中事件的回调,也可以直接理解为事件函数,例如大家都很清楚的Start,Update等函数,以下做个总结。 Awake当前控......
  • 可迭代对象以及迭代器的说明
    可迭代对象通过iter(),转化为迭代器对象,迭代器可以使用next()访问,可迭代对象不能直接使用next();迭代器是一个可以记住遍历的位置的对象,所以可以方便的使用next()。可迭......
  • nVisual各项隐藏项配置说明
    nVisual可以部署在不同的项目中,但是每个项目都有自己不同的使用场景,有的不需要报表功能,有的不需要监测功能,还有的不需要连接外网的功能等。针对这些不同的需求,有必要且有可......
  • dremio DatasetSaver 服务说明
    我以前简单写过关于元数据处理的说明(基于jprofiler+arthas工具)会依赖namespace服务实际对于数据的操作都是通过SourceMetadataManager执行的DatasetSaver服务提供的......
  • KS进行定制化安装,ks脚本说明
    在/var/lib/cobbler/kickstarts/目录下会生成sample_end.ks文件,这个文件就是安装系统时的默认配置文件,我们可以进行修改,来完成自己的个性化配置,配置文件详解如下关键字......
  • DSP+ZYNQ硬件说明手册【XQTyer】
    【开源资料】XQTyer硬件说明手册.pdf链接:https://share.weiyun.com/7TufhN89密码:2f4mvy    XQ6657Z35/45-EVM(XQTyer评估板)是一款基于TIKeyStone架构C6000......
  • EasyAR4.0使用说明(五)----3D物体跟踪
    3D物体跟踪总体上是和平面图像跟踪差不多的,设置,包括程序控制,识别多个对象。区别只是目标对象的不同。总体说明3D物体跟踪对3D物体的纹理,也就是表面的图案的丰富程度是有要求......
  • Ansible when: result.stdout.find使用说明【原创】
    0代表成功,-1代表失败when:result.stdout.find('JAVA_HOME')==-1当文件中没有JAVA_HOME关键字时执行,等于失败才执行,结果没有JAVA_HOME关键字时执行when:result.stdout.......
  • 《Unity3D平台AR开发快速上手--基于EasyAR4.0》随书资源和相关说明
    新手《Unity3D平台AR开发快速上手–基于EasyAR4.0》上市了,现在京东和淘宝都有卖。书分为2个部分,第一部分是EasyAR4.0基础内容和使用,第二部分是利用EasyAR的稀疏空间地图做室......
  • 《Unity2018AR与VR开发快速上手》随书内容资源相关说明
    我的第二本书,《Unity2018AR与VR开发快速上手》终于上市了,现在天猫和京东都有卖。随书资源的百度盘链接被关闭了,只给了个“此链接分享内容可能因为涉及侵权、色情、反动、低......