|
|
@ -35,6 +35,7 @@ import org.apache.dolphinscheduler.server.worker.cache.ResponceCache; |
|
|
|
import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager; |
|
|
|
import org.apache.dolphinscheduler.server.worker.plugin.TaskPluginManager; |
|
|
|
import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService; |
|
|
|
import org.apache.dolphinscheduler.server.worker.processor.TaskCallbackService; |
|
|
|
import org.apache.dolphinscheduler.service.alert.AlertClientService; |
|
|
|
import org.apache.dolphinscheduler.service.alert.AlertClientService; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.spi.exception.PluginNotFoundException; |
|
|
|
import org.apache.dolphinscheduler.spi.task.AbstractTask; |
|
|
|
import org.apache.dolphinscheduler.spi.task.AbstractTask; |
|
|
|
import org.apache.dolphinscheduler.spi.task.TaskChannel; |
|
|
|
import org.apache.dolphinscheduler.spi.task.TaskChannel; |
|
|
|
import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; |
|
|
|
import org.apache.dolphinscheduler.spi.task.TaskExecutionContextCacheManager; |
|
|
@ -104,6 +105,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* constructor |
|
|
|
* constructor |
|
|
|
|
|
|
|
* |
|
|
|
* @param taskExecutionContext taskExecutionContext |
|
|
|
* @param taskExecutionContext taskExecutionContext |
|
|
|
* @param taskCallbackService taskCallbackService |
|
|
|
* @param taskCallbackService taskCallbackService |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -128,7 +130,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
TaskExecuteResponseCommand responseCommand = new TaskExecuteResponseCommand(taskExecutionContext.getTaskInstanceId(),taskExecutionContext.getProcessInstanceId()); |
|
|
|
TaskExecuteResponseCommand responseCommand = new TaskExecuteResponseCommand(taskExecutionContext.getTaskInstanceId(), taskExecutionContext.getProcessInstanceId()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
logger.info("script path : {}", taskExecutionContext.getExecutePath()); |
|
|
|
logger.info("script path : {}", taskExecutionContext.getExecutePath()); |
|
|
|
// check if the OS user exists
|
|
|
|
// check if the OS user exists
|
|
|
@ -161,6 +163,9 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
taskExecutionContext.getTaskInstanceId())); |
|
|
|
taskExecutionContext.getTaskInstanceId())); |
|
|
|
|
|
|
|
|
|
|
|
TaskChannel taskChannel = taskPluginManager.getTaskChannelMap().get(taskExecutionContext.getTaskType()); |
|
|
|
TaskChannel taskChannel = taskPluginManager.getTaskChannelMap().get(taskExecutionContext.getTaskType()); |
|
|
|
|
|
|
|
if (null == taskChannel) { |
|
|
|
|
|
|
|
throw new PluginNotFoundException(String.format("%s Task Plugin Not Found,Please Check Config File.", taskExecutionContext.getTaskType())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO Temporary operation, To be adjusted
|
|
|
|
//TODO Temporary operation, To be adjusted
|
|
|
|
TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class); |
|
|
|
TaskRequest taskRequest = JSONUtils.parseObject(JSONUtils.toJsonString(taskExecutionContext), TaskRequest.class); |
|
|
@ -229,6 +234,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* get global paras map |
|
|
|
* get global paras map |
|
|
|
|
|
|
|
* |
|
|
|
* @return map |
|
|
|
* @return map |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<String, String> getGlobalParamsMap() { |
|
|
|
private Map<String, String> getGlobalParamsMap() { |
|
|
@ -251,7 +257,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
try { |
|
|
|
try { |
|
|
|
task.cancelApplication(true); |
|
|
|
task.cancelApplication(true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -270,7 +276,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
|
|
|
|
|
|
|
|
Set<Map.Entry<String, String>> resEntries = projectRes.entrySet(); |
|
|
|
Set<Map.Entry<String, String>> resEntries = projectRes.entrySet(); |
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String,String> resource : resEntries) { |
|
|
|
for (Map.Entry<String, String> resource : resEntries) { |
|
|
|
String fullName = resource.getKey(); |
|
|
|
String fullName = resource.getKey(); |
|
|
|
String tenantCode = resource.getValue(); |
|
|
|
String tenantCode = resource.getValue(); |
|
|
|
File resFile = new File(execLocalPath, fullName); |
|
|
|
File resFile = new File(execLocalPath, fullName); |
|
|
@ -282,7 +288,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
logger.info("get resource file from hdfs :{}", resHdfsPath); |
|
|
|
logger.info("get resource file from hdfs :{}", resHdfsPath); |
|
|
|
HadoopUtils.getInstance().copyHdfsToLocal(resHdfsPath, execLocalPath + File.separator + fullName, false, true); |
|
|
|
HadoopUtils.getInstance().copyHdfsToLocal(resHdfsPath, execLocalPath + File.separator + fullName, false, true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(),e); |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -329,6 +335,7 @@ public class TaskExecuteThread implements Runnable, Delayed { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* get current TaskExecutionContext |
|
|
|
* get current TaskExecutionContext |
|
|
|
|
|
|
|
* |
|
|
|
* @return TaskExecutionContext |
|
|
|
* @return TaskExecutionContext |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public TaskExecutionContext getTaskExecutionContext() { |
|
|
|
public TaskExecutionContext getTaskExecutionContext() { |
|
|
|