sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2398: Sqoop2: Show all job with order
Date Fri, 10 Jul 2015 16:27:24 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 aca7d7558 -> 81b42fe4c


SQOOP-2398: Sqoop2: Show all job with order

(Richard via Jarek Jarcec Cecho)


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

Branch: refs/heads/sqoop2
Commit: 81b42fe4c021b12ae22e3f2d898056f5f2516b0d
Parents: aca7d75
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Fri Jul 10 09:26:55 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Fri Jul 10 09:26:55 2015 -0700

----------------------------------------------------------------------
 .../common/CommonRepositoryHandler.java         |   2 +-
 ...RepositoryInsertUpdateDeleteSelectQuery.java |   9 +-
 .../integration/server/ShowJobInOrderTest.java  | 104 +++++++++++++++++++
 3 files changed, 112 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/81b42fe4/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
index c8335c0..1b5e2fb 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
@@ -945,7 +945,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
     PreparedStatement stmt = null;
     try {
       stmt = conn
-          .prepareStatement(crudQueries.getStmtSelectJobAll());
+          .prepareStatement(crudQueries.getStmtSelectJobAllWithOrder());
       return loadJobs(stmt, conn);
     } catch (SQLException ex) {
       logException(ex);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/81b42fe4/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
index 932557f..28f5f6a 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryInsertUpdateDeleteSelectQuery.java
@@ -441,6 +441,11 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
           + " LEFT JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
+ " TO_CONNECTOR"
           + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_LINK) + " = TO_CONNECTOR."
+ CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID);
 
+  //DML: Select all jobs with order
+  public static final String STMT_SELECT_JOB_ALL_WITH_ORDER =
+      STMT_SELECT_JOB_ALL +
+          " ORDER BY JOB." + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID);
+
   // DML: Select one specific job
   public static final String STMT_SELECT_JOB_SINGLE_BY_ID =
       STMT_SELECT_JOB_ALL +
@@ -824,8 +829,8 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
     return STMT_SELECT_JOBS_FOR_LINK_CHECK;
   }
 
-  public String getStmtSelectJobAll() {
-    return STMT_SELECT_JOB_ALL;
+  public String getStmtSelectJobAllWithOrder() {
+    return STMT_SELECT_JOB_ALL_WITH_ORDER;
   }
 
   public String getStmtSelectJobSingleById() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/81b42fe4/test/src/test/java/org/apache/sqoop/integration/server/ShowJobInOrderTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/ShowJobInOrderTest.java
b/test/src/test/java/org/apache/sqoop/integration/server/ShowJobInOrderTest.java
new file mode 100644
index 0000000..88cfcb5
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/server/ShowJobInOrderTest.java
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.integration.server;
+
+import org.apache.sqoop.connector.hdfs.configuration.ToFormat;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.test.testcases.ConnectorTestCase;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Ensure that jobs will be shown in order
+ */
+public class ShowJobInOrderTest extends ConnectorTestCase {
+
+  public ShowJobInOrderTest() {
+  }
+
+  @Test
+  public void testShowJobInOrder() throws Exception {
+    createAndLoadTableCities();
+
+    // RDBMS link
+    MLink rdbmsLink = getClient().createLink("generic-jdbc-connector");
+    fillRdbmsLinkConfig(rdbmsLink);
+    saveLink(rdbmsLink);
+
+    // HDFS link
+    MLink hdfsLink = getClient().createLink("hdfs-connector");
+    fillHdfsLink(hdfsLink);
+    saveLink(hdfsLink);
+
+    // Job creation
+    MJob job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
+
+    // rdms "FROM" config
+    fillRdbmsFromConfig(job, "id");
+
+    // hdfs "TO" config
+    fillHdfsToConfig(job, ToFormat.TEXT_FILE);
+
+    saveJob(job);
+
+    // Job creation
+    job = getClient().createJob(hdfsLink.getPersistenceId(), rdbmsLink.getPersistenceId());
+
+    // rdms "To" config
+    fillRdbmsToConfig(job);
+
+    // hdfs "From" config
+    fillHdfsFromConfig(job);
+
+    saveJob(job);
+
+    // Job creation
+    job = getClient().createJob(rdbmsLink.getPersistenceId(), hdfsLink.getPersistenceId());
+
+    // rdms "FROM" config
+    fillRdbmsFromConfig(job, "id");
+
+    // hdfs "TO" config
+    fillHdfsToConfig(job, ToFormat.TEXT_FILE);
+
+    saveJob(job);
+
+    // Job creation
+    job = getClient().createJob(hdfsLink.getPersistenceId(), rdbmsLink.getPersistenceId());
+
+
+    // hdfs "From" config
+    fillHdfsFromConfig(job);
+
+    // rdms "To" config
+    fillRdbmsToConfig(job);
+
+    saveJob(job);
+
+    List<MJob> jobs = getClient().getJobs();
+
+    assertEquals(1, jobs.get(0).getPersistenceId());
+    assertEquals(2, jobs.get(1).getPersistenceId());
+    assertEquals(3, jobs.get(2).getPersistenceId());
+    assertEquals(4, jobs.get(3).getPersistenceId());
+  }
+}


Mime
View raw message