use of com.dtstack.taier.pluginapi.enums.TaskStatus in project Taier by DTStack.
the class AbstractRdbsClientTest method testGetJobStatus.
@Test
public void testGetJobStatus() throws Exception {
RdbsExeQueue rdbsExeQueue = PowerMockito.mock(RdbsExeQueue.class);
when(rdbsExeQueue.getJobStatus(any(String.class))).thenReturn(TaskStatus.RUNNING);
MemberModifier.field(TestRdbsClient.class, "exeQueue").set(testRdbsClient, rdbsExeQueue);
JobIdentifier jobIdentifier = JobIdentifier.createInstance("test", "test", "test");
TaskStatus status = testRdbsClient.getJobStatus(jobIdentifier);
Assert.assertEquals(status, TaskStatus.RUNNING);
}
use of com.dtstack.taier.pluginapi.enums.TaskStatus in project Taier by DTStack.
the class JobStatusDealer method dealJob.
private void dealJob(String jobId) throws Exception {
ScheduleJob scheduleJob = scheduleJobService.getByJobId(jobId);
ScheduleEngineJobCache engineJobCache = scheduleJobCacheService.getJobCacheByJobId(jobId);
if (scheduleJob == null || engineJobCache == null || (StringUtils.isBlank(scheduleJob.getApplicationId()) && StringUtils.isBlank(scheduleJob.getEngineJobId()))) {
shardCache.updateLocalMemTaskStatus(jobId, TaskStatus.CANCELED.getStatus());
Integer status = TaskStatus.CANCELED.getStatus();
String engineJobId = null;
if (scheduleJob != null) {
engineJobId = scheduleJob.getEngineJobId();
if (TaskStatus.getStoppedStatus().contains(scheduleJob.getStatus())) {
status = scheduleJob.getStatus();
} else {
scheduleJobService.updateJobStatusAndExecTime(jobId, status);
}
} else {
scheduleJobService.updateJobStatusAndExecTime(jobId, status);
}
scheduleJobCacheService.deleteByJobId(jobId);
LOGGER.info("jobId:{} set job finished, status:{}, scheduleJob is {} null, engineJobCache is {} null, engineJobId is {} blank.", jobId, status, scheduleJob == null ? "" : "not", engineJobCache == null ? "" : "not", engineJobId == null ? "" : "not");
} else {
String engineTaskId = scheduleJob.getEngineJobId();
String appId = scheduleJob.getApplicationId();
ParamAction paramAction = PublicUtil.jsonStrToObject(engineJobCache.getJobInfo(), ParamAction.class);
Integer taskType = paramAction.getTaskType();
Map<String, Object> pluginInfo = paramAction.getPluginInfo();
JobIdentifier jobIdentifier = new JobIdentifier(engineTaskId, appId, jobId, scheduleJob.getTenantId(), taskType, TaskParamsUtils.parseDeployTypeByTaskParams(paramAction.getTaskParams(), scheduleJob.getComputeType()).getType(), null, MapUtils.isEmpty(pluginInfo) ? null : JSONObject.toJSONString(pluginInfo), paramAction.getComponentVersion());
TaskStatus taskStatus = workerOperator.getJobStatus(jobIdentifier);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("------ jobId:{} dealJob status:{}", jobId, taskStatus);
}
if (taskStatus != null) {
taskStatus = checkNotFoundStatus(taskStatus, jobId);
Integer status = taskStatus.getStatus();
// 重试状态 先不更新状态
boolean isRestart = jobRestartDealer.checkAndRestart(status, scheduleJob, engineJobCache, (job, client) -> ForkJoinPool.commonPool().execute(() -> {
String engineLog = workerOperator.getEngineLog(jobIdentifier);
jobRestartDealer.jobRetryRecord(job, client, engineLog);
}));
if (isRestart) {
LOGGER.info("----- jobId:{} after dealJob status:{}", jobId, taskStatus);
return;
}
shardCache.updateLocalMemTaskStatus(jobId, status);
updateJobStatusWithPredicate(scheduleJob, jobId, status);
// 数据的更新顺序,先更新job_cache,再更新engine_batch_job
if (TaskStatus.getStoppedStatus().contains(status)) {
jobLogDelayDealer(jobId, jobIdentifier, engineJobCache.getComputeType(), scheduleJob.getType());
jobStatusFrequency.remove(jobId);
scheduleJobCacheService.deleteByJobId(jobId);
LOGGER.info("------ jobId:{} is stop status {} delete jobCache", jobId, status);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("------ jobId:{} after dealJob status:{}", jobId, taskStatus);
}
}
}
}
use of com.dtstack.taier.pluginapi.enums.TaskStatus in project Taier by DTStack.
the class LogAspect method afterReturningAdvice.
@AfterReturning(pointcut = "execution(public * com.dtstack.taier.scheduler.WorkerOperator.*(..))", returning = "ret")
public void afterReturningAdvice(JoinPoint joinPoint, Object ret) {
try {
String methodName = joinPoint.getSignature().getName();
if (filterMethod.contains(methodName)) {
return;
}
String argsString = null;
Object[] args = joinPoint.getArgs();
Optional<Object> jobClientOpt = Arrays.stream(args).filter(a -> a instanceof JobClient).findFirst();
if (jobClientOpt.isPresent()) {
if (logPluginInfoMethod.contains(methodName)) {
argsString = JSONObject.toJSONString(jobClientOpt.get(), submitPropertyFilter);
} else {
// 忽略pluginInfo打印
argsString = JSONObject.toJSONString(jobClientOpt.get(), propertyFilter);
}
} else {
if (skipChangeMethod.contains(methodName)) {
if (ret instanceof TaskStatus && (TaskStatus.RUNNING.equals(ret) || TaskStatus.SCHEDULED.equals(ret))) {
// 状态获取 多以running 为主 过滤频繁打印
return;
}
} else {
argsString = JSONObject.toJSONString(args);
}
}
if (LOGGER.isInfoEnabled()) {
JSONObject logInfo = new JSONObject(3);
logInfo.put("method", joinPoint.getSignature().getDeclaringTypeName() + "." + methodName);
logInfo.put("args", argsString);
logInfo.put("return", JSONObject.toJSONString(ret));
LOGGER.info(logInfo.toJSONString());
}
} catch (Exception e) {
LOGGER.error("logAspect error ", e);
}
}
Aggregations