@@ -125,8 +125,16 @@ public TaskExecuteThread(TaskExecutionContext taskExecutionContext,
125125
126126 @ Override
127127 public void run () {
128-
129128 TaskExecuteResponseCommand responseCommand = new TaskExecuteResponseCommand (taskExecutionContext .getTaskInstanceId (), taskExecutionContext .getProcessInstanceId ());
129+ if (Constants .DRY_RUN_FLAG_YES == taskExecutionContext .getDryRun ()) {
130+ responseCommand .setStatus (ExecutionStatus .SUCCESS .getCode ());
131+ responseCommand .setEndTime (new Date ());
132+ TaskExecutionContextCacheManager .removeByTaskInstanceId (taskExecutionContext .getTaskInstanceId ());
133+ ResponceCache .get ().cache (taskExecutionContext .getTaskInstanceId (), responseCommand .convert2Command (), Event .RESULT );
134+ taskCallbackService .sendResult (taskExecutionContext .getTaskInstanceId (), responseCommand .convert2Command ());
135+ return ;
136+ }
137+
130138 try {
131139 logger .info ("script path : {}" , taskExecutionContext .getExecutePath ());
132140 // check if the OS user exists
@@ -146,13 +154,8 @@ public void run() {
146154 }
147155 logger .info ("the task begins to execute. task instance id: {}" , taskExecutionContext .getTaskInstanceId ());
148156
149- int dryRun = taskExecutionContext .getDryRun ();
150157 // copy hdfs/minio file to local
151- if (dryRun == Constants .DRY_RUN_FLAG_NO ) {
152- downloadResource (taskExecutionContext .getExecutePath (),
153- taskExecutionContext .getResources (),
154- logger );
155- }
158+ downloadResource (taskExecutionContext .getExecutePath (), taskExecutionContext .getResources (), logger );
156159
157160 taskExecutionContext .setEnvFile (CommonUtils .getSystemEnvPath ());
158161 taskExecutionContext .setDefinedParams (getGlobalParamsMap ());
@@ -177,31 +180,28 @@ public void run() {
177180 taskRequest .setTaskLogName (taskLogName );
178181
179182 task = taskChannel .createTask (taskRequest );
183+
180184 // task init
181185 this .task .init ();
186+
182187 //init varPool
183188 this .task .getParameters ().setVarPool (taskExecutionContext .getVarPool ());
184189
185- if (dryRun == Constants .DRY_RUN_FLAG_NO ) {
186- // task handle
187- this .task .handle ();
190+ // task handle
191+ this .task .handle ();
188192
189- // task result process
190- if (this .task .getNeedAlert ()) {
191- sendAlert (this .task .getTaskAlertInfo ());
192- }
193- responseCommand .setStatus (this .task .getExitStatus ().getCode ());
194- } else {
195- responseCommand .setStatus (ExecutionStatus .SUCCESS .getCode ());
196- task .setExitStatusCode (Constants .EXIT_CODE_SUCCESS );
193+ // task result process
194+ if (this .task .getNeedAlert ()) {
195+ sendAlert (this .task .getTaskAlertInfo ());
197196 }
197+
198+ responseCommand .setStatus (this .task .getExitStatus ().getCode ());
198199 responseCommand .setEndTime (new Date ());
199200 responseCommand .setProcessId (this .task .getProcessId ());
200201 responseCommand .setAppIds (this .task .getAppIds ());
201202 responseCommand .setVarPool (JSONUtils .toJsonString (this .task .getParameters ().getVarPool ()));
202203 logger .info ("task instance id : {},task final status : {}" , taskExecutionContext .getTaskInstanceId (), this .task .getExitStatus ());
203204 } catch (Throwable e ) {
204-
205205 logger .error ("task scheduler failure" , e );
206206 kill ();
207207 responseCommand .setStatus (ExecutionStatus .FAILURE .getCode ());
0 commit comments