Skip to content

Commit 1a7a00c

Browse files
committed
resolve code review suggestions
1 parent 50c4009 commit 1a7a00c

File tree

7 files changed

+141
-100
lines changed

7 files changed

+141
-100
lines changed

tdenginereader/doc/tdenginereader-CN.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ TDengineReader 通过 TDengine 的 JDBC driver 查询获取数据。
2222
"reader": {
2323
"name": "tdenginereader",
2424
"parameter": {
25-
"user": "root",
25+
"username": "root",
2626
"password": "taosdata",
2727
"connection": [
2828
{
@@ -165,24 +165,8 @@ TDengineReader 通过 TDengine 的 JDBC driver 查询获取数据。
165165

166166
#### 4.1.1 数据特征
167167

168-
建表语句:
169-
170-
单行记录类似于:
171-
172168
#### 4.1.2 机器参数
173169

174-
* 执行DataX的机器参数为:
175-
1. cpu:
176-
2. mem:
177-
3. net: 千兆双网卡
178-
4. disc: DataX 数据不落磁盘,不统计此项
179-
180-
* TDengine数据库机器参数为:
181-
1. cpu:
182-
2. mem:
183-
3. net: 千兆双网卡
184-
4. disc:
185-
186170
#### 4.1.3 DataX jvm 参数
187171

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

202186
说明:
203187

204-
1. 这里的单表,主键类型为 bigint(20),自增。
205-
2. batchSize 和 通道个数,对性能影响较大。
206-
207188
#### 4.2.4 性能测试小结
208189

209190
1.

tdenginereader/src/main/java/com/alibaba/datax/plugin/reader/TDengineReader.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void init() {
9393
}
9494
if (start >= end)
9595
throw DataXException.asDataXException(TDengineReaderErrorCode.ILLEGAL_VALUE,
96-
"The parameter [" + Key.BEGIN_DATETIME + "] should be less than the parameter [" + Key.END_DATETIME + "].");
96+
"The parameter " + Key.BEGIN_DATETIME + ": " + beginDatetime + " should be less than the parameter " + Key.END_DATETIME + ": " + endDatetime + ".");
9797

9898
}
9999

@@ -119,7 +119,6 @@ public List<Configuration> split(int adviceNumber) {
119119
}
120120
}
121121

122-
LOG.info("Configuration: {}", configurations);
123122
return configurations;
124123
}
125124
}
@@ -142,15 +141,14 @@ public static class Task extends Reader.Task {
142141
try {
143142
Class.forName("com.taosdata.jdbc.TSDBDriver");
144143
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
145-
} catch (ClassNotFoundException e) {
146-
e.printStackTrace();
144+
} catch (ClassNotFoundException ignored) {
145+
LOG.warn(ignored.getMessage(), ignored);
147146
}
148147
}
149148

150149
@Override
151150
public void init() {
152151
this.readerSliceConfig = super.getPluginJobConf();
153-
LOG.info("getPluginJobConf: {}", readerSliceConfig);
154152

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

175173
@Override
176174
public void destroy() {
177-
175+
try {
176+
if (conn != null)
177+
conn.close();
178+
} catch (SQLException e) {
179+
LOG.error(e.getMessage(), e);
180+
}
178181
}
179182

180183
@Override
@@ -199,22 +202,15 @@ public void startRead(RecordSender recordSender) {
199202
sqlList.addAll(querySql);
200203
}
201204

202-
try (Statement stmt = conn.createStatement()) {
203-
for (String sql : sqlList) {
205+
for (String sql : sqlList) {
206+
try (Statement stmt = conn.createStatement()) {
204207
ResultSet rs = stmt.executeQuery(sql);
205208
while (rs.next()) {
206209
Record record = buildRecord(recordSender, rs, mandatoryEncoding);
207210
recordSender.sendToWriter(record);
208211
}
209-
}
210-
} catch (SQLException e) {
211-
throw DataXException.asDataXException(TDengineReaderErrorCode.RUNTIME_EXCEPTION, e.getMessage(), e);
212-
} finally {
213-
try {
214-
if (conn != null)
215-
conn.close();
216212
} catch (SQLException e) {
217-
e.printStackTrace();
213+
LOG.error(e.getMessage(), e);
218214
}
219215
}
220216
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.alibaba.datax.plugin.writer.tdenginewriter;
22

33
public class Constants {
4-
public static final String DEFAULT_USERNAME = "root";
5-
public static final String DEFAULT_PASSWORD = "taosdata";
6-
public static final int DEFAULT_BATCH_SIZE = 1;
4+
public static final int DEFAULT_BATCH_SIZE = 1000;
75
public static final boolean DEFAULT_IGNORE_TAGS_UNMATCHED = false;
86
}

0 commit comments

Comments
 (0)