use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent 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.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbListenerTest method assertPostJobStatusTraceEvent.
@Test
public void assertPostJobStatusTraceEvent() {
JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(JOB_NAME, "fake_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.READY, "0", State.TASK_RUNNING, "message is empty.");
jobEventBus.post(jobStatusTraceEvent);
verify(repository, atMost(1)).addJobStatusTraceEvent(jobStatusTraceEvent);
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobStatusTraceEventsWithFields.
@Test
public void assertFindJobStatusTraceEventsWithFields() {
Map<String, Object> fields = new HashMap<>();
fields.put("jobName", "test_job_1");
Result<JobStatusTraceEvent> result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, null, fields));
assertThat(result.getTotal(), is(1));
assertThat(result.getRows().size(), is(1));
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method initStorage.
private static void initStorage() {
for (int i = 1; i <= 500; i++) {
JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job_" + i, ExecutionSource.NORMAL_TRIGGER, 0);
storage.addJobExecutionEvent(startEvent);
if (i % 2 == 0) {
JobExecutionEvent successEvent = startEvent.executionSuccess();
storage.addJobExecutionEvent(successEvent);
}
storage.addJobStatusTraceEvent(new JobStatusTraceEvent("test_job_" + i, "fake_failed_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0", State.TASK_FAILED, "message is empty."));
}
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobStatusTraceEventsWithTime.
@Test
public void assertFindJobStatusTraceEventsWithTime() {
Date now = new Date();
Date tenMinutesBefore = new Date(now.getTime() - 10 * 60 * 1000);
Result<JobStatusTraceEvent> result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, tenMinutesBefore, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, now, null, null));
assertThat(result.getTotal(), is(0));
assertThat(result.getRows().size(), is(0));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, tenMinutesBefore, null));
assertThat(result.getTotal(), is(0));
assertThat(result.getRows().size(), is(0));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, now, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, tenMinutesBefore, now, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
}
Aggregations