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);
}
}
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);
}
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);
}
}
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;
}
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);
}
Aggregations