dremio mysql arp扩展
开发此阿尔普扩展的目的是增强德雷米奥对于类关系型数据库数据库的兼容(比如多丽丝海洋基地。暂时还没测试)
因为默认官方的是基于maridb的(对于类关系型数据库数据库兼容有点问题)
参考代码
核心是阿尔普配置调整了支持使用mysql jdbc,默认使用了maridb的数据源存在一些兼容问题
包裹。com。德米奥。执行董事。商店。JDBC。conf
进口。com。德米奥。执行董事。目录。糖膏剂*;
导入com。德米奥。执行董事。商店。JDBC。可关闭的数据源;
导入com。德米奥。执行董事。商店。JDBC。数据源;
导入com。德米奥。执行董事。商店。JDBC。jdbcplugin fig
导入com。德米奥。执行董事。商店。JDBC。jdbcplugin图生成器;
进口。com。德米奥。执行董事。商店。JDBC。质量。jdbcdremiosqldialect
进口。com。德米奥。执行董事。商店。JDBC。类黄酮。mymysql flavoice
导入com。德米奥。选项。期权经理;
导入com。德米奥。保安。credentiarservice
进口。com。fasterxml。杰克逊。注释。jsonignore
导入com。谷歌。常见。注释。可参观森林;
导入com。谷歌。常见。基地。偏好;
导入io。原型的东西。标签;
导入组织。slf4j。伐木工人;
导入组织。slf4j。伐木工人工厂;
导入javax。验证。约束。max
导入javax。验证。约束。分钟;
导入javax。验证。约束。不是空白;
导入Java。乌提尔。列表;
导入Java。乌提尔。属性;
导入Java。乌提尔。小溪。收藏家;
@SourceType(
value='MYMYSQL ',
标签='MYMYSQL ',
uiConfig = "my-mysql-layout.json",
externalQuerySupported = true
)
public class MyMySQLConf extends AbstractArpConfMyMySQLConf {
private static final Logger logger = LoggerFactory.getLogger(MyMySQLConf.class);
private static final String ARP_FILENAME = "arp/implementation/my-mysql-arp.yaml";
private static final MyMySQLDialect MYSQL_ARP_DIALECT = AbstractArpConf.loadArpFile(ARP_FILENAME, MyMySQLDialect::new);
private static final String MYSQLDRIVER = "com.mysql.jdbc.Driver";
@NotBlank
@Tag(1)
@DisplayMetadata(
label = "Host"
)
public String hostname;
@NotBlank
@Tag(2)
@Min(1L)
@Max(65535L)
@DisplayMetadata(
label = "Port"
)
public String port = "3306";
@Tag(4)
public String username;
@Tag(5)
@Secret
public String password;
@Tag(6)
public AuthenticationType authenticationType;
@Tag(7)
@DisplayMetadata(
label = "Record fetch size"
)
@NotMetadataImpacting
public int fetchSize = 200;
@Tag(8)
@DisplayMetadata(
label = "Net write timeout (in seconds)"
)
@NotMetadataImpacting
public int netWriteTimeout = 60;
@Tag(9)
@DisplayMetadata(
label = "Enable legacy dialect"
)
@JsonIgnore
public boolean useLegacyDialect = false;
@Tag(10)
@NotMetadataImpacting
@JsonIgnore
public boolean enableExternalQuery = false;
@Tag(11)
public ListProperty propertyList;
@Tag(12)
@DisplayMetadata(
label = "Maximum idle connections"
)
@NotMetadataImpacting
public int maxIdleConns = 8;
@Tag(13)
@DisplayMetadata(
label = "Connection idle time (s)"
)
@NotMetadataImpacting
public int idleTimeSec = 60;
@Tag(14)
@DisplayMetadata(
label = "Query timeout (s)"
)
@NotMetadataImpacting
public int queryTimeoutSec = 0;
@VisibleForTesting
CloseableDataSource newDataSource() {
Properties properties = new Properties();
properties.put("useJDBCCompliantTimezoneShift", "true");
properties.put("sessionVariables", String.format("net_write_timeout=%d", this.netWriteTimeout));
// 此处使用了newGenericConnectionPoolDataSource没有使用sharedatasource
return DataSources.newGenericConnectionPoolDataSource(MYSQLDRIVER, this.toJdbcConnectionString(), this.username, this.password, properties, DataSources.CommitMode.FORCE_MANUAL_COMMIT_MODE, this.maxIdleConns, (long)this.idleTimeSec);
}
@VisibleForTesting
String toJdbcConnectionString() {
String hostname = (String)Preconditions.checkNotNull(this.hostname, "missing hostname");
String portAsString = (String)Preconditions.checkNotNull(this.port, "missing port");
int port = Integer.parseInt(portAsString);
String url = String.format("jdbc:mysql://%s:%d", hostname, port);
logger.info("url:{}",url);
System.out.println("url"+url);
String connectUrl = null != this.propertyList !this.propertyList.isEmpty() url + (String)this.propertyList.stream().map((p) - {
return p.name + "=" + p.value;
}).collect(Collectors.joining("", "", "")) : url;
System.out.println("connectUrl"+url);
return connectUrl;
}
@Override
public JdbcDremioSqlDialect getDialect() {
return this.MYSQL_ARP_DIALECT;
}
@Override
public JdbcPluginConfig buildPluginConfig(Builder builder, CredentialsService credentialsService, OptionManager optionManager) {
return builder.withDialect(this.getDialect()).withDatasourceFactory(this::newDataSource).withShowOnlyConnDatabase(false).withFetchSize(this.fetchSize).withQueryTimeout(this.queryTimeoutSec).build();
}
}
说明,具体代码可以参考github
使用
构建,放jar 文件到dremio 的jar 目录,同时选择合适的mysql 驱动放到jars/3rdparty 推荐使用 mysql-connector-java-5.1.47 以及以上的
好处是可以支持oceanbase 。。。。
说明
相关构建好的jar 我也已经push github 了,可以直接使用
参考资料
https://github.com/rongfengliang/dremio-mysql-arp
https://open.oceanbase.com/docs/community/oceanbase-database/V3.1.0/java-database-connection-driver-jdbc-2
https://github.com/rongfengliang/dremio-oceanbase-learning
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/100420.html