Search in sources :

Example 6 with ScheduleEngineJobCache

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));
}
Also used : ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 7 with ScheduleEngineJobCache

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));
}
Also used : ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 8 with ScheduleEngineJobCache

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);
}
Also used : ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 9 with ScheduleEngineJobCache

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;
}
Also used : Logger(org.slf4j.Logger) java.util.concurrent(java.util.concurrent) LoggerFactory(org.slf4j.LoggerFactory) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StringUtils(org.apache.commons.lang3.StringUtils) ApplicationContext(org.springframework.context.ApplicationContext) EngineJobCacheService(com.dtstack.taier.scheduler.service.EngineJobCacheService) EJobCacheStage(com.dtstack.taier.common.enums.EJobCacheStage) CustomThreadFactory(com.dtstack.taier.pluginapi.CustomThreadFactory) ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) JobClient(com.dtstack.taier.pluginapi.JobClient) PublicUtil(com.dtstack.taier.pluginapi.util.PublicUtil) List(java.util.List) JobClientComparator(com.dtstack.taier.common.queue.comparator.JobClientComparator) JobDealer(com.dtstack.taier.scheduler.jobdealer.JobDealer) CollectionUtils(org.apache.commons.collections.CollectionUtils) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache) WorkerOperator(com.dtstack.taier.scheduler.WorkerOperator) JobSubmitDealer(com.dtstack.taier.scheduler.jobdealer.JobSubmitDealer) JobPartitioner(com.dtstack.taier.scheduler.server.JobPartitioner) ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) List(java.util.List) JobClient(com.dtstack.taier.pluginapi.JobClient) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Example 10 with ScheduleEngineJobCache

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);
    }
}
Also used : ParamAction(com.dtstack.taier.pluginapi.pojo.ParamAction) ArrayList(java.util.ArrayList) JobClient(com.dtstack.taier.pluginapi.JobClient) ScheduleEngineJobCache(com.dtstack.taier.dao.domain.ScheduleEngineJobCache)

Aggregations

ScheduleEngineJobCache (com.dtstack.taier.dao.domain.ScheduleEngineJobCache)16 ParamAction (com.dtstack.taier.pluginapi.pojo.ParamAction)6 ScheduleJob (com.dtstack.taier.dao.domain.ScheduleJob)4 JobClient (com.dtstack.taier.pluginapi.JobClient)3 JSONObject (com.alibaba.fastjson.JSONObject)2 ScheduleJobOperatorRecord (com.dtstack.taier.dao.domain.ScheduleJobOperatorRecord)2 JobIdentifier (com.dtstack.taier.pluginapi.JobIdentifier)2 TaskStatus (com.dtstack.taier.pluginapi.enums.TaskStatus)2 EngineJobCacheService (com.dtstack.taier.scheduler.service.EngineJobCacheService)2 CollectionUtils (org.apache.commons.collections.CollectionUtils)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Deleted (com.dtstack.taier.common.enums.Deleted)1 EJobCacheStage (com.dtstack.taier.common.enums.EJobCacheStage)1 OperatorType (com.dtstack.taier.common.enums.OperatorType)1 EnvironmentContext (com.dtstack.taier.common.env.EnvironmentContext)1 JobClientComparator (com.dtstack.taier.common.queue.comparator.JobClientComparator)1 ScheduleJobJob (com.dtstack.taier.dao.domain.ScheduleJobJob)1 CustomThreadFactory (com.dtstack.taier.pluginapi.CustomThreadFactory)1 JobResult (com.dtstack.taier.pluginapi.pojo.JobResult)1