use of com.dtstack.taier.dao.domain.ScheduleEngineJobCache in project Taier by DTStack.
the class EngineJobCacheService method updateStage.
public int updateStage(String jobId, int stage, String nodeAddress, long priority, String waitReason) {
ScheduleEngineJobCache engineJobCache = new ScheduleEngineJobCache();
engineJobCache.setStage(stage);
engineJobCache.setNodeAddress(nodeAddress);
engineJobCache.setJobPriority(priority);
if (StringUtils.isNotBlank(waitReason)) {
engineJobCache.setWaitReason(waitReason);
}
engineJobCache.setGmtModified(Timestamp.valueOf(LocalDateTime.now()));
engineJobCache.setIsFailover(0);
return getBaseMapper().update(engineJobCache, Wrappers.lambdaQuery(ScheduleEngineJobCache.class).eq(ScheduleEngineJobCache::getJobId, jobId));
}
use of com.dtstack.taier.dao.domain.ScheduleEngineJobCache in project Taier by DTStack.
the class ScheduleJobCacheService method updateStage.
public int updateStage(String jobId, int stage, String nodeAddress, long priority, String waitReason) {
ScheduleEngineJobCache engineJobCache = new ScheduleEngineJobCache();
engineJobCache.setJobId(jobId);
engineJobCache.setNodeAddress(nodeAddress);
engineJobCache.setStage(stage);
engineJobCache.setJobPriority(priority);
engineJobCache.setWaitReason(waitReason);
return scheduleEngineJobCacheMapper.update(engineJobCache, Wrappers.lambdaQuery(ScheduleEngineJobCache.class).eq(ScheduleEngineJobCache::getJobId, jobId));
}
use of com.dtstack.taier.dao.domain.ScheduleEngineJobCache in project Taier by DTStack.
the class ScheduleJobCacheService method insert.
public void insert(String jobId, Integer computeType, int stage, String jobInfo, String nodeAddress, String jobName, long priority, String jobResource, Long tenantId) {
ScheduleEngineJobCache engineJobCache = new ScheduleEngineJobCache();
engineJobCache.setJobId(jobId);
engineJobCache.setNodeAddress(nodeAddress);
engineJobCache.setStage(stage);
engineJobCache.setJobPriority(priority);
engineJobCache.setJobInfo(jobInfo);
engineJobCache.setComputeType(computeType);
engineJobCache.setJobResource(jobResource);
engineJobCache.setJobName(jobName);
engineJobCache.setTenantId(tenantId);
this.save(engineJobCache);
}
use of com.dtstack.taier.dao.domain.ScheduleEngineJobCache in project Taier by DTStack.
the class GroupPriorityQueue method emitJob2PriorityQueue.
/**
* @return false: blocked | true: unblocked
*/
private boolean emitJob2PriorityQueue() {
boolean empty = false;
String localAddress = "";
try {
if (priorityQueueSize() >= getQueueSizeLimited()) {
return false;
}
localAddress = environmentContext.getLocalAddress();
long startId = 0L;
outLoop: while (true) {
List<ScheduleEngineJobCache> jobCaches = engineJobCacheService.listByStage(startId, localAddress, EJobCacheStage.DB.getStage(), jobResource);
if (CollectionUtils.isEmpty(jobCaches)) {
empty = true;
break;
}
for (ScheduleEngineJobCache jobCache : jobCaches) {
try {
ParamAction paramAction = PublicUtil.jsonStrToObject(jobCache.getJobInfo(), ParamAction.class);
JobClient jobClient = new JobClient(paramAction);
jobClient.setCallBack((jobStatus) -> {
jobDealer.updateJobStatus(jobClient.getJobId(), jobStatus);
});
boolean addInner = this.addInner(jobClient, false);
LOGGER.info("jobId:{} load from db, {} emit job to queue.", jobClient.getJobId(), addInner ? "success" : "failed");
if (!addInner) {
empty = false;
break outLoop;
}
startId = jobCache.getId();
} catch (Exception e) {
LOGGER.error("", e);
// 数据转换异常--打日志
jobDealer.dealSubmitFailJob(jobCache.getJobId(), "This task stores information exception and cannot be converted." + e.toString());
}
}
}
} catch (Exception e) {
LOGGER.error("emitJob2PriorityQueue localAddress:{} error:", localAddress, e);
}
if (empty) {
blocked.set(false);
}
return empty;
}
use of com.dtstack.taier.dao.domain.ScheduleEngineJobCache in project Taier by DTStack.
the class NodeRecoverService method recoverJobCaches.
public void recoverJobCaches() {
String localAddress = environmentContext.getLocalAddress();
try {
long startId = 0L;
while (true) {
List<ScheduleEngineJobCache> jobCaches = engineJobCacheService.listByStage(startId, localAddress, EJobCacheStage.SUBMITTED.getStage(), null);
if (CollectionUtils.isEmpty(jobCaches)) {
break;
}
List<JobClient> afterJobClients = new ArrayList<>(jobCaches.size());
for (ScheduleEngineJobCache jobCache : jobCaches) {
try {
ParamAction paramAction = PublicUtil.jsonStrToObject(jobCache.getJobInfo(), ParamAction.class);
JobClient jobClient = new JobClient(paramAction);
afterJobClients.add(jobClient);
startId = jobCache.getId();
} catch (Exception e) {
LOGGER.error("", e);
// 数据转换异常--打日志
jobDealer.dealSubmitFailJob(jobCache.getJobId(), "This task stores information exception and cannot be converted." + ExceptionUtil.getErrorMessage(e));
}
}
if (CollectionUtils.isNotEmpty(afterJobClients)) {
jobDealer.afterSubmitJobVast(afterJobClients);
}
}
} catch (Exception e) {
LOGGER.error("----broker:{} RecoverDealer error:", localAddress, e);
}
}
Aggregations