sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cheol...@apache.org
Subject git commit: SQOOP-807: Verify whether job object can be safely removed prior removing
Date Wed, 09 Jan 2013 20:22:42 GMT
Updated Branches:
  refs/heads/sqoop2 b9842ebe0 -> 4f8eb4373


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

(Jarek Jarcec Cecho via Cheolsoo Park)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/4f8eb437
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/4f8eb437
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/4f8eb437

Branch: refs/heads/sqoop2
Commit: 4f8eb43732382ba3bbd9b2ed28082964dae4b79e
Parents: b9842eb
Author: Cheolsoo Park <cheolsoo@apache.org>
Authored: Wed Jan 9 12:21:25 2013 -0800
Committer: Cheolsoo Park <cheolsoo@apache.org>
Committed: Wed Jan 9 12:21:25 2013 -0800

----------------------------------------------------------------------
 .../repository/derby/DerbyRepositoryHandler.java   |    9 +++++++--
 .../repository/derby/TestConnectionHandling.java   |   10 ++++++++++
 .../sqoop/repository/derby/TestJobHandling.java    |   10 ++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/4f8eb437/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index c62730c..9793898 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -717,8 +717,13 @@ public class DerbyRepositoryHandler implements JdbcRepositoryHandler
{
 
   @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;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/4f8eb437/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
index 4121be7..8266b46 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestConnectionHandling.java
@@ -147,6 +147,16 @@ public class TestConnectionHandling extends DerbyTestCase {
     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();
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/4f8eb437/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
index c0e7a31..4c97e1e 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestJobHandling.java
@@ -125,6 +125,16 @@ public class TestJobHandling extends DerbyTestCase {
     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();
 


Mime
View raw message