insist777 commented on code in PR #11670:
URL: https://github.com/apache/dolphinscheduler/pull/11670#discussion_r966862202
##########
dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-api/src/main/java/org/apache/dolphinscheduler/plugin/datasource/api/datasource/BaseDataSourceParamDTO.java:
##########
@@ -117,6 +121,20 @@ public void setOther(Map<String, String> other) {
this.other = other;
}
+ public int getTestFlag() {
+ return testFlag;
+ }
+
+ public void setTestFlag(int testFlag) {
+ this.testFlag = testFlag;
+ }
+ public Integer getBindTestId() {
Review Comment:
done.
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/runner/task/CommonTaskProcessor.java:
##########
@@ -171,4 +177,27 @@ private void killRemoteTask() throws ExecuteException {
nettyExecutorManager.executeDirectly(executionContext);
}
+
+ /**
+ * Check whether the test data source needs to be replaced
+ */
+ public void checkAndReplaceTestDataSource(){
+ if (taskInstance.getTestFlag() == Constants.TEST_FLAG_YES) {
+ try {
+ Map<String, Object> instanceParams =
JSONUtils.parseObject(taskInstance.getTaskParams(), new
TypeReference<Map<String, Object>>() {
+ });
+ Integer onlineDataSourceId = (Integer)
instanceParams.get("datasource");
+ Integer testDataSourceId =
processService.queryTestDataSourceId(onlineDataSourceId);
+ instanceParams.put("datasource", testDataSourceId);
+
taskInstance.setTaskParams(JSONUtils.toJsonString(instanceParams));
+ if (null == testDataSourceId) {
+ logger.warn("task name :{}, test data source
replacement failed", taskInstance.getName());
+ } else {
+ logger.info("task name :{}, test data source
replacement succeeded", taskInstance.getName());
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
Review Comment:
done.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]