use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class FacadeServiceTest method assertAddRunning.
@Test
public void assertAddRunning() {
TaskContext taskContext = TaskContext.from(TaskNode.builder().build().getTaskNodeValue());
facadeService.addRunning(taskContext);
verify(runningService).add(taskContext);
}
use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class FacadeServiceTest method assertGetFailoverTaskId.
@Test
public void assertGetFailoverTaskId() {
TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
TaskContext taskContext = TaskContext.from(taskNode.getTaskNodeValue());
facadeService.recordFailoverTask(taskContext);
verify(failoverService).add(taskContext);
facadeService.getFailoverTaskId(taskContext.getMetaInfo());
when(facadeService.getFailoverTaskId(taskContext.getMetaInfo())).thenReturn(Optional.of(taskNode.getTaskNodePath()));
verify(failoverService).getTaskId(taskContext.getMetaInfo());
}
use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class FacadeServiceTest method assertRecordFailoverTaskWhenIsFailoverEnabled.
@Test
public void assertRecordFailoverTaskWhenIsFailoverEnabled() {
TaskNode taskNode = TaskNode.builder().type(ExecutionType.FAILOVER).build();
when(jobConfigService.load("test_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("test_job")));
TaskContext taskContext = TaskContext.from(taskNode.getTaskNodeValue());
facadeService.recordFailoverTask(taskContext);
verify(failoverService).add(taskContext);
}
use of com.dangdang.ddframe.job.context.TaskContext in project elastic-job by dangdangdotcom.
the class CloudJobFacade method postJobStatusTraceEvent.
@Override
public void postJobStatusTraceEvent(final String taskId, final State state, final String message) {
TaskContext taskContext = TaskContext.from(taskId);
jobEventBus.post(new JobStatusTraceEvent(taskContext.getMetaInfo().getJobName(), taskContext.getId(), taskContext.getSlaveId(), Source.CLOUD_EXECUTOR, taskContext.getType(), String.valueOf(taskContext.getMetaInfo().getShardingItems()), state, message));
}
use of com.dangdang.ddframe.job.context.TaskContext 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;
}
Aggregations