Search in sources :

Example 16 with TaskContext

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;
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) TaskContext(com.dangdang.ddframe.job.context.TaskContext) Protos(org.apache.mesos.Protos) ArrayList(java.util.ArrayList) TaskAssignmentResult(com.netflix.fenzo.TaskAssignmentResult) ByteString(com.google.protobuf.ByteString) TaskInfo(org.apache.mesos.Protos.TaskInfo)

Example 17 with TaskContext

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;
}
Also used : TaskContext(com.dangdang.ddframe.job.context.TaskContext) JobStatusTraceEvent(com.dangdang.ddframe.job.event.type.JobStatusTraceEvent) ByteString(com.google.protobuf.ByteString)

Example 18 with TaskContext

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));
}
Also used : TaskContext(com.dangdang.ddframe.job.context.TaskContext)

Example 19 with TaskContext

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);
}
Also used : TaskContext(com.dangdang.ddframe.job.context.TaskContext) Test(org.junit.Test)

Aggregations

TaskContext (com.dangdang.ddframe.job.context.TaskContext)19 Test (org.junit.Test)9 JobStatusTraceEvent (com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)4 ArrayList (java.util.ArrayList)3 Protos (org.apache.mesos.Protos)3 TaskNode (com.dangdang.ddframe.job.cloud.scheduler.fixture.TaskNode)2 ByteString (com.google.protobuf.ByteString)2 TaskAssignmentResult (com.netflix.fenzo.TaskAssignmentResult)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 TaskInfo (org.apache.mesos.Protos.TaskInfo)2 CloudAppConfiguration (com.dangdang.ddframe.job.cloud.scheduler.config.app.CloudAppConfiguration)1 CloudJobConfiguration (com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration)1 RunningService (com.dangdang.ddframe.job.cloud.scheduler.state.running.RunningService)1 ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)1 JobRunningStatistics (com.dangdang.ddframe.job.statistics.type.job.JobRunningStatistics)1 TaskRunningStatistics (com.dangdang.ddframe.job.statistics.type.task.TaskRunningStatistics)1 Function (com.google.common.base.Function)1 TaskRequest (com.netflix.fenzo.TaskRequest)1 VMAssignmentResult (com.netflix.fenzo.VMAssignmentResult)1