use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearch method getJobStatusTraceEvents.
private List<JobStatusTraceEvent> getJobStatusTraceEvents(final Condition condition) {
List<JobStatusTraceEvent> result = new LinkedList<>();
try (Connection conn = dataSource.getConnection();
PreparedStatement preparedStatement = createDataPreparedStatement(conn, TABLE_JOB_STATUS_TRACE_LOG, FIELDS_JOB_STATUS_TRACE_LOG, condition);
ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent(resultSet.getString(1), resultSet.getString(2), resultSet.getString(3), resultSet.getString(4), resultSet.getString(5), Source.valueOf(resultSet.getString(6)), ExecutionType.valueOf(resultSet.getString(7)), resultSet.getString(8), State.valueOf(resultSet.getString(9)), resultSet.getString(10), new Date(resultSet.getTimestamp(11).getTime()));
result.add(jobStatusTraceEvent);
}
} catch (final SQLException ex) {
// TODO 记录失败直接输出日志,未来可考虑配置化
log.error("Fetch JobStatusTraceEvent from DB error:", ex);
}
return result;
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobStatusTraceEventsWithErrorFields.
@Test
public void assertFindJobStatusTraceEventsWithErrorFields() {
Map<String, Object> fields = new HashMap<>();
fields.put("notExistField", "some value");
Result<JobStatusTraceEvent> result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, null, fields));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbStorageTest method assertAddJobStatusTraceEventWhenFailoverWithTaskStagingState.
@Test
public void assertAddJobStatusTraceEventWhenFailoverWithTaskStagingState() throws SQLException {
JobStatusTraceEvent jobStatusTraceEvent = new JobStatusTraceEvent("test_job", "fake_failover_task_id", "fake_slave_id", Source.LITE_EXECUTOR, ExecutionType.FAILOVER, "0", State.TASK_STAGING, "message is empty.");
jobStatusTraceEvent.setOriginalTaskId("original_fake_failover_task_id");
assertThat(storage.getJobStatusTraceEvents("fake_failover_task_id").size(), is(0));
storage.addJobStatusTraceEvent(jobStatusTraceEvent);
assertThat(storage.getJobStatusTraceEvents("fake_failover_task_id").size(), is(1));
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobStatusTraceEventsWithErrorPageSizeAndNumber.
@Test
public void assertFindJobStatusTraceEventsWithErrorPageSizeAndNumber() {
Result<JobStatusTraceEvent> result = repository.findJobStatusTraceEvents(new Condition(-1, -1, null, null, null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
}
use of com.dangdang.ddframe.job.event.type.JobStatusTraceEvent in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobStatusTraceEventsWithPageSizeAndNumber.
@Test
public void assertFindJobStatusTraceEventsWithPageSizeAndNumber() {
Result<JobStatusTraceEvent> result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobStatusTraceEvents(new Condition(50, 1, null, null, null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(50));
result = repository.findJobStatusTraceEvents(new Condition(100, 5, null, null, null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(100));
result = repository.findJobStatusTraceEvents(new Condition(100, 6, null, null, null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(0));
}
Aggregations