Search in sources :

Example 6 with TaskContext

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

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

Example 8 with TaskContext

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

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

Example 10 with TaskContext

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

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