0
点赞
收藏
分享

微信扫一扫

通过dremio git 提交学习dremio 插件开发以及测试

伽马星系 2022-11-03 阅读 140

主要是一个简单的说明,我们可以通过源码以及git 提交学习一些不错的关于dremio 开发相关的东西

一个参考插的开发

如下图

通过dremio git 提交学习dremio 插件开发以及测试_java

 

 

  • 插件开发
    从上图可以看出核心就是config以及存储插件,以及相关的配置,还有插件加载的配置(类扫描)
  • 插件测试 此测试类比较有意义,很多时间大家不爱测试,碰到问题就比较难解决了,此类就是一个不错的参考 参考测试类

public class AWSGlueStoragePluginTest extends BaseTestQuery {
插件注册

public static void addGlueTestPlugin(final String pluginName, final CatalogService pluginRegistry) throws Exception {
SourceConfig sc = new SourceConfig();
sc.setName(pluginName);
AWSGluePluginConfig conf = new AWSGluePluginConfig();
final List<Property> finalProperties = new ArrayList<>();
finalProperties.add(new Property("hive.imetastoreclient.factory.class",
"com.amazonaws.glue.catalog.metastore.MockAWSGlueDataCatalogHiveClientFactory"));

finalProperties.add(new Property("fs.s3a.bucket.qa1.dremio.com." +
"access.key", "test"));
finalProperties.add(new Property("fs.s3a.bucket.qa1.dremio.com.secret.key", "test"));
finalProperties.add(new Property("fs.s3a.bucket.qa1.dremio.com.aws.credentials.provider", "org.apache.hadoop.fs.s3a" +
".SimpleAWSCredentialsProvider"));
finalProperties.add(new Property("fs.s3a.bucket.qa1.dremio.com.endpoint", "localhost:"+port));
finalProperties.add(new Property("fs.s3a.bucket.qa1.dremio.com.path.style.access", "true"));
finalProperties.add(new Property("fs.s3a.bucket.qa1.dremio.com.connection.ssl.enabled", "false"));

File file = new File(
AWSGlueStoragePluginTest.class.getClassLoader().getResource("catalog_store.json").getFile()
);
String content = new String(Files.readAllBytes(file.toPath()));
finalProperties.add(new Property("awsglue.catalog.store.content", content));
conf.enableAsync = false;

conf.propertyList = finalProperties;
conf.accessKey = "test";
conf.accessSecret = "test";
sc.setType(conf.getType());
sc.setConfig(conf.toBytesString());
sc.setMetadataPolicy(CatalogService.DEFAULT_METADATA_POLICY);
// 注册插件
((CatalogServiceImpl) pluginRegistry).getSystemUserCatalog().createSource(sc);
}

 说明

通过官方的git 提交我们可以学到不少有意思的东西,可以更好的学习dremio,以上只是一个简单的说明,大家可以更好的发掘dremio 的价值

参考资料

​​https://github.com/dremio/dremio-oss/commit/07ab5d99b4fa14b77f12043f2640b1273f7886d5​​​
​​​https://github.com/dremio/dremio-oss/blob/07ab5d99b4fa14b77f12043f2640b1273f7886d5/sabot/kernel/src/main/java/com/dremio/exec/server/SabotContext.java​​

举报

相关推荐

0 条评论