use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class TaskLaunchScheduledService method getTaskInfoList.
private List<Protos.TaskInfo> getTaskInfoList(final Collection<String> integrityViolationJobs, final VMAssignmentResult vmAssignmentResult, final String hostname, final Protos.SlaveID slaveId) {
List<Protos.TaskInfo> result = new ArrayList<>(vmAssignmentResult.getTasksAssigned().size());
for (TaskAssignmentResult each : vmAssignmentResult.getTasksAssigned()) {
TaskContext taskContext = TaskContext.from(each.getTaskId());
String jobName = taskContext.getMetaInfo().getJobName();
if (!integrityViolationJobs.contains(jobName) && !facadeService.isRunning(taskContext) && !facadeService.isJobDisabled(jobName)) {
Protos.TaskInfo taskInfo = getTaskInfo(slaveId, each);
if (null != taskInfo) {
result.add(taskInfo);
facadeService.addMapping(taskInfo.getTaskId().getValue(), hostname);
taskScheduler.getTaskAssigner().call(each.getRequest(), hostname);
}
}
}
return result;
}
use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class TaskLaunchScheduledService method createJobStatusTraceEvent.
private JobStatusTraceEvent createJobStatusTraceEvent(final TaskContext taskContext) {
TaskContext.MetaInfo metaInfo = taskContext.getMetaInfo();
JobStatusTraceEvent result = new JobStatusTraceEvent(metaInfo.getJobName(), taskContext.getId(), taskContext.getSlaveId(), Source.CLOUD_SCHEDULER, taskContext.getType(), String.valueOf(metaInfo.getShardingItems()), JobStatusTraceEvent.State.TASK_STAGING, "");
if (ExecutionType.FAILOVER == taskContext.getType()) {
Optional<String> taskContextOptional = facadeService.getFailoverTaskId(metaInfo);
if (taskContextOptional.isPresent()) {
result.setOriginalTaskId(taskContextOptional.get());
}
}
return result;
}
use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class ProducerManager method unschedule.
/**
* 停止调度作业.
*
* @param jobName 作业名称
*/
public void unschedule(final String jobName) {
for (TaskContext each : runningService.getRunningTasks(jobName)) {
schedulerDriver.killTask(Protos.TaskID.newBuilder().setValue(each.getId()).build());
}
runningService.remove(jobName);
readyService.remove(Lists.newArrayList(jobName));
}
use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class FacadeServiceTest method assertUpdateDaemonStatus.
@Test
public void assertUpdateDaemonStatus() {
TaskContext taskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue());
facadeService.updateDaemonStatus(taskContext, true);
verify(runningService).updateIdle(taskContext, true);
}
Aggregations