Skip to content

Commit

Permalink
resolve code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyang90 committed May 5, 2022
1 parent 50c4009 commit 1a7a00c
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 100 deletions.
21 changes: 1 addition & 20 deletions tdenginereader/doc/tdenginereader-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ TDengineReader 通过 TDengine 的 JDBC driver 查询获取数据。
"reader": {
"name": "tdenginereader",
"parameter": {
"user": "root",
"username": "root",
"password": "taosdata",
"connection": [
{
Expand Down Expand Up @@ -165,24 +165,8 @@ TDengineReader 通过 TDengine 的 JDBC driver 查询获取数据。

#### 4.1.1 数据特征

建表语句:

单行记录类似于:

#### 4.1.2 机器参数

* 执行DataX的机器参数为:
1. cpu:
2. mem:
3. net: 千兆双网卡
4. disc: DataX 数据不落磁盘,不统计此项

* TDengine数据库机器参数为:
1. cpu:
2. mem:
3. net: 千兆双网卡
4. disc:

#### 4.1.3 DataX jvm 参数

-Xms1024m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError
Expand All @@ -201,9 +185,6 @@ TDengineReader 通过 TDengine 的 JDBC driver 查询获取数据。

说明:

1. 这里的单表,主键类型为 bigint(20),自增。
2. batchSize 和 通道个数,对性能影响较大。

#### 4.2.4 性能测试小结

1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void init() {
}
if (start >= end)
throw DataXException.asDataXException(TDengineReaderErrorCode.ILLEGAL_VALUE,
"The parameter [" + Key.BEGIN_DATETIME + "] should be less than the parameter [" + Key.END_DATETIME + "].");
"The parameter " + Key.BEGIN_DATETIME + ": " + beginDatetime + " should be less than the parameter " + Key.END_DATETIME + ": " + endDatetime + ".");

}

Expand All @@ -119,7 +119,6 @@ public List<Configuration> split(int adviceNumber) {
}
}

LOG.info("Configuration: {}", configurations);
return configurations;
}
}
Expand All @@ -142,15 +141,14 @@ public static class Task extends Reader.Task {
try {
Class.forName("com.taosdata.jdbc.TSDBDriver");
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (ClassNotFoundException ignored) {
LOG.warn(ignored.getMessage(), ignored);
}
}

@Override
public void init() {
this.readerSliceConfig = super.getPluginJobConf();
LOG.info("getPluginJobConf: {}", readerSliceConfig);

String user = readerSliceConfig.getString(Key.USERNAME);
String password = readerSliceConfig.getString(Key.PASSWORD);
Expand All @@ -174,7 +172,12 @@ public void init() {

@Override
public void destroy() {

try {
if (conn != null)
conn.close();
} catch (SQLException e) {
LOG.error(e.getMessage(), e);
}
}

@Override
Expand All @@ -199,22 +202,15 @@ public void startRead(RecordSender recordSender) {
sqlList.addAll(querySql);
}

try (Statement stmt = conn.createStatement()) {
for (String sql : sqlList) {
for (String sql : sqlList) {
try (Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
Record record = buildRecord(recordSender, rs, mandatoryEncoding);
recordSender.sendToWriter(record);
}
}
} catch (SQLException e) {
throw DataXException.asDataXException(TDengineReaderErrorCode.RUNTIME_EXCEPTION, e.getMessage(), e);
} finally {
try {
if (conn != null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.alibaba.datax.plugin.writer.tdenginewriter;

public class Constants {
public static final String DEFAULT_USERNAME = "root";
public static final String DEFAULT_PASSWORD = "taosdata";
public static final int DEFAULT_BATCH_SIZE = 1;
public static final int DEFAULT_BATCH_SIZE = 1000;
public static final boolean DEFAULT_IGNORE_TAGS_UNMATCHED = false;
}
Loading

0 comments on commit 1a7a00c

Please sign in to comment.