Search in sources :

Example 11 with JobStatusTraceEvent

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

Example 12 with JobStatusTraceEvent

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

Example 13 with 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));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) HashMap(java.util.HashMap) JobStatusTraceEvent(com.dangdang.ddframe.job.event.type.JobStatusTraceEvent) Test(org.junit.Test)

Example 14 with JobStatusTraceEvent

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."));
    }
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) JobStatusTraceEvent(com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)

Example 15 with JobStatusTraceEvent

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));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobStatusTraceEvent(com.dangdang.ddframe.job.event.type.JobStatusTraceEvent) Date(java.util.Date) Test(org.junit.Test)

Aggregations

JobStatusTraceEvent (com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)18 Test (org.junit.Test)11 Condition (com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition)8 TaskContext (com.dangdang.ddframe.job.context.TaskContext)4 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 JobExecutionEvent (com.dangdang.ddframe.job.event.type.JobExecutionEvent)1 ByteString (com.google.protobuf.ByteString)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1