sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject git commit: SQOOP-1651: Sqoop2: Cleanup: Naming and ordering of methods in Repo relates classes
Date Sun, 02 Nov 2014 17:52:46 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 184f02464 -> eda085895


SQOOP-1651: Sqoop2: Cleanup: Naming and ordering of methods in Repo relates classes

(Veena Basavaraj via Abraham Elmahrek)


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

Branch: refs/heads/sqoop2
Commit: eda0858956cef2d8190065cb4b16647a35623a98
Parents: 184f024
Author: Abraham <abraham@elmahrek.com>
Authored: Sun Nov 2 09:51:22 2014 -0800
Committer: Abraham <abraham@elmahrek.com>
Committed: Sun Nov 2 09:52:12 2014 -0800

----------------------------------------------------------------------
 .../org/apache/sqoop/driver/JobManager.java     |  8 +-
 .../apache/sqoop/repository/JdbcRepository.java | 80 ++++++++++----------
 .../sqoop/repository/JdbcRepositoryHandler.java |  8 +-
 .../org/apache/sqoop/repository/Repository.java | 38 +++++-----
 .../derby/DerbyRepositoryHandler.java           | 18 ++---
 .../derby/TestSubmissionHandling.java           | 18 ++---
 6 files changed, 83 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/eda08589/core/src/main/java/org/apache/sqoop/driver/JobManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/JobManager.java b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
index f6447c6..ba56c77 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
@@ -279,7 +279,7 @@ public class JobManager implements Reconfigurable {
     // only if it's not.
     synchronized (getClass()) {
       MSubmission lastSubmission = RepositoryManager.getInstance().getRepository()
-          .findSubmissionLastForJob(jobId);
+          .findLastSubmissionForJob(jobId);
       if (lastSubmission != null && lastSubmission.getStatus().isRunning()) {
         throw new SqoopException(DriverError.DRIVER_0002, "Job with id " + jobId);
       }
@@ -530,7 +530,7 @@ public class JobManager implements Reconfigurable {
   public MSubmission stop(long jobId, HttpEventContext ctx) {
 
     Repository repository = RepositoryManager.getInstance().getRepository();
-    MSubmission mSubmission = repository.findSubmissionLastForJob(jobId);
+    MSubmission mSubmission = repository.findLastSubmissionForJob(jobId);
 
     if (mSubmission == null || !mSubmission.getStatus().isRunning()) {
       throw new SqoopException(DriverError.DRIVER_0003, "Job with id " + jobId
@@ -549,7 +549,7 @@ public class JobManager implements Reconfigurable {
 
   public MSubmission status(long jobId) {
     Repository repository = RepositoryManager.getInstance().getRepository();
-    MSubmission mSubmission = repository.findSubmissionLastForJob(jobId);
+    MSubmission mSubmission = repository.findLastSubmissionForJob(jobId);
 
     if (mSubmission == null) {
       return new MSubmission(jobId, new Date(), SubmissionStatus.NEVER_EXECUTED);
@@ -681,7 +681,7 @@ public class JobManager implements Reconfigurable {
           // Let's get all running submissions from repository to check them out
           List<MSubmission> unfinishedSubmissions =
             RepositoryManager.getInstance().getRepository()
-              .findSubmissionsUnfinished();
+              .findUnfinishedSubmissions();
 
           for (MSubmission submission : unfinishedSubmissions) {
             update(submission);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/eda08589/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
index 2aeb07e..976223d 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -388,6 +388,20 @@ public class JdbcRepository extends Repository {
   /**
    * {@inheritDoc}
    */
+  @SuppressWarnings("unchecked")
+  @Override
+  public List<MLink> findLinksForConnector(final long connectorId) {
+    return (List<MLink>) doWithConnection(new DoWithConnection() {
+      @Override
+      public Object doIt(Connection conn) throws Exception {
+        return handler.findLinksForConnector(connectorId, conn);
+      }
+    });
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void createJob(final MJob job) {
     doWithConnection(new DoWithConnection() {
@@ -460,13 +474,11 @@ public class JdbcRepository extends Repository {
     doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) {
-        if(!handler.existsJob(id, conn)) {
-          throw new SqoopException(RepositoryError.JDBCREPO_0020,
-            "Invalid id: " + id);
+        if (!handler.existsJob(id, conn)) {
+          throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + id);
         }
-        if(handler.inUseJob(id, conn)) {
-          throw new SqoopException(RepositoryError.JDBCREPO_0022,
-            "Id in use: " + id);
+        if (handler.inUseJob(id, conn)) {
+          throw new SqoopException(RepositoryError.JDBCREPO_0022, "Id in use: " + id);
         }
 
         handler.deleteJob(id, conn);
@@ -505,6 +517,20 @@ public class JdbcRepository extends Repository {
   /**
    * {@inheritDoc}
    */
+  @SuppressWarnings("unchecked")
+  @Override
+  public List<MJob> findJobsForConnector(final long connectorId) {
+    return (List<MJob>) doWithConnection(new DoWithConnection() {
+      @Override
+      public Object doIt(Connection conn) throws Exception {
+        return handler.findJobsForConnector(connectorId, conn);
+      }
+    });
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   @Override
   public void createSubmission(final MSubmission submission) {
     doWithConnection(new DoWithConnection() {
@@ -513,7 +539,6 @@ public class JdbcRepository extends Repository {
         if(submission.hasPersistenceId()) {
           throw new SqoopException(RepositoryError.JDBCREPO_0023);
         }
-
         handler.createSubmission(submission, conn);
         return null;
       }
@@ -561,11 +586,11 @@ public class JdbcRepository extends Repository {
    */
   @SuppressWarnings("unchecked")
   @Override
-  public List<MSubmission> findSubmissionsUnfinished() {
+  public List<MSubmission> findUnfinishedSubmissions() {
     return (List<MSubmission>) doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) {
-        return handler.findSubmissionsUnfinished(conn);
+        return handler.findUnfinishedSubmissions(conn);
       }
     });
   }
@@ -606,43 +631,14 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
-  public MSubmission findSubmissionLastForJob(final long jobId) {
+  public MSubmission findLastSubmissionForJob(final long jobId) {
     return (MSubmission) doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) {
-        if(!handler.existsJob(jobId, conn)) {
-          throw new SqoopException(RepositoryError.JDBCREPO_0020,
-            "Invalid id: " + jobId);
+        if (!handler.existsJob(jobId, conn)) {
+          throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
         }
-        return handler.findSubmissionLastForJob(jobId, conn);
-      }
-    });
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @SuppressWarnings("unchecked")
-  @Override
-  public List<MLink> findLinksForConnector(final long connectorId) {
-    return (List<MLink>) doWithConnection(new DoWithConnection() {
-      @Override
-      public Object doIt(Connection conn) throws Exception {
-        return handler.findLinksForConnector(connectorId, conn);
-      }
-    });
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @SuppressWarnings("unchecked")
-  @Override
-  public List<MJob> findJobsForConnector(final long connectorId) {
-    return (List<MJob>) doWithConnection(new DoWithConnection() {
-      @Override
-      public Object doIt(Connection conn) throws Exception {
-        return handler.findJobsForConnector(connectorId, conn);
+        return handler.findLastSubmissionForJob(jobId, conn);
       }
     });
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/eda08589/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
index ad380d3..1e22759 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
@@ -330,7 +330,7 @@ public abstract class JdbcRepositoryHandler {
    *
    * @param jobId Job id
    * @param conn Connection to the repository
-   * @return Deserialized config of the job that is present in the repository
+   * @return job for a given id that is present in the repository
    */
   public abstract MJob findJob(long jobId, Connection conn);
 
@@ -343,7 +343,7 @@ public abstract class JdbcRepositoryHandler {
   public abstract List<MJob> findJobs(Connection conn);
 
   /**
-   * Save given submission in repository.
+   * Save given submission associates with a job in repository.
    *
    * @param submission Submission object
    * @param conn Connection to the repository
@@ -380,7 +380,7 @@ public abstract class JdbcRepositoryHandler {
    * @param conn Connection to the repository
    * @return List of unfinished submissions.
    */
-  public abstract List<MSubmission> findSubmissionsUnfinished(Connection conn);
+  public abstract List<MSubmission> findUnfinishedSubmissions(Connection conn);
 
   /**
    * Return list of all submissions from the repository.
@@ -405,5 +405,5 @@ public abstract class JdbcRepositoryHandler {
    * @param conn Connection to the repository
    * @return Most recent submission
    */
-  public abstract MSubmission findSubmissionLastForJob(long jobId, Connection conn);
+  public abstract MSubmission findLastSubmissionForJob(long jobId, Connection conn);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/eda08589/core/src/main/java/org/apache/sqoop/repository/Repository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/Repository.java b/core/src/main/java/org/apache/sqoop/repository/Repository.java
index 79742b9..09989e0 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -115,7 +115,7 @@ public abstract class Repository {
   /**
    * Get all connectors in repository
    *
-   * @return List will all connectors in repository
+   * @return List with all connectors in repository
    */
   public abstract List<MConnector> findConnectors();
 
@@ -189,6 +189,13 @@ public abstract class Repository {
   public abstract MLink findLink(String name);
 
   /**
+   * Retrieve links which use the given connector.
+   * @param connectorId Connector id whose links should be fetched
+   * @return List of MLink that use <code>connectorId</code>.
+   */
+  public abstract List<MLink> findLinksForConnector(long connectorId);
+
+  /**
    * Get all Link objects.
    *
    * @return List will all saved link objects
@@ -242,7 +249,7 @@ public abstract class Repository {
    * Find job object with given id.
    *
    * @param id Job id
-   * @return Deserialized config of job loaded from repository
+   * @return job with given id loaded from repository
    */
   public abstract MJob findJob(long id);
 
@@ -254,6 +261,14 @@ public abstract class Repository {
   public abstract List<MJob> findJobs();
 
   /**
+   * Retrieve jobs which use the given link.
+   *
+   * @param connectorId Connector ID whose jobs should be fetched
+   * @return List of MJobs that use <code>linkID</code>.
+   */
+  public abstract List<MJob> findJobsForConnector(long connectorId);
+
+  /**
    * Create new submission record in repository.
    *
    * @param submission Submission object that should be serialized to repository
@@ -279,7 +294,7 @@ public abstract class Repository {
    *
    * @return List of unfinished submissions
    */
-  public abstract List<MSubmission> findSubmissionsUnfinished();
+  public abstract List<MSubmission> findUnfinishedSubmissions();
 
   /**
    * Return all submissions from repository
@@ -301,22 +316,7 @@ public abstract class Repository {
    * @param jobId Job id
    * @return Most recent submission
    */
-  public abstract MSubmission findSubmissionLastForJob(long jobId);
-
-  /**
-   * Retrieve links which use the given connector.
-   * @param connectorId Connector ID whose links should be fetched
-   * @return List of MLink that use <code>connectorID</code>.
-   */
-  public abstract List<MLink> findLinksForConnector(long connectorId);
-
-  /**
-   * Retrieve jobs which use the given link.
-   *
-   * @param connectorId Connector ID whose jobs should be fetched
-   * @return List of MJobs that use <code>linkID</code>.
-   */
-  public abstract List<MJob> findJobsForConnector(long connectorId);
+  public abstract MSubmission findLastSubmissionForJob(long jobId);
 
   /**
    * Update the connector with the new data supplied in the

http://git-wip-us.apache.org/repos/asf/sqoop/blob/eda08589/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 b996a0b..b324f4f 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
@@ -1205,9 +1205,9 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
 
       List<MLink> links = loadLinks(linkFetchStmt, conn);
 
-      if(links.size() != 1) {
-        throw new SqoopException(DerbyRepoError.DERBYREPO_0024, "Couldn't find"
-          + " link with id " + linkId);
+      if (links.size() != 1) {
+        throw new SqoopException(DerbyRepoError.DERBYREPO_0024, "Couldn't find link with
id "
+            + linkId);
       }
 
       // Return the first and only one link object with the given id
@@ -1492,7 +1492,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
 
   @Override
   public boolean inUseJob(long jobId, Connection conn) {
-    MSubmission submission = findSubmissionLastForJob(jobId, conn);
+    MSubmission submission = findLastSubmissionForJob(jobId, conn);
 
     // We have no submissions and thus job can't be in use
     if(submission == null) {
@@ -1573,9 +1573,9 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
 
       List<MJob> jobs = loadJobs(stmt, conn);
 
-      if(jobs.size() != 1) {
-        throw new SqoopException(DerbyRepoError.DERBYREPO_0030, "Couldn't find"
-          + " job with id " + id);
+      if (jobs.size() != 1) {
+        throw new SqoopException(DerbyRepoError.DERBYREPO_0030, "Couldn't find job with id
"
+            + id);
       }
 
       // Return the first and only one link object
@@ -1763,7 +1763,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    * {@inheritDoc}
    */
   @Override
-  public List<MSubmission> findSubmissionsUnfinished(Connection conn) {
+  public List<MSubmission> findUnfinishedSubmissions(Connection conn) {
     List<MSubmission> submissions = new LinkedList<MSubmission>();
     PreparedStatement stmt = null;
     ResultSet rs = null;
@@ -1852,7 +1852,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    * {@inheritDoc}
    */
   @Override
-  public MSubmission findSubmissionLastForJob(long jobId, Connection conn) {
+  public MSubmission findLastSubmissionForJob(long jobId, Connection conn) {
     PreparedStatement stmt = null;
     ResultSet rs = null;
     try {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/eda08589/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
index 4c2d062..e2e8073 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestSubmissionHandling.java
@@ -60,13 +60,13 @@ public class TestSubmissionHandling extends DerbyTestCase {
   public void testFindSubmissionsUnfinished() throws Exception {
     List<MSubmission> submissions;
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(0, submissions.size());
 
     loadSubmissions();
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(2, submissions.size());
   }
@@ -123,7 +123,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
     assertCountForTable("SQOOP.SQ_SUBMISSION", 1);
 
     List<MSubmission> submissions =
-      handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+      handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(1, submissions.size());
 
@@ -179,7 +179,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
     loadSubmissions();
 
     List<MSubmission> submissions =
-      handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+      handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(2, submissions.size());
 
@@ -188,7 +188,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
 
     handler.updateSubmission(submission, getDerbyDatabaseConnection());
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(1, submissions.size());
   }
@@ -198,7 +198,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
     loadSubmissions();
     List<MSubmission> submissions;
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(2, submissions.size());
     assertCountForTable("SQOOP.SQ_SUBMISSION", 5);
@@ -208,21 +208,21 @@ public class TestSubmissionHandling extends DerbyTestCase {
     calendar.set(2012, Calendar.JANUARY, 3, 5, 5, 5);
     handler.purgeSubmissions(calendar.getTime(), getDerbyDatabaseConnection());
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(1, submissions.size());
     assertCountForTable("SQOOP.SQ_SUBMISSION", 2);
 
     handler.purgeSubmissions(new Date(), getDerbyDatabaseConnection());
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(0, submissions.size());
     assertCountForTable("SQOOP.SQ_SUBMISSION", 0);
 
     handler.purgeSubmissions(new Date(), getDerbyDatabaseConnection());
 
-    submissions = handler.findSubmissionsUnfinished(getDerbyDatabaseConnection());
+    submissions = handler.findUnfinishedSubmissions(getDerbyDatabaseConnection());
     assertNotNull(submissions);
     assertEquals(0, submissions.size());
     assertCountForTable("SQOOP.SQ_SUBMISSION", 0);


Mime
View raw message