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