Search in sources :

Example 1 with TaskAssignmentResult

use of com.netflix.fenzo.TaskAssignmentResult in project elastic-job by dangdangdotcom.

the class TaskLaunchScheduledServiceTest method mockTaskAssignmentResult.

private TaskAssignmentResult mockTaskAssignmentResult(final String taskName, final ExecutionType executionType) {
    TaskAssignmentResult result = mock(TaskAssignmentResult.class);
    TaskRequest taskRequest = new JobTaskRequest(new TaskContext(taskName, Lists.newArrayList(0), executionType, "unassigned-slave"), CloudJobConfigurationBuilder.createCloudJobConfiguration(taskName));
    when(result.getTaskId()).thenReturn(String.format("%s@-@0@-@%s@-@unassigned-slave@-@0", taskName, executionType.name()));
    when(result.getHostname()).thenReturn("localhost");
    when(result.getAssignedPorts()).thenReturn(Lists.newArrayList(1234));
    when(result.getRequest()).thenReturn(taskRequest);
    when(result.isSuccessful()).thenReturn(true);
    when(result.getFitness()).thenReturn(1.0);
    return result;
}
Also used : TaskContext(com.dangdang.ddframe.job.context.TaskContext) TaskAssignmentResult(com.netflix.fenzo.TaskAssignmentResult) TaskRequest(com.netflix.fenzo.TaskRequest)

Example 2 with TaskAssignmentResult

use of com.netflix.fenzo.TaskAssignmentResult 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)

Aggregations

TaskContext (com.dangdang.ddframe.job.context.TaskContext)2 TaskAssignmentResult (com.netflix.fenzo.TaskAssignmentResult)2 ByteString (com.google.protobuf.ByteString)1 TaskRequest (com.netflix.fenzo.TaskRequest)1 ArrayList (java.util.ArrayList)1 Protos (org.apache.mesos.Protos)1 TaskInfo (org.apache.mesos.Protos.TaskInfo)1