5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-09 03:10:31 +08:00

SQOOP-807: Verify whether job object can be safely removed prior removing

(Jarek Jarcec Cecho via Cheolsoo Park)
This commit is contained in:
Cheolsoo Park 2013-01-09 12:21:25 -08:00
parent b9842ebe04
commit 4f8eb43732
3 changed files with 27 additions and 2 deletions

View File

@ -717,8 +717,13 @@ public boolean existsJob(long id, Connection conn) {
@Override
public boolean inUseJob(long jobId, Connection conn) {
// TODO(jarcec): This method will need to be upgraded once submission
// engine will be in place as we can't remove "running" job.
MSubmission submission = findSubmissionLastForJob(jobId, conn);
// We can't remove running job
if(submission.getStatus().isRunning()) {
return true;
}
return false;
}

View File

@ -147,6 +147,16 @@ public void testCreateConnection() throws Exception {
assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 8);
}
public void testInUseConnection() throws Exception {
loadConnections();
assertFalse(handler.inUseConnection(1, getDerbyConnection()));
loadJobs();
assertTrue(handler.inUseConnection(1, getDerbyConnection()));
}
public void testUpdateConnection() throws Exception {
loadConnections();

View File

@ -125,6 +125,16 @@ public void testExistsJob() throws Exception {
assertFalse(handler.existsJob(5, getDerbyConnection()));
}
public void testInUseJob() throws Exception {
loadJobs();
loadSubmissions();
assertTrue(handler.inUseJob(1, getDerbyConnection()));
assertFalse(handler.inUseJob(2, getDerbyConnection()));
assertFalse(handler.inUseJob(3, getDerbyConnection()));
assertFalse(handler.inUseJob(4, getDerbyConnection()));
}
public void testCreateJob() throws Exception {
MJob job = getJob();