use of org.apache.gobblin.rest.JobExecutionInfo in project incubator-gobblin by apache.
the class DatabaseJobHistoryStoreV101 method getJobExecutionInfos.
private Map<String, JobExecutionInfo> getJobExecutionInfos(Connection connection, List<String> jobIds) throws SQLException {
Map<String, JobExecutionInfo> jobExecutionInfos = Maps.newLinkedHashMap();
if (jobIds != null && jobIds.size() > 0) {
String template = String.format(JOB_EXECUTION_QUERY_BY_JOB_ID_STATEMENT_TEMPLATE, getInPredicate(jobIds.size()));
int index = 1;
try (PreparedStatement jobExecutionQueryStatement = connection.prepareStatement(template)) {
for (String jobId : jobIds) {
jobExecutionQueryStatement.setString(index++, jobId);
}
try (ResultSet jobRs = jobExecutionQueryStatement.executeQuery()) {
while (jobRs.next()) {
JobExecutionInfo jobExecutionInfo = resultSetToJobExecutionInfo(jobRs);
jobExecutionInfos.put(jobExecutionInfo.getJobId(), jobExecutionInfo);
}
}
}
}
return jobExecutionInfos;
}
use of org.apache.gobblin.rest.JobExecutionInfo in project incubator-gobblin by apache.
the class DatabaseJobHistoryStoreTest method testQueryByJobName.
@Test(dependsOnMethods = { "testUpdate" })
public void testQueryByJobName() throws IOException {
JobExecutionQuery queryByJobName = new JobExecutionQuery();
queryByJobName.setIdType(QueryIdTypeEnum.JOB_NAME);
queryByJobName.setId(JobExecutionQuery.Id.create(this.expectedJobExecutionInfos.get(0).getJobName()));
List<JobExecutionInfo> result = this.jobHistoryStore.get(queryByJobName);
Assert.assertEquals(result.size(), 1);
JobExecutionInfo actual = result.get(0);
JobExecutionInfo expected = this.expectedJobExecutionInfos.get(0);
assertJobExecution(actual, expected);
}
use of org.apache.gobblin.rest.JobExecutionInfo in project incubator-gobblin by apache.
the class DatabaseJobHistoryStoreTest method testUpdate.
@Test(dependsOnMethods = { "testInsert" })
public void testUpdate() throws IOException {
for (JobExecutionInfo jobExecutionInfo : this.expectedJobExecutionInfos) {
jobExecutionInfo.setEndTime(System.currentTimeMillis());
jobExecutionInfo.setDuration(jobExecutionInfo.getEndTime() - jobExecutionInfo.getStartTime());
jobExecutionInfo.setState(JobStateEnum.COMMITTED);
jobExecutionInfo.setCompletedTasks(jobExecutionInfo.getLaunchedTasks());
for (TaskExecutionInfo taskExecutionInfo : jobExecutionInfo.getTaskExecutions()) {
taskExecutionInfo.setEndTime(jobExecutionInfo.getEndTime());
taskExecutionInfo.setDuration(taskExecutionInfo.getEndTime() - taskExecutionInfo.getStartTime());
taskExecutionInfo.setState(TaskStateEnum.COMMITTED);
}
this.jobHistoryStore.put(jobExecutionInfo);
}
}
use of org.apache.gobblin.rest.JobExecutionInfo in project incubator-gobblin by apache.
the class DatabaseJobHistoryStoreTest method testQueryByTable.
@Test(dependsOnMethods = { "testUpdate" })
public void testQueryByTable() throws IOException {
JobExecutionQuery queryByTable = new JobExecutionQuery();
queryByTable.setIdType(QueryIdTypeEnum.TABLE);
queryByTable.setId(JobExecutionQuery.Id.create(this.expectedJobExecutionInfos.get(0).getTaskExecutions().get(0).getTable()));
List<JobExecutionInfo> result = this.jobHistoryStore.get(queryByTable);
Assert.assertEquals(result.size(), 2);
JobExecutionInfo actual = result.get(0);
Assert.assertEquals(actual.getJobName(), this.expectedJobExecutionInfos.get(0).getJobName());
Assert.assertEquals(actual.getJobId(), this.expectedJobExecutionInfos.get(0).getJobId());
Assert.assertEquals(actual.getTaskExecutions().size(), 1);
Assert.assertEquals(actual.getTaskExecutions().get(0).getTable(), this.expectedJobExecutionInfos.get(0).getTaskExecutions().get(0).getTable());
actual = result.get(1);
Assert.assertEquals(actual.getJobName(), this.expectedJobExecutionInfos.get(1).getJobName());
Assert.assertEquals(actual.getJobId(), this.expectedJobExecutionInfos.get(1).getJobId());
Assert.assertEquals(actual.getTaskExecutions().size(), 1);
Assert.assertEquals(actual.getTaskExecutions().get(0).getTable(), this.expectedJobExecutionInfos.get(1).getTaskExecutions().get(0).getTable());
queryByTable.setId(JobExecutionQuery.Id.create(this.expectedJobExecutionInfos.get(1).getTaskExecutions().get(1).getTable()));
result = this.jobHistoryStore.get(queryByTable);
Assert.assertEquals(result.size(), 1);
actual = result.get(0);
Assert.assertEquals(actual.getJobName(), this.expectedJobExecutionInfos.get(1).getJobName());
Assert.assertEquals(actual.getJobId(), this.expectedJobExecutionInfos.get(1).getJobId());
Assert.assertEquals(result.size(), 1);
Assert.assertEquals(actual.getTaskExecutions().size(), 1);
Assert.assertEquals(actual.getTaskExecutions().get(0).getTable(), this.expectedJobExecutionInfos.get(1).getTaskExecutions().get(1).getTable());
}
Aggregations