Search in sources :

Example 1 with CloudJobConfiguration

use of com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration in project elastic-job by dangdangdotcom.

the class FacadeService method recordFailoverTask.

/**
     * 记录失效转移队列.
     * 
     * @param taskContext 任务上下文
     */
public void recordFailoverTask(final TaskContext taskContext) {
    Optional<CloudJobConfiguration> jobConfigOptional = jobConfigService.load(taskContext.getMetaInfo().getJobName());
    if (!jobConfigOptional.isPresent()) {
        return;
    }
    CloudJobConfiguration jobConfig = jobConfigOptional.get();
    if (jobConfig.getTypeConfig().getCoreConfig().isFailover() || CloudJobExecutionType.DAEMON == jobConfig.getJobExecutionType()) {
        failoverService.add(taskContext);
    }
}
Also used : CloudJobConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration)

Example 2 with CloudJobConfiguration

use of com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration in project elastic-job by dangdangdotcom.

the class TaskLaunchScheduledService method getTaskInfo.

private Protos.TaskInfo getTaskInfo(final Protos.SlaveID slaveID, final TaskAssignmentResult taskAssignmentResult) {
    TaskContext taskContext = TaskContext.from(taskAssignmentResult.getTaskId());
    Optional<CloudJobConfiguration> jobConfigOptional = facadeService.load(taskContext.getMetaInfo().getJobName());
    if (!jobConfigOptional.isPresent()) {
        return null;
    }
    CloudJobConfiguration jobConfig = jobConfigOptional.get();
    Optional<CloudAppConfiguration> appConfigOptional = facadeService.loadAppConfig(jobConfig.getAppName());
    if (!appConfigOptional.isPresent()) {
        return null;
    }
    CloudAppConfiguration appConfig = appConfigOptional.get();
    taskContext.setSlaveId(slaveID.getValue());
    ShardingContexts shardingContexts = getShardingContexts(taskContext, appConfig, jobConfig);
    boolean useDefaultExecutor = CloudJobExecutionType.TRANSIENT == jobConfig.getJobExecutionType() && JobType.SCRIPT == jobConfig.getTypeConfig().getJobType();
    Protos.CommandInfo.URI uri = buildURI(appConfig, useDefaultExecutor);
    Protos.CommandInfo command = buildCommand(uri, appConfig.getBootstrapScript(), shardingContexts, useDefaultExecutor);
    return buildTaskInfo(taskContext, appConfig, jobConfig, shardingContexts, slaveID, command, useDefaultExecutor);
}
Also used : CloudAppConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.app.CloudAppConfiguration) TaskContext(com.dangdang.ddframe.job.context.TaskContext) CloudJobConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration) Protos(org.apache.mesos.Protos) ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts)

Example 3 with CloudJobConfiguration

use of com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration in project elastic-job by dangdangdotcom.

the class ProducerManager method startup.

/**
     * 启动作业调度器.
     */
public void startup() {
    log.info("Start producer manager");
    transientProducerScheduler.start();
    for (CloudJobConfiguration each : configService.loadAll()) {
        schedule(each);
    }
}
Also used : CloudJobConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration)

Example 4 with CloudJobConfiguration

use of com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration in project elastic-job by dangdangdotcom.

the class FailoverService method getAllEligibleJobContexts.

/**
     * 从失效转移队列中获取所有有资格执行的作业上下文.
     *
     * @return 有资格执行的作业上下文集合
     */
public Collection<JobContext> getAllEligibleJobContexts() {
    if (!regCenter.isExisted(FailoverNode.ROOT)) {
        return Collections.emptyList();
    }
    List<String> jobNames = regCenter.getChildrenKeys(FailoverNode.ROOT);
    Collection<JobContext> result = new ArrayList<>(jobNames.size());
    Set<HashCode> assignedTasks = new HashSet<>(jobNames.size() * 10, 1);
    for (String each : jobNames) {
        List<String> taskIdList = regCenter.getChildrenKeys(FailoverNode.getFailoverJobNodePath(each));
        if (taskIdList.isEmpty()) {
            regCenter.remove(FailoverNode.getFailoverJobNodePath(each));
            continue;
        }
        Optional<CloudJobConfiguration> jobConfig = configService.load(each);
        if (!jobConfig.isPresent()) {
            regCenter.remove(FailoverNode.getFailoverJobNodePath(each));
            continue;
        }
        List<Integer> assignedShardingItems = getAssignedShardingItems(each, taskIdList, assignedTasks);
        if (!assignedShardingItems.isEmpty()) {
            if (jobConfig.isPresent()) {
                result.add(new JobContext(jobConfig.get(), assignedShardingItems, ExecutionType.FAILOVER));
            }
        }
    }
    return result;
}
Also used : HashCode(com.google.common.hash.HashCode) CloudJobConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration) ArrayList(java.util.ArrayList) JobContext(com.dangdang.ddframe.job.cloud.scheduler.context.JobContext) HashSet(java.util.HashSet)

Example 5 with CloudJobConfiguration

use of com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration in project elastic-job by dangdangdotcom.

the class StatisticManager method getJobTypeStatistics.

/**
     * 获取作业类型统计数据.
     * 
     * @return 作业类型统计数据对象
     */
public JobTypeStatistics getJobTypeStatistics() {
    int scriptJobCnt = 0;
    int simpleJobCnt = 0;
    int dataflowJobCnt = 0;
    for (CloudJobConfiguration each : configurationService.loadAll()) {
        if (JobType.SCRIPT.equals(each.getTypeConfig().getJobType())) {
            scriptJobCnt++;
        } else if (JobType.SIMPLE.equals(each.getTypeConfig().getJobType())) {
            simpleJobCnt++;
        } else if (JobType.DATAFLOW.equals(each.getTypeConfig().getJobType())) {
            dataflowJobCnt++;
        }
    }
    return new JobTypeStatistics(scriptJobCnt, simpleJobCnt, dataflowJobCnt);
}
Also used : CloudJobConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration) JobTypeStatistics(com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics)

Aggregations

CloudJobConfiguration (com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration)7 CloudAppConfiguration (com.dangdang.ddframe.job.cloud.scheduler.config.app.CloudAppConfiguration)1 JobContext (com.dangdang.ddframe.job.cloud.scheduler.context.JobContext)1 TaskContext (com.dangdang.ddframe.job.context.TaskContext)1 ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)1 JobExecutionTypeStatistics (com.dangdang.ddframe.job.statistics.type.job.JobExecutionTypeStatistics)1 JobTypeStatistics (com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics)1 HashCode (com.google.common.hash.HashCode)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Protos (org.apache.mesos.Protos)1 Test (org.junit.Test)1