dremio S3StoragePlugin 简单说明

S3StoragePlugin 核心是进行s3 的数据处理,从能力上来说主要是一个文件系统的存储插件,以前我简单介绍过关于存储扩展
的开发,一般需要包含一个存储插件配置类以及存储插件的实现(会有基于文件系统的s3,nas。。。。,基于底层基础类的jdbc 存储插件)

配置类

主要是S3PluginConfig 基于了AbstractS3PluginConfig 抽象类,配置类同时会进行存储插件的创建 (newPlugin 方法)同时s3 插件也是支持
类s3兼容的(compatibilityMode),会在存储插件中使用到(主要是S3FileSystem基于hdfs 的FileSystem 的实现,将s3 包装为一个文件系统), 详
细对于配置的使用是在文件系统存储的start 方法中(实现了标准的service 接口)

类图如下

 

 

存储插件实现

S3StoragePlugin 主要是实现FileSystemPlugin进行了部分方法的重写(getProperties,supportsColocatedReads,getState,createNewTable,isAsyncEnabledForQuery
),比较核心的实现是CreateTableEntry 方法
CreateTableEntry s3 实现处理

 
 public CreateTableEntry createNewTable(
    NamespaceKey tableSchemaPath, SchemaConfig config,
    IcebergTableProps icebergTableProps,
    WriterOptions writerOptions,
    Map<String, Object> storageOptions,
    boolean isResultsTable
  ) {
    Preconditions.checkArgument(tableSchemaPath.size() >= 2, "key must be at least two parts");
    final List<String> resolvedPath = resolveTableNameToValidPath(tableSchemaPath.getPathComponents()); // strips source name
    final String containerName = resolvedPath.get(0);
    // 进行了判断,s3 bucket 不能直接创建
    if (resolvedPath.size() == 1) {
      throw UserException.validationError()
        .message("Creating buckets is not supported (name: %s)", containerName)
        .build(logger);
    }
   //  实际还是调用FileSystemPlugin 提供的createNewTable 能力
    final CreateTableEntry entry = super.createNewTable(tableSchemaPath, config,
      icebergTableProps, writerOptions, storageOptions, isResultsTable);
 
    final S3FileSystem fs = getSystemUserFS().unwrap(S3FileSystem.class);
 
    if (!fs.containerExists(containerName)) {
      throw UserException.validationError()
          .message("Cannot create the table because '%s' bucket does not exist", containerName)
          .build(logger);
    }
 
    return entry;
  }

FileSystemPlugin 的 createNewTable 实现处理利用了FormatPlugin 、CreateParquetTableEntry、EasyFileSystemCreateTableEntry (同时对于iceberg 会有特定的处理
毕竟dremio 目前对于CTAS 的核心支持主要基于了iceberg)
参考类

 

 

使用

属于标准插件的使用,包含了UI部分(backen api),以及内部查询相关的(元数据,调度,执行。。。。)

参考资料

plugins/s3/src/main/java/com/dremio/plugins/s3/store/S3StoragePlugin.java
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/DirectorySupportLackingFileSystemPlugin.java
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/FileSystemConf.java
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/FileSystemPlugin.java
sabot/kernel/src/main/java/com/dremio/exec/catalog/conf/ConnectionConf.java
plugins/s3/src/main/java/com/dremio/plugins/s3/store/S3PluginConfig.java
plugins/s3/src/main/java/com/dremio/plugins/s3/store/AbstractS3PluginConfig.java
plugins/s3/src/main/java/com/dremio/plugins/s3/store/S3FileSystem.java
plugins/s3/src/main/java/com/dremio/plugins/util/ContainerFileSystem.java
services/namespace/src/main/java/com/dremio/service/namespace/AbstractConnectionConf.java
sabot/kernel/src/main/java/com/dremio/exec/catalog/MutablePlugin.java
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/CreateParquetTableEntry.java
sabot/kernel/src/main/java/com/dremio/exec/store/dfs/EasyFileSystemCreateTableEntry.java

posted on 2023-02-24 12:05  荣锋亮  阅读(39)  评论(0编辑  收藏  举报

导航