Browse Source

cal duration in processInstancesList (#943)

* rename from DatasourceUserMapper to DataSourceUserMapper

* add unit test in UserMapper and WorkerGroupMapper

* change cn.escheduler to org.apache.dolphinscheduler

* add unit test in UdfFuncMapperTest

* add unit test in UdfFuncMapperTest

* remove DatabaseConfiguration

* add ConnectionFactoryTest

* cal duration in processInstancesList
lgcareer 5 years ago
parent
commit
60a13bf5ec

+ 3 - 0
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java

@@ -915,6 +915,9 @@ public class ProcessDefinitionService extends BaseDAGService {
          */
         List<ProcessInstance> processInstanceList = processInstanceMapper.queryByProcessDefineId(processId, limit);
 
+        for(ProcessInstance processInstance:processInstanceList){
+            processInstance.setDuration(DateUtils.differSec(processInstance.getStartTime(),processInstance.getEndTime()));
+        }
 
         if (limit > processInstanceList.size()) {
             limit = processInstanceList.size();

+ 4 - 0
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java

@@ -193,6 +193,10 @@ public class ProcessInstanceService extends BaseDAGService {
                 processInstanceMapper.queryProcessInstanceListPaging(page,
                 project.getId(), processDefineId, searchVal, statusArray, host, start, end);
 
+        for(ProcessInstance processInstance:processInstanceList.getRecords()){
+            processInstance.setDuration(DateUtils.differSec(processInstance.getStartTime(),processInstance.getEndTime()));
+        }
+
         Set<String> exclusionSet = new HashSet<String>(){{
             add(Constants.CLASS);
             add("locations");

+ 12 - 7
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java

@@ -16,6 +16,11 @@
  */
 package org.apache.dolphinscheduler.server.worker.task.sql;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.EnumUtils;
 import org.apache.dolphinscheduler.alert.utils.MailUtils;
 import org.apache.dolphinscheduler.common.enums.ShowType;
 import org.apache.dolphinscheduler.common.enums.TaskTimeoutStrategy;
@@ -41,11 +46,6 @@ import org.apache.dolphinscheduler.server.utils.ParamUtils;
 import org.apache.dolphinscheduler.server.utils.UDFUtils;
 import org.apache.dolphinscheduler.server.worker.task.AbstractTask;
 import org.apache.dolphinscheduler.server.worker.task.TaskProps;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.serializer.SerializerFeature;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.EnumUtils;
 import org.slf4j.Logger;
 
 import java.sql.*;
@@ -55,7 +55,7 @@ import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import static org.apache.dolphinscheduler.common.Constants.*;
-import static org.apache.dolphinscheduler.common.enums.DbType.*;
+import static org.apache.dolphinscheduler.common.enums.DbType.HIVE;
 /**
  *  sql task
  */
@@ -162,7 +162,12 @@ public class SqlTask extends AbstractTask {
             boolean udfTypeFlag = EnumUtils.isValidEnum(UdfType.class, sqlParameters.getType())
                     && StringUtils.isNotEmpty(sqlParameters.getUdfs());
             if(udfTypeFlag){
-                List<UdfFunc> udfFuncList = processDao.queryUdfFunListByids(sqlParameters.getUdfs());
+                String[] ids = sqlParameters.getUdfs().split(",");
+                int[] idsArray = new int[ids.length];
+                for(int i=0;i<ids.length;i++){
+                    idsArray[i]=Integer.parseInt(ids[i]);
+                }
+                List<UdfFunc> udfFuncList = processDao.queryUdfFunListByids(idsArray);
                 createFuncs = UDFUtils.createFuncs(udfFuncList, taskProps.getTenantCode(), logger);
             }