Browse Source
* [feature-6071][plugin] add datasource plugin. (#6071) * remove the dependency of datasource in common and task-plugin module. * the new datasource-api module provides data source connection acquisition. * add sqlserver data source plug-in. * add ds license * fix check style * update spi pom * frx conflict resolution * fix check style * fix datasource ut * fix code check style * fix code check style * fix datasource ut * add pg hive mysql oracle clickhouse db2 datasource * fix datasource package * update datasource pom * update datasource pom * update datasource pom * update datasource pom * update pom * update pom dep * update pom dep * fix license * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * fix ut * add oracle package * modify comments * conflict resolution * rename log comment * rename log comment3.0.0/version-upgrade
mask
3 years ago
committed by
GitHub
189 changed files with 4648 additions and 3258 deletions
@ -1,98 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude; |
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include; |
|
||||||
|
|
||||||
/** |
|
||||||
* The base model of connection param |
|
||||||
* <p> |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.clickhouse.ClickhouseConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.db2.Db2ConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.hive.HiveConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.mysql.MysqlConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.oracle.OracleConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.postgresql.PostgreSqlConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.presto.PrestoConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.spark.SparkConnectionParam} |
|
||||||
* {@link org.apache.dolphinscheduler.common.datasource.sqlserver.SqlServerConnectionParam} |
|
||||||
*/ |
|
||||||
@JsonInclude(Include.NON_NULL) |
|
||||||
public abstract class BaseConnectionParam implements ConnectionParam { |
|
||||||
|
|
||||||
protected String user; |
|
||||||
|
|
||||||
protected String password; |
|
||||||
|
|
||||||
protected String address; |
|
||||||
|
|
||||||
protected String database; |
|
||||||
|
|
||||||
protected String jdbcUrl; |
|
||||||
|
|
||||||
protected String other; |
|
||||||
|
|
||||||
public String getUser() { |
|
||||||
return user; |
|
||||||
} |
|
||||||
|
|
||||||
public void setUser(String user) { |
|
||||||
this.user = user; |
|
||||||
} |
|
||||||
|
|
||||||
public String getPassword() { |
|
||||||
return password; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPassword(String password) { |
|
||||||
this.password = password; |
|
||||||
} |
|
||||||
|
|
||||||
public String getAddress() { |
|
||||||
return address; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAddress(String address) { |
|
||||||
this.address = address; |
|
||||||
} |
|
||||||
|
|
||||||
public String getDatabase() { |
|
||||||
return database; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDatabase(String database) { |
|
||||||
this.database = database; |
|
||||||
} |
|
||||||
|
|
||||||
public String getJdbcUrl() { |
|
||||||
return jdbcUrl; |
|
||||||
} |
|
||||||
|
|
||||||
public void setJdbcUrl(String jdbcUrl) { |
|
||||||
this.jdbcUrl = jdbcUrl; |
|
||||||
} |
|
||||||
|
|
||||||
public String getOther() { |
|
||||||
return other; |
|
||||||
} |
|
||||||
|
|
||||||
public void setOther(String other) { |
|
||||||
this.other = other; |
|
||||||
} |
|
||||||
} |
|
@ -1,57 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource; |
|
||||||
|
|
||||||
public class BaseHdfsConnectionParam extends BaseConnectionParam { |
|
||||||
protected String principal; |
|
||||||
protected String javaSecurityKrb5Conf; |
|
||||||
protected String loginUserKeytabUsername; |
|
||||||
protected String loginUserKeytabPath; |
|
||||||
|
|
||||||
public String getPrincipal() { |
|
||||||
return principal; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPrincipal(String principal) { |
|
||||||
this.principal = principal; |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaSecurityKrb5Conf() { |
|
||||||
return javaSecurityKrb5Conf; |
|
||||||
} |
|
||||||
|
|
||||||
public void setJavaSecurityKrb5Conf(String javaSecurityKrb5Conf) { |
|
||||||
this.javaSecurityKrb5Conf = javaSecurityKrb5Conf; |
|
||||||
} |
|
||||||
|
|
||||||
public String getLoginUserKeytabUsername() { |
|
||||||
return loginUserKeytabUsername; |
|
||||||
} |
|
||||||
|
|
||||||
public void setLoginUserKeytabUsername(String loginUserKeytabUsername) { |
|
||||||
this.loginUserKeytabUsername = loginUserKeytabUsername; |
|
||||||
} |
|
||||||
|
|
||||||
public String getLoginUserKeytabPath() { |
|
||||||
return loginUserKeytabPath; |
|
||||||
} |
|
||||||
|
|
||||||
public void setLoginUserKeytabPath(String loginUserKeytabPath) { |
|
||||||
this.loginUserKeytabPath = loginUserKeytabPath; |
|
||||||
} |
|
||||||
} |
|
@ -1,61 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource; |
|
||||||
|
|
||||||
public abstract class BaseHdfsDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
protected String principal; |
|
||||||
|
|
||||||
protected String javaSecurityKrb5Conf; |
|
||||||
|
|
||||||
protected String loginUserKeytabUsername; |
|
||||||
|
|
||||||
protected String loginUserKeytabPath; |
|
||||||
|
|
||||||
public String getPrincipal() { |
|
||||||
return principal; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPrincipal(String principal) { |
|
||||||
this.principal = principal; |
|
||||||
} |
|
||||||
|
|
||||||
public String getLoginUserKeytabUsername() { |
|
||||||
return loginUserKeytabUsername; |
|
||||||
} |
|
||||||
|
|
||||||
public void setLoginUserKeytabUsername(String loginUserKeytabUsername) { |
|
||||||
this.loginUserKeytabUsername = loginUserKeytabUsername; |
|
||||||
} |
|
||||||
|
|
||||||
public String getLoginUserKeytabPath() { |
|
||||||
return loginUserKeytabPath; |
|
||||||
} |
|
||||||
|
|
||||||
public void setLoginUserKeytabPath(String loginUserKeytabPath) { |
|
||||||
this.loginUserKeytabPath = loginUserKeytabPath; |
|
||||||
} |
|
||||||
|
|
||||||
public String getJavaSecurityKrb5Conf() { |
|
||||||
return javaSecurityKrb5Conf; |
|
||||||
} |
|
||||||
|
|
||||||
public void setJavaSecurityKrb5Conf(String javaSecurityKrb5Conf) { |
|
||||||
this.javaSecurityKrb5Conf = javaSecurityKrb5Conf; |
|
||||||
} |
|
||||||
} |
|
@ -1,81 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
import java.sql.Connection; |
|
||||||
import java.sql.SQLException; |
|
||||||
|
|
||||||
public interface DatasourceProcessor { |
|
||||||
|
|
||||||
/** |
|
||||||
* check datasource param is valid |
|
||||||
*/ |
|
||||||
void checkDatasourceParam(BaseDataSourceParamDTO datasourceParam); |
|
||||||
|
|
||||||
/** |
|
||||||
* create BaseDataSourceParamDTO by connectionJson |
|
||||||
* |
|
||||||
* @param connectionJson see{@link org.apache.dolphinscheduler.dao.entity.Datasource} |
|
||||||
* @return {@link BaseDataSourceParamDTO} |
|
||||||
*/ |
|
||||||
BaseDataSourceParamDTO createDatasourceParamDTO(String connectionJson); |
|
||||||
|
|
||||||
/** |
|
||||||
* create datasource connection parameter which will be stored at DataSource |
|
||||||
* <p> |
|
||||||
* see {@code org.apache.dolphinscheduler.dao.entity.DataSource.connectionParams} |
|
||||||
*/ |
|
||||||
ConnectionParam createConnectionParams(BaseDataSourceParamDTO datasourceParam); |
|
||||||
|
|
||||||
/** |
|
||||||
* deserialize json to datasource connection param |
|
||||||
* |
|
||||||
* @param connectionJson {@code org.apache.dolphinscheduler.dao.entity.DataSource.connectionParams} |
|
||||||
* @return {@link BaseConnectionParam} |
|
||||||
*/ |
|
||||||
ConnectionParam createConnectionParams(String connectionJson); |
|
||||||
|
|
||||||
/** |
|
||||||
* get datasource Driver |
|
||||||
*/ |
|
||||||
String getDatasourceDriver(); |
|
||||||
|
|
||||||
/** |
|
||||||
* get jdbcUrl by connection param, the jdbcUrl is different with ConnectionParam.jdbcUrl, this method will inject |
|
||||||
* other to jdbcUrl |
|
||||||
* |
|
||||||
* @param connectionParam connection param |
|
||||||
*/ |
|
||||||
String getJdbcUrl(ConnectionParam connectionParam); |
|
||||||
|
|
||||||
/** |
|
||||||
* get connection by connectionParam |
|
||||||
* |
|
||||||
* @param connectionParam connectionParam |
|
||||||
* @return {@link Connection} |
|
||||||
*/ |
|
||||||
Connection getConnection(ConnectionParam connectionParam) throws ClassNotFoundException, SQLException, IOException; |
|
||||||
|
|
||||||
/** |
|
||||||
* @return {@link DbType} |
|
||||||
*/ |
|
||||||
DbType getDbType(); |
|
||||||
} |
|
@ -1,41 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.clickhouse; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class ClickHouseDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "ClickHouseDatasourceParamDTO{" |
|
||||||
+ "host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.CLICKHOUSE; |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.db2; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class Db2DatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "Db2DatasourceParamDTO{" |
|
||||||
+ "name='" + name + '\'' |
|
||||||
+ ", note='" + note + '\'' |
|
||||||
+ ", host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.DB2; |
|
||||||
} |
|
||||||
} |
|
@ -1,38 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.hive; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseHdfsConnectionParam; |
|
||||||
|
|
||||||
public class HiveConnectionParam extends BaseHdfsConnectionParam { |
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "HiveConnectionParam{" |
|
||||||
+ "user='" + user + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", address='" + address + '\'' |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", jdbcUrl='" + jdbcUrl + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ ", principal='" + principal + '\'' |
|
||||||
+ ", javaSecurityKrb5Conf='" + javaSecurityKrb5Conf + '\'' |
|
||||||
+ ", loginUserKeytabUsername='" + loginUserKeytabUsername + '\'' |
|
||||||
+ ", loginUserKeytabPath='" + loginUserKeytabPath + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
} |
|
@ -1,45 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.hive; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseHdfsDatasourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class HiveDataSourceParamDTO extends BaseHdfsDatasourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "HiveDataSourceParamDTO{" |
|
||||||
+ "host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", principal='" + principal + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ ", javaSecurityKrb5Conf='" + javaSecurityKrb5Conf + '\'' |
|
||||||
+ ", loginUserKeytabUsername='" + loginUserKeytabUsername + '\'' |
|
||||||
+ ", loginUserKeytabPath='" + loginUserKeytabPath + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.HIVE; |
|
||||||
} |
|
||||||
} |
|
@ -1,34 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.mysql; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseConnectionParam; |
|
||||||
|
|
||||||
public class MysqlConnectionParam extends BaseConnectionParam { |
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "MysqlConnectionParam{" |
|
||||||
+ "user='" + user + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", address='" + address + '\'' |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", jdbcUrl='" + jdbcUrl + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.mysql; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class MysqlDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "MysqlDatasourceParamDTO{" |
|
||||||
+ "name='" + name + '\'' |
|
||||||
+ ", note='" + note + '\'' |
|
||||||
+ ", host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.MYSQL; |
|
||||||
} |
|
||||||
} |
|
@ -1,46 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.oracle; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseConnectionParam; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbConnectType; |
|
||||||
|
|
||||||
public class OracleConnectionParam extends BaseConnectionParam { |
|
||||||
protected DbConnectType connectType; |
|
||||||
|
|
||||||
public DbConnectType getConnectType() { |
|
||||||
return connectType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setConnectType(DbConnectType connectType) { |
|
||||||
this.connectType = connectType; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "OracleConnectionParam{" |
|
||||||
+ "user='" + user + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", address='" + address + '\'' |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", jdbcUrl='" + jdbcUrl + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ ", connectType=" + connectType |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
} |
|
@ -1,55 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.oracle; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbConnectType; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class OracleDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
private DbConnectType connectType; |
|
||||||
|
|
||||||
public DbConnectType getConnectType() { |
|
||||||
return connectType; |
|
||||||
} |
|
||||||
|
|
||||||
public void setConnectType(DbConnectType connectType) { |
|
||||||
this.connectType = connectType; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "OracleDatasourceParamDTO{" |
|
||||||
+ "name='" + name + '\'' |
|
||||||
+ ", note='" + note + '\'' |
|
||||||
+ ", host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", connectType=" + connectType |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.ORACLE; |
|
||||||
} |
|
||||||
} |
|
@ -1,41 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.postgresql; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class PostgreSqlDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "PostgreSqlDatasourceParamDTO{" |
|
||||||
+ "host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.POSTGRESQL; |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.presto; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class PrestoDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "PrestoDatasourceParamDTO{" |
|
||||||
+ "name='" + name + '\'' |
|
||||||
+ ", note='" + note + '\'' |
|
||||||
+ ", host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.PRESTO; |
|
||||||
} |
|
||||||
} |
|
@ -1,38 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.spark; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseHdfsConnectionParam; |
|
||||||
|
|
||||||
public class SparkConnectionParam extends BaseHdfsConnectionParam { |
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "SparkConnectionParam{" |
|
||||||
+ "user='" + user + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", address='" + address + '\'' |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", jdbcUrl='" + jdbcUrl + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ ", principal='" + principal + '\'' |
|
||||||
+ ", javaSecurityKrb5Conf='" + javaSecurityKrb5Conf + '\'' |
|
||||||
+ ", loginUserKeytabUsername='" + loginUserKeytabUsername + '\'' |
|
||||||
+ ", loginUserKeytabPath='" + loginUserKeytabPath + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
} |
|
@ -1,45 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.spark; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseHdfsDatasourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class SparkDatasourceParamDTO extends BaseHdfsDatasourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "SparkDatasourceParamDTO{" |
|
||||||
+ "host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", principal='" + principal + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ ", javaSecurityKrb5Conf='" + javaSecurityKrb5Conf + '\'' |
|
||||||
+ ", loginUserKeytabUsername='" + loginUserKeytabUsername + '\'' |
|
||||||
+ ", loginUserKeytabPath='" + loginUserKeytabPath + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.SPARK; |
|
||||||
} |
|
||||||
} |
|
@ -1,43 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.datasource.sqlserver; |
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.datasource.BaseDataSourceParamDTO; |
|
||||||
import org.apache.dolphinscheduler.common.enums.DbType; |
|
||||||
|
|
||||||
public class SqlServerDatasourceParamDTO extends BaseDataSourceParamDTO { |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return "SqlServerDatasourceParamDTO{" |
|
||||||
+ "name='" + name + '\'' |
|
||||||
+ ", note='" + note + '\'' |
|
||||||
+ ", host='" + host + '\'' |
|
||||||
+ ", port=" + port |
|
||||||
+ ", database='" + database + '\'' |
|
||||||
+ ", userName='" + userName + '\'' |
|
||||||
+ ", password='" + password + '\'' |
|
||||||
+ ", other='" + other + '\'' |
|
||||||
+ '}'; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public DbType getType() { |
|
||||||
return DbType.SQLSERVER; |
|
||||||
} |
|
||||||
} |
|
@ -1,60 +0,0 @@ |
|||||||
/* |
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
||||||
* contributor license agreements. See the NOTICE file distributed with |
|
||||||
* this work for additional information regarding copyright ownership. |
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
||||||
* (the "License"); you may not use this file except in compliance with |
|
||||||
* the License. You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.common.enums; |
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toMap; |
|
||||||
|
|
||||||
import java.util.Arrays; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.EnumValue; |
|
||||||
import com.google.common.base.Functions; |
|
||||||
|
|
||||||
public enum DbType { |
|
||||||
MYSQL(0), |
|
||||||
POSTGRESQL(1), |
|
||||||
HIVE(2), |
|
||||||
SPARK(3), |
|
||||||
CLICKHOUSE(4), |
|
||||||
ORACLE(5), |
|
||||||
SQLSERVER(6), |
|
||||||
DB2(7), |
|
||||||
PRESTO(8), |
|
||||||
H2(9); |
|
||||||
|
|
||||||
DbType(int code) { |
|
||||||
this.code = code; |
|
||||||
} |
|
||||||
|
|
||||||
@EnumValue |
|
||||||
private final int code; |
|
||||||
|
|
||||||
public int getCode() { |
|
||||||
return code; |
|
||||||
} |
|
||||||
|
|
||||||
private static final Map<Integer, DbType> DB_TYPE_MAP = |
|
||||||
Arrays.stream(DbType.values()).collect(toMap(DbType::getCode, Functions.identity())); |
|
||||||
|
|
||||||
public static DbType of(int type) { |
|
||||||
if (DB_TYPE_MAP.containsKey(type)) { |
|
||||||
return DB_TYPE_MAP.get(type); |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,177 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- |
||||||
|
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
~ contributor license agreements. See the NOTICE file distributed with |
||||||
|
~ this work for additional information regarding copyright ownership. |
||||||
|
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
~ (the "License"); you may not use this file except in compliance with |
||||||
|
~ the License. You may obtain a copy of the License at |
||||||
|
~ |
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
~ |
||||||
|
~ Unless required by applicable law or agreed to in writing, software |
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
~ See the License for the specific language governing permissions and |
||||||
|
~ limitations under the License. |
||||||
|
--> |
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<parent> |
||||||
|
<artifactId>dolphinscheduler-datasource-plugin</artifactId> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<version>2.0.0-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-datasource-api</artifactId> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-spi</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>commons-io</groupId> |
||||||
|
<artifactId>commons-io</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.slf4j</groupId> |
||||||
|
<artifactId>slf4j-api</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>com.google.guava</groupId> |
||||||
|
<artifactId>guava</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>commons-codec</groupId> |
||||||
|
<artifactId>commons-codec</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.commons</groupId> |
||||||
|
<artifactId>commons-collections4</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>com.github.oshi</groupId> |
||||||
|
<artifactId>oshi-core</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>com.alibaba</groupId> |
||||||
|
<artifactId>druid</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework</groupId> |
||||||
|
<artifactId>spring-jdbc</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.hadoop</groupId> |
||||||
|
<artifactId>hadoop-client</artifactId> |
||||||
|
<exclusions> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.slf4j</groupId> |
||||||
|
<artifactId>slf4j-log4j12</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<artifactId>servlet-api</artifactId> |
||||||
|
<groupId>javax.servlet</groupId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.codehaus.jackson</groupId> |
||||||
|
<artifactId>jackson-jaxrs</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.codehaus.jackson</groupId> |
||||||
|
<artifactId>jackson-xc</artifactId> |
||||||
|
</exclusion> |
||||||
|
|
||||||
|
<exclusion> |
||||||
|
<groupId>org.fusesource.leveldbjni</groupId> |
||||||
|
<artifactId>leveldbjni-all</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.apache.zookeeper</groupId> |
||||||
|
<artifactId>zookeeper</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.apache.hadoop</groupId> |
||||||
|
<artifactId>hadoop-mapreduce-client-shuffle</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<artifactId>jersey-client</artifactId> |
||||||
|
<groupId>com.sun.jersey</groupId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<artifactId>jersey-core</artifactId> |
||||||
|
<groupId>com.sun.jersey</groupId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<artifactId>jaxb-api</artifactId> |
||||||
|
<groupId>javax.xml.bind</groupId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<artifactId>log4j</artifactId> |
||||||
|
<groupId>log4j</groupId> |
||||||
|
</exclusion> |
||||||
|
</exclusions> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>junit</groupId> |
||||||
|
<artifactId>junit</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-core</artifactId> |
||||||
|
<type>jar</type> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.powermock</groupId> |
||||||
|
<artifactId>powermock-module-junit4</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.powermock</groupId> |
||||||
|
<artifactId>powermock-api-mockito2</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
<exclusions> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-core</artifactId> |
||||||
|
</exclusion> |
||||||
|
</exclusions> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.jacoco</groupId> |
||||||
|
<artifactId>org.jacoco.agent</artifactId> |
||||||
|
<classifier>runtime</classifier> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<finalName>dolphinscheduler-datasource-api-${project.version}</finalName> |
||||||
|
</build> |
||||||
|
</project> |
@ -0,0 +1,129 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.client; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.provider.JdbcDataSourceProvider; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceClient; |
||||||
|
import org.apache.dolphinscheduler.spi.exception.PluginException; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.StringUtils; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
import java.sql.SQLException; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource; |
||||||
|
import com.google.common.base.Stopwatch; |
||||||
|
|
||||||
|
public class CommonDataSourceClient implements DataSourceClient { |
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(CommonDataSourceClient.class); |
||||||
|
|
||||||
|
public static final String COMMON_USER = "root"; |
||||||
|
public static final String COMMON_PASSWORD = "123456"; |
||||||
|
public static final String COMMON_VALIDATION_QUERY = "select 1"; |
||||||
|
|
||||||
|
protected final BaseConnectionParam baseConnectionParam; |
||||||
|
protected DruidDataSource druidDataSource; |
||||||
|
protected JdbcTemplate jdbcTemplate; |
||||||
|
|
||||||
|
public CommonDataSourceClient(BaseConnectionParam baseConnectionParam) { |
||||||
|
this.baseConnectionParam = baseConnectionParam; |
||||||
|
preInit(); |
||||||
|
checkEnv(baseConnectionParam); |
||||||
|
initClient(baseConnectionParam); |
||||||
|
checkClient(); |
||||||
|
} |
||||||
|
|
||||||
|
protected void preInit() { |
||||||
|
logger.info("preInit in CommonDataSourceClient"); |
||||||
|
} |
||||||
|
|
||||||
|
protected void checkEnv(BaseConnectionParam baseConnectionParam) { |
||||||
|
checkValidationQuery(baseConnectionParam); |
||||||
|
checkUser(baseConnectionParam); |
||||||
|
} |
||||||
|
|
||||||
|
protected void initClient(BaseConnectionParam baseConnectionParam) { |
||||||
|
this.druidDataSource = JdbcDataSourceProvider.createJdbcDataSource(baseConnectionParam); |
||||||
|
this.jdbcTemplate = new JdbcTemplate(druidDataSource); |
||||||
|
} |
||||||
|
|
||||||
|
protected void checkUser(BaseConnectionParam baseConnectionParam) { |
||||||
|
if (StringUtils.isBlank(baseConnectionParam.getUser())) { |
||||||
|
setDefaultUsername(baseConnectionParam); |
||||||
|
} |
||||||
|
if (StringUtils.isBlank(baseConnectionParam.getPassword())) { |
||||||
|
setDefaultPassword(baseConnectionParam); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected void setDefaultUsername(BaseConnectionParam baseConnectionParam) { |
||||||
|
baseConnectionParam.setUser(COMMON_USER); |
||||||
|
} |
||||||
|
|
||||||
|
protected void setDefaultPassword(BaseConnectionParam baseConnectionParam) { |
||||||
|
baseConnectionParam.setPassword(COMMON_PASSWORD); |
||||||
|
} |
||||||
|
|
||||||
|
protected void checkValidationQuery(BaseConnectionParam baseConnectionParam) { |
||||||
|
if (StringUtils.isBlank(baseConnectionParam.getValidationQuery())) { |
||||||
|
setDefaultValidationQuery(baseConnectionParam); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected void setDefaultValidationQuery(BaseConnectionParam baseConnectionParam) { |
||||||
|
baseConnectionParam.setValidationQuery(COMMON_VALIDATION_QUERY); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void checkClient() { |
||||||
|
//Checking data source client
|
||||||
|
Stopwatch stopwatch = Stopwatch.createStarted(); |
||||||
|
try { |
||||||
|
this.jdbcTemplate.execute(this.baseConnectionParam.getValidationQuery()); |
||||||
|
} catch (Exception e) { |
||||||
|
throw PluginException.getInstance("JDBC connect failed", e); |
||||||
|
} finally { |
||||||
|
logger.info("Time to execute check jdbc client with sql {} for {} ms ", this.baseConnectionParam.getValidationQuery(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Connection getConnection() { |
||||||
|
try { |
||||||
|
return this.druidDataSource.getConnection(); |
||||||
|
} catch (SQLException e) { |
||||||
|
logger.error("get druidDataSource Connection fail SQLException: {}", e.getMessage(), e); |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void close() { |
||||||
|
logger.info("do close dataSource."); |
||||||
|
this.druidDataSource.close(); |
||||||
|
this.druidDataSource = null; |
||||||
|
this.jdbcTemplate = null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/BaseHdfsConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseHdfsConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/BaseHdfsConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseHdfsConnectionParam.java
2
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/BaseHdfsDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseHdfsDatasourceParamDTO.java
2
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/BaseHdfsDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseHdfsDatasourceParamDTO.java
14
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/DatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/DatasourceProcessor.java
14
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/DatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/DatasourceProcessor.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/clickhouse/ClickHouseDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickHouseDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/clickhouse/ClickHouseDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickHouseDatasourceParamDTO.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/clickhouse/ClickHouseDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickHouseDatasourceProcessor.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/clickhouse/ClickHouseDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickHouseDatasourceProcessor.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/clickhouse/ClickhouseConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickhouseConnectionParam.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/clickhouse/ClickhouseConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickhouseConnectionParam.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/db2/Db2ConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/db2/Db2ConnectionParam.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/db2/Db2ConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/db2/Db2ConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/db2/Db2DatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/db2/Db2DatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/db2/Db2DatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/db2/Db2DatasourceParamDTO.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/hive/HiveConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveConnectionParam.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/hive/HiveConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/hive/HiveDataSourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDataSourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/hive/HiveDataSourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDataSourceParamDTO.java
8
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/mysql/MysqlConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlConnectionParam.java
8
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/mysql/MysqlConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/mysql/MysqlDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/mysql/MysqlDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceParamDTO.java
34
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/mysql/MysqlDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessor.java
34
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/mysql/MysqlDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessor.java
8
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/oracle/OracleConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleConnectionParam.java
8
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/oracle/OracleConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/oracle/OracleDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/oracle/OracleDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleDatasourceParamDTO.java
34
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/oracle/OracleDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleDatasourceProcessor.java
34
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/oracle/OracleDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleDatasourceProcessor.java
7
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/postgresql/PostgreSqlConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlConnectionParam.java
7
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/postgresql/PostgreSqlConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/postgresql/PostgreSqlDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/postgresql/PostgreSqlDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlDatasourceParamDTO.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/postgresql/PostgreSqlDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlDatasourceProcessor.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/postgresql/PostgreSqlDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlDatasourceProcessor.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/presto/PrestoDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/presto/PrestoDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/presto/PrestoDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/presto/PrestoDatasourceParamDTO.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/presto/PrestoDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/presto/PrestoDatasourceProcessor.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/presto/PrestoDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/presto/PrestoDatasourceProcessor.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/spark/SparkConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkConnectionParam.java
7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/spark/SparkConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/spark/SparkDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/spark/SparkDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkDatasourceParamDTO.java
36
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/spark/SparkDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkDatasourceProcessor.java
36
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/spark/SparkDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkDatasourceProcessor.java
7
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/sqlserver/SqlServerConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerConnectionParam.java
7
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/sqlserver/SqlServerConnectionParam.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerConnectionParam.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/sqlserver/SqlServerDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerDatasourceParamDTO.java
4
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/datasource/sqlserver/SqlServerDatasourceParamDTO.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerDatasourceParamDTO.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/sqlserver/SqlServerDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerDatasourceProcessor.java
30
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/datasource/sqlserver/SqlServerDatasourceProcessor.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerDatasourceProcessor.java
@ -0,0 +1,105 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.plugin; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DatasourceUtil; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceClient; |
||||||
|
import org.apache.dolphinscheduler.spi.enums.DbType; |
||||||
|
import org.apache.dolphinscheduler.spi.exception.PluginException; |
||||||
|
import org.apache.dolphinscheduler.spi.plugin.DolphinPluginLoader; |
||||||
|
import org.apache.dolphinscheduler.spi.plugin.DolphinPluginManagerConfig; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.Constants; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.PropertyUtils; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.StringUtils; |
||||||
|
|
||||||
|
import org.apache.commons.collections4.MapUtils; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList; |
||||||
|
|
||||||
|
public class DataSourceClientProvider { |
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DataSourceClientProvider.class); |
||||||
|
|
||||||
|
private static final Map<String, DataSourceClient> uniqueId2dataSourceClientMap = new ConcurrentHashMap<>(); |
||||||
|
|
||||||
|
private DataSourcePluginManager dataSourcePluginManager; |
||||||
|
|
||||||
|
private DataSourceClientProvider() { |
||||||
|
initDataSourcePlugin(); |
||||||
|
} |
||||||
|
|
||||||
|
private static class DataSourceClientProviderHolder { |
||||||
|
private static final DataSourceClientProvider INSTANCE = new DataSourceClientProvider(); |
||||||
|
} |
||||||
|
|
||||||
|
public static DataSourceClientProvider getInstance() { |
||||||
|
return DataSourceClientProviderHolder.INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public Connection getConnection(DbType dbType, ConnectionParam connectionParam) { |
||||||
|
BaseConnectionParam baseConnectionParam = (BaseConnectionParam) connectionParam; |
||||||
|
String datasourceUniqueId = DatasourceUtil.getDatasourceUniqueId(baseConnectionParam, dbType); |
||||||
|
logger.info("getConnection datasourceUniqueId {}", datasourceUniqueId); |
||||||
|
|
||||||
|
DataSourceClient dataSourceClient; |
||||||
|
dataSourceClient = uniqueId2dataSourceClientMap.get(datasourceUniqueId); |
||||||
|
if (dataSourceClient == null) { |
||||||
|
Map<String, DataSourceChannel> dataSourceChannelMap = dataSourcePluginManager.getDataSourceChannelMap(); |
||||||
|
DataSourceChannel dataSourceChannel = dataSourceChannelMap.get(dbType.getDescp()); |
||||||
|
if (null == dataSourceChannel) { |
||||||
|
throw PluginException.getInstance(String.format("%s dataSource Plugin Not Found,Please Check Config File.", dbType.getDescp())); |
||||||
|
} |
||||||
|
dataSourceClient = dataSourceChannel.createDataSourceClient(baseConnectionParam); |
||||||
|
uniqueId2dataSourceClientMap.put(datasourceUniqueId, dataSourceClient); |
||||||
|
} |
||||||
|
return dataSourceClient.getConnection(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initDataSourcePlugin() { |
||||||
|
dataSourcePluginManager = new DataSourcePluginManager(); |
||||||
|
DolphinPluginManagerConfig datasourcePluginManagerConfig = new DolphinPluginManagerConfig(); |
||||||
|
datasourcePluginManagerConfig.setPlugins(PropertyUtils.getString(Constants.DATASOURCE_PLUGIN_BINDING)); |
||||||
|
|
||||||
|
datasourcePluginManagerConfig.setInstalledPluginsDir(PropertyUtils.getString(Constants.DATASOURCE_PLUGIN_DIR, Constants.DATASOURCE_PLUGIN_PATH)); |
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(PropertyUtils.getString(Constants.MAVEN_LOCAL_REPOSITORY))) { |
||||||
|
datasourcePluginManagerConfig.setMavenLocalRepository(PropertyUtils.getString(Constants.MAVEN_LOCAL_REPOSITORY).trim()); |
||||||
|
} |
||||||
|
|
||||||
|
DolphinPluginLoader datasourcePluginLoader = new DolphinPluginLoader(datasourcePluginManagerConfig, ImmutableList.of(dataSourcePluginManager)); |
||||||
|
try { |
||||||
|
datasourcePluginLoader.loadPlugins(); |
||||||
|
} catch (Exception e) { |
||||||
|
throw PluginException.getInstance("Load datasource Plugin Failed !", e); |
||||||
|
} |
||||||
|
if (MapUtils.isEmpty(dataSourcePluginManager.getDataSourceChannelMap())) { |
||||||
|
throw PluginException.getInstance("datasource Plugin Not Found,Please Check Config File"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.plugin; |
||||||
|
|
||||||
|
import static java.lang.String.format; |
||||||
|
import static java.util.Objects.requireNonNull; |
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin; |
||||||
|
import org.apache.dolphinscheduler.spi.classloader.ThreadContextClassLoader; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory; |
||||||
|
import org.apache.dolphinscheduler.spi.exception.PluginException; |
||||||
|
import org.apache.dolphinscheduler.spi.plugin.AbstractDolphinPluginManager; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
public class DataSourcePluginManager extends AbstractDolphinPluginManager { |
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(DataSourcePluginManager.class); |
||||||
|
|
||||||
|
private final Map<String, DataSourceChannelFactory> datasourceClientFactoryMap = new ConcurrentHashMap<>(); |
||||||
|
private final Map<String, DataSourceChannel> datasourceClientMap = new ConcurrentHashMap<>(); |
||||||
|
|
||||||
|
public Map<String, DataSourceChannel> getDataSourceChannelMap() { |
||||||
|
return datasourceClientMap; |
||||||
|
} |
||||||
|
|
||||||
|
private void addDatasourceClientFactory(DataSourceChannelFactory datasourceChannelFactory) { |
||||||
|
requireNonNull(datasourceChannelFactory, "datasourceChannelFactory is null"); |
||||||
|
|
||||||
|
if (datasourceClientFactoryMap.putIfAbsent(datasourceChannelFactory.getName(), datasourceChannelFactory) != null) { |
||||||
|
throw PluginException.getInstance(format("Datasource Plugin '%s' is already registered", datasourceChannelFactory.getName())); |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
loadDatasourceClient(datasourceChannelFactory.getName()); |
||||||
|
} catch (Exception e) { |
||||||
|
throw PluginException.getInstance(format("Datasource Plugin '%s' is can not load .", datasourceChannelFactory.getName())); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void loadDatasourceClient(String name) { |
||||||
|
requireNonNull(name, "name is null"); |
||||||
|
|
||||||
|
DataSourceChannelFactory datasourceChannelFactory = datasourceClientFactoryMap.get(name); |
||||||
|
checkState(datasourceChannelFactory != null, "datasource Plugin {} is not registered", name); |
||||||
|
|
||||||
|
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(datasourceChannelFactory.getClass().getClassLoader())) { |
||||||
|
DataSourceChannel datasourceChannel = datasourceChannelFactory.create(); |
||||||
|
this.datasourceClientMap.put(name, datasourceChannel); |
||||||
|
} |
||||||
|
|
||||||
|
logger.info("-- Loaded datasource Plugin {} --", name); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void installPlugin(DolphinSchedulerPlugin dolphinSchedulerPlugin) { |
||||||
|
for (DataSourceChannelFactory datasourceChannelFactory : dolphinSchedulerPlugin.getDatasourceChannelFactorys()) { |
||||||
|
logger.info("Registering datasource Plugin '{}'", datasourceChannelFactory.getName()); |
||||||
|
this.addDatasourceClientFactory(datasourceChannelFactory); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.provider; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.PasswordUtils; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.Constants; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.PropertyUtils; |
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource; |
||||||
|
|
||||||
|
/** |
||||||
|
* Jdbc Data Source Provider |
||||||
|
*/ |
||||||
|
public class JdbcDataSourceProvider { |
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(JdbcDataSourceProvider.class); |
||||||
|
|
||||||
|
public static DruidDataSource createJdbcDataSource(BaseConnectionParam properties) { |
||||||
|
logger.info("Creating DruidDataSource pool for maxActive:{}", PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_ACTIVE, 50)); |
||||||
|
|
||||||
|
DruidDataSource druidDataSource = new DruidDataSource(); |
||||||
|
|
||||||
|
druidDataSource.setDriverClassName(properties.getDriverClassName()); |
||||||
|
druidDataSource.setUrl(properties.getJdbcUrl()); |
||||||
|
druidDataSource.setUsername(properties.getUser()); |
||||||
|
druidDataSource.setPassword(PasswordUtils.decodePassword(properties.getPassword())); |
||||||
|
|
||||||
|
druidDataSource.setMinIdle(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MIN_IDLE, 5)); |
||||||
|
druidDataSource.setMaxActive(PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_ACTIVE, 50)); |
||||||
|
druidDataSource.setTestOnBorrow(PropertyUtils.getBoolean(Constants.SPRING_DATASOURCE_TEST_ON_BORROW, false)); |
||||||
|
|
||||||
|
if (properties.getProps() != null) { |
||||||
|
properties.getProps().forEach(druidDataSource::addConnectionProperty); |
||||||
|
} |
||||||
|
|
||||||
|
logger.info("Creating DruidDataSource pool success."); |
||||||
|
return druidDataSource; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return One Session Jdbc DataSource |
||||||
|
*/ |
||||||
|
public static DruidDataSource createOneSessionJdbcDataSource(BaseConnectionParam properties) { |
||||||
|
logger.info("Creating OneSession DruidDataSource pool for maxActive:{}", PropertyUtils.getInt(Constants.SPRING_DATASOURCE_MAX_ACTIVE, 50)); |
||||||
|
|
||||||
|
DruidDataSource druidDataSource = new DruidDataSource(); |
||||||
|
|
||||||
|
druidDataSource.setDriverClassName(properties.getDriverClassName()); |
||||||
|
druidDataSource.setUrl(properties.getJdbcUrl()); |
||||||
|
druidDataSource.setUsername(properties.getUser()); |
||||||
|
druidDataSource.setPassword(PasswordUtils.decodePassword(properties.getPassword())); |
||||||
|
|
||||||
|
druidDataSource.setMinIdle(1); |
||||||
|
druidDataSource.setMaxActive(1); |
||||||
|
druidDataSource.setTestOnBorrow(true); |
||||||
|
|
||||||
|
if (properties.getProps() != null) { |
||||||
|
properties.getProps().forEach(druidDataSource::addConnectionProperty); |
||||||
|
} |
||||||
|
|
||||||
|
logger.info("Creating OneSession DruidDataSource pool success."); |
||||||
|
return druidDataSource; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,100 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.client; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.mysql.MysqlConnectionParam; |
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.provider.JdbcDataSourceProvider; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
|
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.mockito.Mock; |
||||||
|
import org.mockito.Mockito; |
||||||
|
import org.powermock.api.mockito.PowerMockito; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
import org.springframework.jdbc.core.JdbcTemplate; |
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource; |
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@SuppressStaticInitializationFor("org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient") |
||||||
|
@PrepareForTest(value = {DruidDataSource.class, CommonDataSourceClient.class, JdbcDataSourceProvider.class, JdbcTemplate.class, Connection.class}) |
||||||
|
public class CommonDataSourceClientTest { |
||||||
|
|
||||||
|
@Mock |
||||||
|
private CommonDataSourceClient commonDataSourceClient; |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testPreInit() { |
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).preInit(); |
||||||
|
commonDataSourceClient.preInit(); |
||||||
|
Mockito.verify(commonDataSourceClient).preInit(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCheckEnv() { |
||||||
|
BaseConnectionParam baseConnectionParam = new MysqlConnectionParam(); |
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).checkEnv(Mockito.any(BaseConnectionParam.class)); |
||||||
|
commonDataSourceClient.checkEnv(baseConnectionParam); |
||||||
|
Mockito.verify(commonDataSourceClient).checkEnv(Mockito.any(BaseConnectionParam.class)); |
||||||
|
|
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).checkValidationQuery(Mockito.any(BaseConnectionParam.class)); |
||||||
|
commonDataSourceClient.checkValidationQuery(baseConnectionParam); |
||||||
|
Mockito.verify(commonDataSourceClient).checkValidationQuery(Mockito.any(BaseConnectionParam.class)); |
||||||
|
|
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).checkUser(Mockito.any(BaseConnectionParam.class)); |
||||||
|
commonDataSourceClient.checkUser(baseConnectionParam); |
||||||
|
Mockito.verify(commonDataSourceClient).checkUser(Mockito.any(BaseConnectionParam.class)); |
||||||
|
|
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).setDefaultUsername(Mockito.any(BaseConnectionParam.class)); |
||||||
|
commonDataSourceClient.setDefaultUsername(baseConnectionParam); |
||||||
|
Mockito.verify(commonDataSourceClient).setDefaultUsername(Mockito.any(BaseConnectionParam.class)); |
||||||
|
|
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).setDefaultPassword(Mockito.any(BaseConnectionParam.class)); |
||||||
|
commonDataSourceClient.setDefaultPassword(baseConnectionParam); |
||||||
|
Mockito.verify(commonDataSourceClient).setDefaultPassword(Mockito.any(BaseConnectionParam.class)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testInitClient() { |
||||||
|
BaseConnectionParam baseConnectionParam = new MysqlConnectionParam(); |
||||||
|
PowerMockito.doNothing().when(commonDataSourceClient).initClient(Mockito.any(BaseConnectionParam.class)); |
||||||
|
commonDataSourceClient.initClient(baseConnectionParam); |
||||||
|
Mockito.verify(commonDataSourceClient).initClient(Mockito.any(BaseConnectionParam.class)); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCheckClient() { |
||||||
|
PowerMockito.doNothing().when(this.commonDataSourceClient).checkClient(); |
||||||
|
this.commonDataSourceClient.checkClient(); |
||||||
|
Mockito.verify(this.commonDataSourceClient).checkClient(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetConnection() { |
||||||
|
Connection connection = PowerMockito.mock(Connection.class); |
||||||
|
PowerMockito.when(commonDataSourceClient.getConnection()).thenReturn(connection); |
||||||
|
Assert.assertNotNull(commonDataSourceClient.getConnection()); |
||||||
|
} |
||||||
|
} |
26
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/clickhouse/ClickHouseDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickHouseDatasourceProcessorTest.java
26
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/clickhouse/ClickHouseDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/clickhouse/ClickHouseDatasourceProcessorTest.java
25
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/db2/Db2DatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/db2/Db2DatasourceProcessorTest.java
25
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/db2/Db2DatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/db2/Db2DatasourceProcessorTest.java
30
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/hive/HiveDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java
30
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/hive/HiveDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/hive/HiveDatasourceProcessorTest.java
37
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/mysql/MysqlDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java
37
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/mysql/MysqlDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/mysql/MysqlDatasourceProcessorTest.java
29
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/oracle/OracleDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleDatasourceProcessorTest.java
29
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/oracle/OracleDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/oracle/OracleDatasourceProcessorTest.java
27
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/postgresql/PostgreSqlDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlDatasourceProcessorTest.java
27
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/postgresql/PostgreSqlDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/postgresql/PostgreSqlDatasourceProcessorTest.java
27
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/presto/PrestoDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/presto/PrestoDatasourceProcessorTest.java
27
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/presto/PrestoDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/presto/PrestoDatasourceProcessorTest.java
29
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/spark/SparkDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkDatasourceProcessorTest.java
29
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/spark/SparkDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/spark/SparkDatasourceProcessorTest.java
29
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/sqlserver/SqlServerDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerDatasourceProcessorTest.java
29
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/datasource/sqlserver/SqlServerDatasourceProcessorTest.java → dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/test/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/sqlserver/SqlServerDatasourceProcessorTest.java
@ -0,0 +1,52 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.provider; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.mysql.MysqlConnectionParam; |
||||||
|
|
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.mockito.Mockito; |
||||||
|
import org.powermock.api.mockito.PowerMockito; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
|
||||||
|
import com.alibaba.druid.pool.DruidDataSource; |
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@PrepareForTest(value = {DruidDataSource.class, JdbcDataSourceProvider.class}) |
||||||
|
public class JdbcDataSourceProviderTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateJdbcDataSource() { |
||||||
|
PowerMockito.mockStatic(JdbcDataSourceProvider.class); |
||||||
|
DruidDataSource druidDataSource = PowerMockito.mock(DruidDataSource.class); |
||||||
|
PowerMockito.when(JdbcDataSourceProvider.createJdbcDataSource(Mockito.any())).thenReturn(druidDataSource); |
||||||
|
Assert.assertNotNull(JdbcDataSourceProvider.createJdbcDataSource(new MysqlConnectionParam())); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateOneSessionJdbcDataSource() { |
||||||
|
PowerMockito.mockStatic(JdbcDataSourceProvider.class); |
||||||
|
DruidDataSource druidDataSource = PowerMockito.mock(DruidDataSource.class); |
||||||
|
PowerMockito.when(JdbcDataSourceProvider.createOneSessionJdbcDataSource(Mockito.any())).thenReturn(druidDataSource); |
||||||
|
Assert.assertNotNull(JdbcDataSourceProvider.createOneSessionJdbcDataSource(new MysqlConnectionParam())); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,124 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.api.utils; |
||||||
|
|
||||||
|
import static org.apache.dolphinscheduler.spi.task.TaskConstants.DATASOURCE_ENCRYPTION_ENABLE; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.utils.Constants; |
||||||
|
import org.apache.dolphinscheduler.spi.utils.PropertyUtils; |
||||||
|
|
||||||
|
import org.apache.hadoop.conf.Configuration; |
||||||
|
import org.apache.hadoop.security.UserGroupInformation; |
||||||
|
|
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.powermock.api.mockito.PowerMockito; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@SuppressStaticInitializationFor("org.apache.dolphinscheduler.spi.utils.PropertyUtils") |
||||||
|
@PrepareForTest(value = {PropertyUtils.class, UserGroupInformation.class, CommonUtils.class, PasswordUtils.class}) |
||||||
|
public class CommonUtilsTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetKerberosStartupState() { |
||||||
|
PowerMockito.mockStatic(CommonUtils.class); |
||||||
|
PowerMockito.when(CommonUtils.getKerberosStartupState()).thenReturn(false); |
||||||
|
boolean kerberosStartupState = CommonUtils.getKerberosStartupState(); |
||||||
|
Assert.assertFalse(kerberosStartupState); |
||||||
|
|
||||||
|
PowerMockito.mockStatic(PropertyUtils.class); |
||||||
|
PowerMockito.when(PropertyUtils.getUpperCaseString(Constants.RESOURCE_STORAGE_TYPE)).thenReturn("HDFS"); |
||||||
|
PowerMockito.when(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, true)).thenReturn(Boolean.TRUE); |
||||||
|
kerberosStartupState = CommonUtils.getKerberosStartupState(); |
||||||
|
Assert.assertFalse(kerberosStartupState); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testLoadKerberosConf() { |
||||||
|
try { |
||||||
|
PowerMockito.mockStatic(PropertyUtils.class); |
||||||
|
PowerMockito.when(PropertyUtils.getUpperCaseString(Constants.RESOURCE_STORAGE_TYPE)).thenReturn("HDFS"); |
||||||
|
PowerMockito.when(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false)).thenReturn(Boolean.TRUE); |
||||||
|
PowerMockito.when(PropertyUtils.getString(Constants.JAVA_SECURITY_KRB5_CONF_PATH)).thenReturn("/opt/krb5.conf"); |
||||||
|
PowerMockito.when(PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_USERNAME)).thenReturn("hdfs-mycluster@ESZ.COM"); |
||||||
|
PowerMockito.when(PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_PATH)).thenReturn("/opt/hdfs.headless.keytab"); |
||||||
|
|
||||||
|
PowerMockito.mockStatic(UserGroupInformation.class); |
||||||
|
boolean result = CommonUtils.loadKerberosConf(new Configuration()); |
||||||
|
Assert.assertTrue(result); |
||||||
|
|
||||||
|
CommonUtils.loadKerberosConf(null, null, null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
Assert.fail("load Kerberos Conf failed"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void encodePassword() { |
||||||
|
PowerMockito.mockStatic(PropertyUtils.class); |
||||||
|
PowerMockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false)).thenReturn(Boolean.TRUE); |
||||||
|
|
||||||
|
Assert.assertEquals("", PasswordUtils.encodePassword("")); |
||||||
|
Assert.assertEquals("bnVsbE1USXpORFUy", PasswordUtils.encodePassword("123456")); |
||||||
|
Assert.assertEquals("bnVsbElWRkJXbGhUVjBBPQ==", PasswordUtils.encodePassword("!QAZXSW@")); |
||||||
|
Assert.assertEquals("bnVsbE5XUm1aMlZ5S0VBPQ==", PasswordUtils.encodePassword("5dfger(@")); |
||||||
|
|
||||||
|
PowerMockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false)).thenReturn(Boolean.FALSE); |
||||||
|
|
||||||
|
Assert.assertEquals("", PasswordUtils.encodePassword("")); |
||||||
|
Assert.assertEquals("123456", PasswordUtils.encodePassword("123456")); |
||||||
|
Assert.assertEquals("!QAZXSW@", PasswordUtils.encodePassword("!QAZXSW@")); |
||||||
|
Assert.assertEquals("5dfger(@", PasswordUtils.encodePassword("5dfger(@")); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void decodePassword() { |
||||||
|
PowerMockito.mockStatic(PropertyUtils.class); |
||||||
|
PowerMockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false)).thenReturn(Boolean.TRUE); |
||||||
|
|
||||||
|
PropertyUtils.setValue(Constants.DATASOURCE_ENCRYPTION_ENABLE, "true"); |
||||||
|
|
||||||
|
PowerMockito.mockStatic(PasswordUtils.class); |
||||||
|
PowerMockito.when(PasswordUtils.decodePassword("bnVsbE1USXpORFUy")).thenReturn("123456"); |
||||||
|
PowerMockito.when(PasswordUtils.decodePassword("bnVsbElWRkJXbGhUVjBBPQ==")).thenReturn("!QAZXSW@"); |
||||||
|
PowerMockito.when(PasswordUtils.decodePassword("bnVsbE5XUm1aMlZ5S0VBPQ==")).thenReturn("5dfger(@"); |
||||||
|
|
||||||
|
Assert.assertEquals(null, PasswordUtils.decodePassword("")); |
||||||
|
Assert.assertEquals("123456", PasswordUtils.decodePassword("bnVsbE1USXpORFUy")); |
||||||
|
Assert.assertEquals("!QAZXSW@", PasswordUtils.decodePassword("bnVsbElWRkJXbGhUVjBBPQ==")); |
||||||
|
Assert.assertEquals("5dfger(@", PasswordUtils.decodePassword("bnVsbE5XUm1aMlZ5S0VBPQ==")); |
||||||
|
|
||||||
|
PowerMockito.when(PropertyUtils.getBoolean(DATASOURCE_ENCRYPTION_ENABLE, false)).thenReturn(Boolean.FALSE); |
||||||
|
|
||||||
|
PowerMockito.when(PasswordUtils.decodePassword("123456")).thenReturn("123456"); |
||||||
|
PowerMockito.when(PasswordUtils.decodePassword("!QAZXSW@")).thenReturn("!QAZXSW@"); |
||||||
|
PowerMockito.when(PasswordUtils.decodePassword("5dfger(@")).thenReturn("5dfger(@"); |
||||||
|
|
||||||
|
Assert.assertEquals(null, PasswordUtils.decodePassword("")); |
||||||
|
Assert.assertEquals("123456", PasswordUtils.decodePassword("123456")); |
||||||
|
Assert.assertEquals("!QAZXSW@", PasswordUtils.decodePassword("!QAZXSW@")); |
||||||
|
Assert.assertEquals("5dfger(@", PasswordUtils.decodePassword("5dfger(@")); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,114 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- |
||||||
|
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
~ contributor license agreements. See the NOTICE file distributed with |
||||||
|
~ this work for additional information regarding copyright ownership. |
||||||
|
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
~ (the "License"); you may not use this file except in compliance with |
||||||
|
~ the License. You may obtain a copy of the License at |
||||||
|
~ |
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
~ |
||||||
|
~ Unless required by applicable law or agreed to in writing, software |
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
~ See the License for the specific language governing permissions and |
||||||
|
~ limitations under the License. |
||||||
|
--> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<parent> |
||||||
|
<artifactId>dolphinscheduler-datasource-plugin</artifactId> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<version>2.0.0-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-datasource-clickhouse</artifactId> |
||||||
|
<name>${project.artifactId}</name> |
||||||
|
<!-- can be load as a datasource Plugin when development and run server in IDE --> |
||||||
|
<packaging>dolphinscheduler-plugin</packaging> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-spi</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-datasource-api</artifactId> |
||||||
|
<version>${project.version}</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>ru.yandex.clickhouse</groupId> |
||||||
|
<artifactId>clickhouse-jdbc</artifactId> |
||||||
|
<exclusions> |
||||||
|
<exclusion> |
||||||
|
<artifactId>jaxb-api</artifactId> |
||||||
|
<groupId>javax.xml.bind</groupId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>com.fasterxml.jackson.core</groupId> |
||||||
|
<artifactId>jackson-annotations</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>com.fasterxml.jackson.core</groupId> |
||||||
|
<artifactId>jackson-databind</artifactId> |
||||||
|
</exclusion> |
||||||
|
<exclusion> |
||||||
|
<groupId>com.fasterxml.jackson.core</groupId> |
||||||
|
<artifactId>jackson-core</artifactId> |
||||||
|
</exclusion> |
||||||
|
</exclusions> |
||||||
|
<version>${clickhouse.jdbc.version}</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>junit</groupId> |
||||||
|
<artifactId>junit</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.powermock</groupId> |
||||||
|
<artifactId>powermock-module-junit4</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.powermock</groupId> |
||||||
|
<artifactId>powermock-api-mockito2</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
<exclusions> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-core</artifactId> |
||||||
|
</exclusion> |
||||||
|
</exclusions> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-core</artifactId> |
||||||
|
<type>jar</type> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.jacoco</groupId> |
||||||
|
<artifactId>org.jacoco.agent</artifactId> |
||||||
|
<classifier>runtime</classifier> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<finalName>dolphinscheduler-datasource-clickhouse-${project.version}</finalName> |
||||||
|
</build> |
||||||
|
</project> |
@ -0,0 +1,33 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.clickhouse; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory; |
||||||
|
|
||||||
|
public class ClickhouseDataSourceChannelFactory implements DataSourceChannelFactory { |
||||||
|
@Override |
||||||
|
public String getName() { |
||||||
|
return "clickhouse"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataSourceChannel create() { |
||||||
|
return new ClickhouseDataSourceChannel(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.clickhouse; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam; |
||||||
|
|
||||||
|
public class ClickhouseDataSourceClient extends CommonDataSourceClient { |
||||||
|
|
||||||
|
public ClickhouseDataSourceClient(BaseConnectionParam baseConnectionParam) { |
||||||
|
super(baseConnectionParam); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.clickhouse; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin; |
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory; |
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList; |
||||||
|
|
||||||
|
public class ClickhouseDataSourcePlugin implements DolphinSchedulerPlugin { |
||||||
|
@Override |
||||||
|
public Iterable<DataSourceChannelFactory> getDatasourceChannelFactorys() { |
||||||
|
return ImmutableList.of(new ClickhouseDataSourceChannelFactory()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.clickhouse; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel; |
||||||
|
|
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
public class ClickhouseDataSourceChannelFactoryTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreate() { |
||||||
|
ClickhouseDataSourceChannelFactory sourceChannelFactory = new ClickhouseDataSourceChannelFactory(); |
||||||
|
DataSourceChannel dataSourceChannel = sourceChannelFactory.create(); |
||||||
|
Assert.assertNotNull(dataSourceChannel); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.clickhouse; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.clickhouse.ClickhouseConnectionParam; |
||||||
|
|
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.mockito.Mockito; |
||||||
|
import org.powermock.api.mockito.PowerMockito; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@SuppressStaticInitializationFor("org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient") |
||||||
|
@PrepareForTest({ClickhouseDataSourceClient.class, ClickhouseDataSourceChannel.class}) |
||||||
|
public class ClickhouseDataSourceChannelTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateDataSourceClient() { |
||||||
|
ClickhouseDataSourceChannel sourceChannel = PowerMockito.mock(ClickhouseDataSourceChannel.class); |
||||||
|
ClickhouseDataSourceClient dataSourceClient = PowerMockito.mock(ClickhouseDataSourceClient.class); |
||||||
|
PowerMockito.when(sourceChannel.createDataSourceClient(Mockito.any())).thenReturn(dataSourceClient); |
||||||
|
Assert.assertNotNull(sourceChannel.createDataSourceClient(new ClickhouseConnectionParam())); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
/* |
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
* contributor license agreements. See the NOTICE file distributed with |
||||||
|
* this work for additional information regarding copyright ownership. |
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
* (the "License"); you may not use this file except in compliance with |
||||||
|
* the License. You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.datasource.clickhouse; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory; |
||||||
|
|
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
public class ClickhouseDataSourcePluginTest { |
||||||
|
|
||||||
|
private ClickhouseDataSourcePlugin dataSourcePlugin = new ClickhouseDataSourcePlugin(); |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetDatasourceChannelFactorys() { |
||||||
|
Iterable<DataSourceChannelFactory> channelFactorys = dataSourcePlugin.getDatasourceChannelFactorys(); |
||||||
|
for (DataSourceChannelFactory dataSourceChannelFactory : channelFactorys) { |
||||||
|
Assert.assertTrue(dataSourceChannelFactory instanceof ClickhouseDataSourceChannelFactory); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,91 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- |
||||||
|
~ Licensed to the Apache Software Foundation (ASF) under one or more |
||||||
|
~ contributor license agreements. See the NOTICE file distributed with |
||||||
|
~ this work for additional information regarding copyright ownership. |
||||||
|
~ The ASF licenses this file to You under the Apache License, Version 2.0 |
||||||
|
~ (the "License"); you may not use this file except in compliance with |
||||||
|
~ the License. You may obtain a copy of the License at |
||||||
|
~ |
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
~ |
||||||
|
~ Unless required by applicable law or agreed to in writing, software |
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
~ See the License for the specific language governing permissions and |
||||||
|
~ limitations under the License. |
||||||
|
--> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<parent> |
||||||
|
<artifactId>dolphinscheduler-datasource-plugin</artifactId> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<version>2.0.0-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-datasource-db2</artifactId> |
||||||
|
<name>${project.artifactId}</name> |
||||||
|
<!-- can be load as a datasource Plugin when development and run server in IDE --> |
||||||
|
<packaging>dolphinscheduler-plugin</packaging> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-spi</artifactId> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.dolphinscheduler</groupId> |
||||||
|
<artifactId>dolphinscheduler-datasource-api</artifactId> |
||||||
|
<version>${project.version}</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>junit</groupId> |
||||||
|
<artifactId>junit</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.powermock</groupId> |
||||||
|
<artifactId>powermock-module-junit4</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.powermock</groupId> |
||||||
|
<artifactId>powermock-api-mockito2</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
<exclusions> |
||||||
|
<exclusion> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-core</artifactId> |
||||||
|
</exclusion> |
||||||
|
</exclusions> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.mockito</groupId> |
||||||
|
<artifactId>mockito-core</artifactId> |
||||||
|
<type>jar</type> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.jacoco</groupId> |
||||||
|
<artifactId>org.jacoco.agent</artifactId> |
||||||
|
<classifier>runtime</classifier> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<finalName>dolphinscheduler-datasource-db2-${project.version}</finalName> |
||||||
|
</build> |
||||||
|
|
||||||
|
</project> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue