Skip to content

Commit ad073a9

Browse files
authored
Merge 98670be into 0c470ff
2 parents 0c470ff + 98670be commit ad073a9

File tree

14 files changed

+159
-57
lines changed

14 files changed

+159
-57
lines changed

dolphinscheduler-bom/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<vertica-jdbc.version>12.0.4-0</vertica-jdbc.version>
6161
<oracle-jdbc.version>21.5.0.0</oracle-jdbc.version>
6262
<dameng-jdbc.version>8.1.2.79</dameng-jdbc.version>
63+
<ngdbc.version>2.4.51</ngdbc.version>
6364
<slf4j.version>1.7.36</slf4j.version>
6465
<poi.version>4.1.2</poi.version>
6566
<javax.servlet-api.version>3.1.0</javax.servlet-api.version>
@@ -418,6 +419,14 @@
418419
<artifactId>h2</artifactId>
419420
<version>${h2.version}</version>
420421
</dependency>
422+
423+
<dependency>
424+
<groupId>com.sap.cloud.db.jdbc</groupId>
425+
<artifactId>ngdbc</artifactId>
426+
<version>${ngdbc.version}</version>
427+
<scope>test</scope>
428+
</dependency>
429+
421430
<!-- sl4j -->
422431
<dependency>
423432
<groupId>org.slf4j</groupId>

dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/constants/DataSourceConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class DataSourceConstants {
6565
public static final String KYUUBI_VALIDATION_QUERY = "select 1";
6666
public static final String VERTICA_VALIDATION_QUERY = "select 1";
6767

68-
public static final String HANA_VALIDATION_QUERY = "select 1";
68+
public static final String HANA_VALIDATION_QUERY = "select 1 from DUMMY";
6969

7070
/**
7171
* jdbc url

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-all/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,10 @@
153153
<artifactId>dolphinscheduler-datasource-k8s</artifactId>
154154
<version>${project.version}</version>
155155
</dependency>
156+
<dependency>
157+
<groupId>org.apache.dolphinscheduler</groupId>
158+
<artifactId>dolphinscheduler-datasource-hana</artifactId>
159+
<version>${project.version}</version>
160+
</dependency>
156161
</dependencies>
157162
</project>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>org.apache.dolphinscheduler</groupId>
23+
<artifactId>dolphinscheduler-datasource-plugin</artifactId>
24+
<version>dev-SNAPSHOT</version>
25+
</parent>
26+
27+
<artifactId>dolphinscheduler-datasource-hana</artifactId>
28+
<packaging>jar</packaging>
29+
<name>${project.artifactId}</name>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.apache.dolphinscheduler</groupId>
34+
<artifactId>dolphinscheduler-spi</artifactId>
35+
<scope>provided</scope>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.apache.dolphinscheduler</groupId>
40+
<artifactId>dolphinscheduler-datasource-api</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>com.sap.cloud.db.jdbc</groupId>
46+
<artifactId>ngdbc</artifactId>
47+
</dependency>
48+
</dependencies>
49+
</project>

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hana/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hana/HanaDataSourceClient.java renamed to dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hana/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hana/HanaAdHocDataSourceClient.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717

1818
package org.apache.dolphinscheduler.plugin.datasource.hana;
1919

20-
import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient;
20+
import org.apache.dolphinscheduler.plugin.datasource.api.client.BaseAdHocDataSourceClient;
2121
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
2222
import org.apache.dolphinscheduler.spi.enums.DbType;
2323

24-
public class HanaDataSourceClient extends CommonDataSourceClient {
24+
public class HanaAdHocDataSourceClient extends BaseAdHocDataSourceClient {
2525

26-
public HanaDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
26+
public HanaAdHocDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
2727
super(baseConnectionParam, dbType);
2828
}
29-
3029
}

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hana/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hana/HanaDataSourceChannel.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@
1717

1818
package org.apache.dolphinscheduler.plugin.datasource.hana;
1919

20+
import org.apache.dolphinscheduler.spi.datasource.AdHocDataSourceClient;
2021
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
2122
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
22-
import org.apache.dolphinscheduler.spi.datasource.DataSourceClient;
23+
import org.apache.dolphinscheduler.spi.datasource.PooledDataSourceClient;
2324
import org.apache.dolphinscheduler.spi.enums.DbType;
2425

2526
public class HanaDataSourceChannel implements DataSourceChannel {
2627

2728
@Override
28-
public DataSourceClient createDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
29-
return new HanaDataSourceClient(baseConnectionParam, dbType);
29+
public AdHocDataSourceClient createAdHocDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
30+
return new HanaAdHocDataSourceClient(baseConnectionParam, dbType);
31+
}
32+
33+
@Override
34+
public PooledDataSourceClient createPooledDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
35+
return new HanaPooledDataSourceClient(baseConnectionParam, dbType);
3036
}
3137
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.plugin.datasource.hana;
19+
20+
import org.apache.dolphinscheduler.plugin.datasource.api.client.BasePooledDataSourceClient;
21+
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
22+
import org.apache.dolphinscheduler.spi.enums.DbType;
23+
24+
public class HanaPooledDataSourceClient extends BasePooledDataSourceClient {
25+
26+
public HanaPooledDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
27+
super(baseConnectionParam, dbType);
28+
}
29+
30+
}

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hana/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hana/param/HanaDataSourceProcessor.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@
3434
import java.sql.DriverManager;
3535
import java.sql.SQLException;
3636

37-
import org.slf4j.Logger;
38-
import org.slf4j.LoggerFactory;
39-
4037
import com.google.auto.service.AutoService;
38+
4139
@AutoService(DataSourceProcessor.class)
4240
public class HanaDataSourceProcessor extends AbstractDataSourceProcessor {
4341

44-
private final Logger logger = LoggerFactory.getLogger(HanaDataSourceProcessor.class);
45-
4642
private static final String APPEND_PARAMS = "reconnect=true";
43+
4744
@Override
4845
public BaseDataSourceParamDTO castDatasourceParamDTO(String paramJson) {
4946
return JSONUtils.parseObject(paramJson, HanaDataSourceParamDTO.class);
@@ -96,7 +93,7 @@ public String getDatasourceDriver() {
9693

9794
@Override
9895
public String getValidationQuery() {
99-
return DataSourceConstants.COM_HANA_DB_JDBC_DRIVER;
96+
return DataSourceConstants.HANA_VALIDATION_QUERY;
10097
}
10198

10299
@Override

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hana/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hana/HanaDataSourceChannelFactoryTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
package org.apache.dolphinscheduler.plugin.datasource.hana;
1919

2020
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
21+
2122
import org.junit.jupiter.api.Assertions;
2223
import org.junit.jupiter.api.Test;
2324

24-
public class HanaDataSourceChannelFactoryTest {
25+
class HanaDataSourceChannelFactoryTest {
2526

2627
@Test
27-
public void testCreate() {
28+
void testCreate() {
2829
HanaDataSourceChannelFactory sourceChannelFactory = new HanaDataSourceChannelFactory();
2930
DataSourceChannel dataSourceChannel = sourceChannelFactory.create();
3031
Assertions.assertNotNull(dataSourceChannel);

dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hana/src/test/java/org/apache/dolphinscheduler/plugin/datasource/hana/HanaDataSourceChannelTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@
1919

2020
import org.apache.dolphinscheduler.plugin.datasource.hana.param.HanaConnectionParam;
2121
import org.apache.dolphinscheduler.spi.enums.DbType;
22+
2223
import org.junit.jupiter.api.Assertions;
2324
import org.junit.jupiter.api.Test;
2425
import org.junit.jupiter.api.extension.ExtendWith;
2526
import org.mockito.Mockito;
2627
import org.mockito.junit.jupiter.MockitoExtension;
2728

2829
@ExtendWith(MockitoExtension.class)
29-
public class HanaDataSourceChannelTest {
30+
class HanaDataSourceChannelTest {
3031

3132
@Test
32-
public void testCreateDataSourceClient() {
33+
void testCreateDataSourceClient() {
3334
HanaDataSourceChannel sourceChannel = Mockito.mock(HanaDataSourceChannel.class);
34-
HanaDataSourceClient dataSourceClient = Mockito.mock(HanaDataSourceClient.class);
35-
Mockito.when(sourceChannel.createDataSourceClient(Mockito.any(), Mockito.any())).thenReturn(dataSourceClient);
36-
Assertions.assertNotNull(sourceChannel.createDataSourceClient(new HanaConnectionParam(), DbType.HANA));
35+
HanaPooledDataSourceClient dataSourceClient = Mockito.mock(HanaPooledDataSourceClient.class);
36+
Mockito.when(sourceChannel.createPooledDataSourceClient(Mockito.any(), Mockito.any()))
37+
.thenReturn(dataSourceClient);
38+
Assertions.assertNotNull(sourceChannel.createPooledDataSourceClient(new HanaConnectionParam(), DbType.HANA));
3739
}
3840
}

0 commit comments

Comments
 (0)