@ -16,6 +16,8 @@
* /
package org.apache.dolphinscheduler.server.worker.task ;
import static ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER ;
import org.apache.dolphinscheduler.common.Constants ;
import org.apache.dolphinscheduler.common.enums.CommandType ;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus ;
@ -23,27 +25,17 @@ import org.apache.dolphinscheduler.common.enums.TaskRecordStatus;
import org.apache.dolphinscheduler.common.enums.TaskType ;
import org.apache.dolphinscheduler.common.process.Property ;
import org.apache.dolphinscheduler.common.task.AbstractParameters ;
import org.apache.dolphinscheduler.common.task.conditions.ConditionsParameters ;
import org.apache.dolphinscheduler.common.task.datax.DataxParameters ;
import org.apache.dolphinscheduler.common.task.flink.FlinkParameters ;
import org.apache.dolphinscheduler.common.task.mr.MapreduceParameters ;
import org.apache.dolphinscheduler.common.task.procedure.ProcedureParameters ;
import org.apache.dolphinscheduler.common.task.python.PythonParameters ;
import org.apache.dolphinscheduler.common.task.shell.ShellParameters ;
import org.apache.dolphinscheduler.common.task.spark.SparkParameters ;
import org.apache.dolphinscheduler.common.task.sql.SqlParameters ;
import org.apache.dolphinscheduler.common.task.sqoop.SqoopParameters ;
import org.apache.dolphinscheduler.common.utils.JSONUtils ;
import org.apache.dolphinscheduler.common.utils.TaskParametersUtils ;
import org.apache.dolphinscheduler.dao.TaskRecordDao ;
import org.apache.dolphinscheduler.server.entity.TaskExecutionContext ;
import org.apache.dolphinscheduler.server.utils.ParamUtils ;
import org.apache.commons.lang.StringUtils ;
import org.slf4j.Logger ;
import java.util.List ;
import java.util.Map ;
import static ch.qos.logback.classic.ClassicConstants.FINALIZE_SESSION_MARKER ;
import org.slf4j.Logger ;
/ * *
* executive task
@ -89,6 +81,7 @@ public abstract class AbstractTask {
/ * *
* constructor
*
* @param taskExecutionContext taskExecutionContext
* @param logger logger
* /
@ -99,6 +92,7 @@ public abstract class AbstractTask {
/ * *
* init task
*
* @throws Exception exception
* /
public void init ( ) throws Exception {
@ -106,6 +100,7 @@ public abstract class AbstractTask {
/ * *
* task handle
*
* @throws Exception exception
* /
public abstract void handle ( ) throws Exception ;
@ -113,6 +108,7 @@ public abstract class AbstractTask {
/ * *
* cancel application
*
* @param status status
* @throws Exception exception
* /
@ -122,6 +118,7 @@ public abstract class AbstractTask {
/ * *
* log handle
*
* @param logs log list
* /
public void logHandle ( List < String > logs ) {
@ -136,12 +133,14 @@ public abstract class AbstractTask {
public void setVarPool ( String varPool ) {
this . varPool = varPool ;
}
public String getVarPool ( ) {
return varPool ;
}
/ * *
* get exit status code
*
* @return exit status code
* /
public int getExitStatusCode ( ) {
@ -170,12 +169,12 @@ public abstract class AbstractTask {
/ * *
* get task parameters
*
* @return AbstractParameters
* /
public abstract AbstractParameters getParameters ( ) ;
/ * *
* result processing
* /
@ -184,7 +183,7 @@ public abstract class AbstractTask {
// task recor flat : if true , start up qianfan
if ( TaskRecordDao . getTaskRecordFlag ( )
& & TaskType . typeIsNormalTask ( taskExecutionContext . getTaskType ( ) ) ) {
AbstractParameters params = ( AbstractParameters ) JSONUtils . parseObject ( taskExecutionContext . getTaskParams ( ) , getCurTaskParamsClas s( ) ) ;
AbstractParameters params = TaskParametersUtils . getParameters ( taskExecutionContext . getTaskType ( ) , taskExecutionContext . getTaskParam s( ) ) ;
// replace placeholder
Map < String , Property > paramsMap = ParamUtils . convert ( ParamUtils . getUserDefParamsMap ( taskExecutionContext . getDefinedParams ( ) ) ,
@ -213,56 +212,9 @@ public abstract class AbstractTask {
}
/ * *
* get current task parameter class
* @return Task Params Class
* /
private Class getCurTaskParamsClass ( ) {
Class paramsClass = null ;
// get task type
TaskType taskType = TaskType . valueOf ( taskExecutionContext . getTaskType ( ) ) ;
switch ( taskType ) {
case SHELL :
paramsClass = ShellParameters . class ;
break ;
case SQL :
paramsClass = SqlParameters . class ;
break ;
case PROCEDURE :
paramsClass = ProcedureParameters . class ;
break ;
case MR :
paramsClass = MapreduceParameters . class ;
break ;
case SPARK :
paramsClass = SparkParameters . class ;
break ;
case FLINK :
paramsClass = FlinkParameters . class ;
break ;
case PYTHON :
paramsClass = PythonParameters . class ;
break ;
case DATAX :
paramsClass = DataxParameters . class ;
break ;
case SQOOP :
paramsClass = SqoopParameters . class ;
break ;
case CONDITIONS :
paramsClass = ConditionsParameters . class ;
break ;
default :
logger . error ( "not support this task type: {}" , taskType ) ;
throw new IllegalArgumentException ( "not support this task type" ) ;
}
return paramsClass ;
}
/ * *
* get exit status according to exitCode
*
* @return exit status
* /
public ExecutionStatus getExitStatus ( ) {