simon824 commented on a change in pull request #2872:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/2872#discussion_r437135579
##########
File path:
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/JacksonSerializer.java
##########
@@ -31,7 +39,13 @@
* @return byte array
*/
public static <T> byte[] serialize(T obj) {
- String json = JSON.toJSONString(obj);
+ String json = "";
Review comment:
toJSONString will not throw exceptions
##########
File path:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/datax/DataxTask.java
##########
@@ -236,64 +222,90 @@ private String buildDataxJsonFile()
/**
* build datax job config
- *
+ *
* @return collection of datax job config JSONObject
* @throws SQLException if error throws SQLException
*/
- private List<JSONObject> buildDataxJobContentJson() throws SQLException {
- DataxTaskExecutionContext dataxTaskExecutionContext =
taskExecutionContext.getDataxTaskExecutionContext();
+ private List<ObjectNode> buildDataxJobContentJson() throws SQLException {
+ DataxTaskExecutionContext dataxTaskExecutionContext =
taskExecutionContext.getDataxTaskExecutionContext();
BaseDataSource dataSourceCfg =
DataSourceFactory.getDatasource(DbType.of(dataxTaskExecutionContext.getSourcetype()),
dataxTaskExecutionContext.getSourceConnectionParams());
BaseDataSource dataTargetCfg =
DataSourceFactory.getDatasource(DbType.of(dataxTaskExecutionContext.getTargetType()),
dataxTaskExecutionContext.getTargetConnectionParams());
- List<JSONObject> readerConnArr = new ArrayList<>();
- JSONObject readerConn = new JSONObject();
- readerConn.put("querySql", new String[] {dataXParameters.getSql()});
- readerConn.put("jdbcUrl", new String[] {dataSourceCfg.getJdbcUrl()});
+ List<ObjectNode> readerConnArr = new ArrayList<>();
+ ObjectNode readerConn = JSONUtils.createObjectNode();
+
+ ArrayNode sqlArr = readerConn.putArray("querySql");
+ for (String sql : new String[]{dataXParameters.getSql()}) {
+ sqlArr.add(sql);
+ }
+
+ ArrayNode urlArr = readerConn.putArray("jdbcUrl");
+ for (String url : new String[]{dataSourceCfg.getJdbcUrl()}) {
+ urlArr.add(url);
+ }
+
readerConnArr.add(readerConn);
- JSONObject readerParam = new JSONObject();
+ ObjectNode readerParam = JSONUtils.createObjectNode();
readerParam.put("username", dataSourceCfg.getUser());
readerParam.put("password", dataSourceCfg.getPassword());
- readerParam.put("connection", readerConnArr);
+ readerParam.putArray("connection").addAll(readerConnArr);
- JSONObject reader = new JSONObject();
+
+ ObjectNode reader = JSONUtils.createObjectNode();
reader.put("name",
DataxUtils.getReaderPluginName(DbType.of(dataxTaskExecutionContext.getSourcetype())));
- reader.put("parameter", readerParam);
+ reader.set("parameter", readerParam);
+
+ List<ObjectNode> writerConnArr = new ArrayList<>();
+ ObjectNode writerConn = JSONUtils.createObjectNode();
+ ArrayNode tableArr = writerConn.putArray("table");
+ for (String table : new String[]{dataXParameters.getTargetTable()}) {
+ tableArr.add(table);
+ }
- List<JSONObject> writerConnArr = new ArrayList<>();
- JSONObject writerConn = new JSONObject();
- writerConn.put("table", new String[]
{dataXParameters.getTargetTable()});
writerConn.put("jdbcUrl", dataTargetCfg.getJdbcUrl());
writerConnArr.add(writerConn);
- JSONObject writerParam = new JSONObject();
+ ObjectNode writerParam = JSONUtils.createObjectNode();
writerParam.put("username", dataTargetCfg.getUser());
writerParam.put("password", dataTargetCfg.getPassword());
- writerParam.put("column",
-
parsingSqlColumnNames(DbType.of(dataxTaskExecutionContext.getSourcetype()),
- DbType.of(dataxTaskExecutionContext.getTargetType()),
- dataSourceCfg, dataXParameters.getSql()));
- writerParam.put("connection", writerConnArr);
+
+ String[] columns =
parsingSqlColumnNames(DbType.of(dataxTaskExecutionContext.getSourcetype()),
+ DbType.of(dataxTaskExecutionContext.getTargetType()),
+ dataSourceCfg, dataXParameters.getSql());
+ ArrayNode columnArr = writerParam.putArray("column");
Review comment:
The type of columns is String[] , addAll() only accept ArrayNode
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]