You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2014/11/13 08:42:22 UTC
sqoop git commit: SQOOP-1723: Sqoop2: findJobsByConnector fails
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 0ace9710e -> a2e87bef0
SQOOP-1723: Sqoop2: findJobsByConnector fails
(Veena Basavaraj 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/a2e87bef
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/a2e87bef
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/a2e87bef
Branch: refs/heads/sqoop2
Commit: a2e87bef0173974799427550770caa620d165b29
Parents: 0ace971
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Wed Nov 12 23:41:59 2014 -0800
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Wed Nov 12 23:41:59 2014 -0800
----------------------------------------------------------------------
.../common/CommonRepositoryHandler.java | 8 ++---
...RepositoryInsertUpdateDeleteSelectQuery.java | 14 ++++----
.../derby/DerbyRepositoryHandler.java | 2 ++
...erbySchemaInsertUpdateDeleteSelectQuery.java | 32 -----------------
.../sqoop/repository/derby/TestJobHandling.java | 33 +++++++++++++++--
.../repository/derby/TestLinkHandling.java | 37 ++++++++++++++++++--
6 files changed, 78 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a2e87bef/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 9f4ecbc..42c40e6 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
@@ -149,7 +149,8 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
public List<MJob> findJobsForConnector(long connectorId, Connection conn) {
PreparedStatement stmt = null;
try {
- stmt = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_SELECT_ALL_JOBS_FOR_CONNECTOR_CONFIGURABLE);
+ stmt = conn
+ .prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_SELECT_ALL_JOBS_FOR_CONNECTOR_CONFIGURABLE);
stmt.setLong(1, connectorId);
stmt.setLong(2, connectorId);
return loadJobs(stmt, conn);
@@ -894,10 +895,9 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
public List<MJob> findJobs(Connection conn) {
PreparedStatement stmt = null;
try {
- stmt = conn.prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_SELECT_JOB);
-
+ stmt = conn
+ .prepareStatement(CommonRepositoryInsertUpdateDeleteSelectQuery.STMT_SELECT_JOB_ALL);
return loadJobs(stmt, conn);
-
} catch (SQLException ex) {
logException(ex);
throw new SqoopException(CommonRepositoryError.COMMON_0028, ex);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a2e87bef/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 921f12f..bff56a6 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
@@ -343,7 +343,7 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
+ " WHERE " + COLUMN_SQ_LNK_ID + " = ? ";
//DML: Select all jobs
- public static final String STMT_SELECT_JOB =
+ public static final String STMT_SELECT_JOB_ALL =
"SELECT "
+ "FROM_CONNECTOR." + COLUMN_SQ_LNK_CONFIGURABLE + ", "
+ "TO_CONNECTOR." + COLUMN_SQ_LNK_CONFIGURABLE + ", "
@@ -364,17 +364,19 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
// DML: Select one specific job
public static final String STMT_SELECT_JOB_SINGLE_BY_ID =
- STMT_SELECT_JOB + " WHERE " + COLUMN_SQB_ID + " = ?";
+ STMT_SELECT_JOB_ALL +
+ " WHERE " + COLUMN_SQB_ID + " = ?";
// DML: Select one specific job
public static final String STMT_SELECT_JOB_SINGLE_BY_NAME =
- STMT_SELECT_JOB + " WHERE " + COLUMN_SQB_NAME + " = ?";
+ STMT_SELECT_JOB_ALL +
+ " WHERE " + COLUMN_SQB_NAME + " = ?";
// DML: Select all jobs for a Connector
public static final String STMT_SELECT_ALL_JOBS_FOR_CONNECTOR_CONFIGURABLE =
- STMT_SELECT_JOB
- + " WHERE FROM_LINK." + COLUMN_SQ_LNK_CONFIGURABLE + " = ? OR TO_LINK."
- + COLUMN_SQ_LNK_CONFIGURABLE + " = ?";
+ STMT_SELECT_JOB_ALL +
+ " WHERE FROM_CONNECTOR." + COLUMN_SQ_LNK_CONFIGURABLE + " = ?" +
+ " OR TO_CONNECTOR." + COLUMN_SQ_LNK_CONFIGURABLE + " = ?";
/**********SUBMISSION TABLE **************/
// DML: Insert new submission
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a2e87bef/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 4d99a52..b5c9efc 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
@@ -19,6 +19,8 @@ package org.apache.sqoop.repository.derby;
import static org.apache.sqoop.repository.derby.DerbySchemaCreateQuery.*;
import static org.apache.sqoop.repository.derby.DerbySchemaInsertUpdateDeleteSelectQuery.*;
+import static org.apache.sqoop.repository.common.CommonRepositoryInsertUpdateDeleteSelectQuery.*;
+
import static org.apache.sqoop.repository.derby.DerbySchemaUpgradeQuery.*;
import java.net.URL;
import java.sql.Connection;
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a2e87bef/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaInsertUpdateDeleteSelectQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaInsertUpdateDeleteSelectQuery.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaInsertUpdateDeleteSelectQuery.java
index 4cbaf5a..5ffd939 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaInsertUpdateDeleteSelectQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaInsertUpdateDeleteSelectQuery.java
@@ -83,28 +83,6 @@ public final class DerbySchemaInsertUpdateDeleteSelectQuery {
+ COLUMN_SQN_UPDATE_USER + ", " + COLUMN_SQN_UPDATE_DATE
+ ") VALUES (?, ?, ?, ?, ?, ?, ?)";
- /**********JOB TABLE **************/
- //DML: Select all jobs
- public static final String STMT_SELECT_JOB =
- "SELECT "
- + "FROM_CONNECTOR." + COLUMN_SQ_LNK_CONFIGURABLE + ", "
- + "TO_CONNECTOR." + COLUMN_SQ_LNK_CONFIGURABLE + ", "
- + "JOB." + COLUMN_SQB_ID + ", "
- + "JOB." + COLUMN_SQB_NAME + ", "
- + "JOB." + COLUMN_SQB_FROM_LINK + ", "
- + "JOB." + COLUMN_SQB_TO_LINK + ", "
- + "JOB." + COLUMN_SQB_ENABLED + ", "
- + "JOB." + COLUMN_SQB_CREATION_USER + ", "
- + "JOB." + COLUMN_SQB_CREATION_DATE + ", "
- + "JOB." + COLUMN_SQB_UPDATE_USER + ", "
- + "JOB." + COLUMN_SQB_UPDATE_DATE
- + " FROM " + TABLE_SQ_JOB + " JOB"
- + " LEFT JOIN " + TABLE_SQ_LINK + " FROM_CONNECTOR"
- + " ON " + COLUMN_SQB_FROM_LINK + " = FROM_CONNECTOR." + COLUMN_SQ_LNK_ID
- + " LEFT JOIN " + TABLE_SQ_LINK + " TO_CONNECTOR"
- + " ON " + COLUMN_SQB_TO_LINK + " = TO_CONNECTOR." + COLUMN_SQ_LNK_ID;
-
-
/******* CONFIG and CONNECTOR DIRECTIONS ****/
public static final String STMT_INSERT_DIRECTION = "INSERT INTO " + TABLE_SQ_DIRECTION + " "
+ "(" + COLUMN_SQD_NAME + ") VALUES (?)";
@@ -115,16 +93,6 @@ public final class DerbySchemaInsertUpdateDeleteSelectQuery {
+ COLUMN_SQ_CFG_DIRECTION
+ " FROM " + TABLE_SQ_CONFIG;
- public static final String STMT_INSERT_SQ_CONNECTOR_DIRECTIONS =
- "INSERT INTO " + TABLE_SQ_CONNECTOR_DIRECTIONS + " "
- + "(" + COLUMN_SQCD_CONNECTOR + ", " + COLUMN_SQCD_DIRECTION + ")"
- + " VALUES (?, ?)";
-
- public static final String STMT_INSERT_SQ_CONFIG_DIRECTIONS =
- "INSERT INTO " + TABLE_SQ_CONFIG_DIRECTIONS + " "
- + "(" + COLUMN_SQ_CFG_DIR_CONFIG + ", " + COLUMN_SQ_CFG_DIR_DIRECTION + ")"
- + " VALUES (?, ?)";
-
private DerbySchemaInsertUpdateDeleteSelectQuery() {
// Disable explicit object creation
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a2e87bef/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 45a96ad..309e6b2 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
@@ -108,20 +108,47 @@ public class TestJobHandling extends DerbyTestCase {
assertEquals(0, list.size());
loadJobsForLatestVersion();
- // Load all two connections on loaded repository
+ // Load all two links on loaded repository
list = handler.findJobs(derbyConnection);
assertEquals(4, list.size());
assertEquals("JA0", list.get(0).getName());
-
assertEquals("JB0", list.get(1).getName());
-
assertEquals("JC0", list.get(2).getName());
+ assertEquals("JD0", list.get(3).getName());
+ }
+
+ @Test
+ public void testFindJobsByConnector() throws Exception {
+ List<MJob> list;
+ // Load empty list on empty repository
+ list = handler.findJobs(derbyConnection);
+ assertEquals(0, list.size());
+ loadJobsForLatestVersion();
+
+ // Load all 4 jobs on loaded repository
+ list = handler.findJobsForConnector(1, derbyConnection);
+ assertEquals(4, list.size());
+ assertEquals("JA0", list.get(0).getName());
+ assertEquals("JB0", list.get(1).getName());
+ assertEquals("JC0", list.get(2).getName());
assertEquals("JD0", list.get(3).getName());
}
@Test
+ public void testFindJobsForNonExistingConnector() throws Exception {
+ List<MJob> list;
+ // Load empty list on empty repository
+ list = handler.findJobs(derbyConnection);
+ assertEquals(0, list.size());
+ loadJobsForLatestVersion();
+
+ list = handler.findJobsForConnector(11, derbyConnection);
+ assertEquals(0, list.size());
+ }
+
+ @Test
public void testExistsJob() throws Exception {
// There shouldn't be anything on empty repository
assertFalse(handler.existsJob(1, derbyConnection));
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a2e87bef/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
index 8ab384a..6274d11 100644
--- a/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
+++ b/repository/repository-derby/src/test/java/org/apache/sqoop/repository/derby/TestLinkHandling.java
@@ -63,7 +63,7 @@ public class TestLinkHandling extends DerbyTestCase {
assertEquals(CommonRepositoryError.COMMON_0021, ex.getErrorCode());
}
- // Load prepared connections into database
+ // Load prepared links into database
loadLinksForLatestVersion();
MLink linkA = handler.findLink(1, getDerbyDatabaseConnection());
@@ -85,7 +85,7 @@ public class TestLinkHandling extends DerbyTestCase {
public void testFindLinkByName() throws Exception {
// Let's try to find non existing link
assertNull(handler.findLink("non-existing", getDerbyDatabaseConnection()));
- // Load prepared connections into database
+ // Load prepared links into database
loadLinksForLatestVersion();
MLink linkA = handler.findLink("CA", getDerbyDatabaseConnection());
@@ -113,7 +113,7 @@ public class TestLinkHandling extends DerbyTestCase {
loadLinksForLatestVersion();
- // Load all two connections on loaded repository
+ // Load all two links on loaded repository
list = handler.findLinks(getDerbyDatabaseConnection());
assertEquals(2, list.size());
@@ -122,6 +122,37 @@ public class TestLinkHandling extends DerbyTestCase {
}
@Test
+ public void testFindLinksByConnector() throws Exception {
+ List<MLink> list;
+
+ // Load empty list on empty repository
+ list = handler.findLinks(getDerbyDatabaseConnection());
+ assertEquals(0, list.size());
+
+ loadLinksForLatestVersion();
+
+ // Load all two links on loaded repository
+ list = handler.findLinksForConnector(1, getDerbyDatabaseConnection());
+ assertEquals(2, list.size());
+
+ assertEquals("CA", list.get(0).getName());
+ assertEquals("CB", list.get(1).getName());
+ }
+
+ public void testFindLinksByNonExistingConnector() throws Exception {
+ List<MLink> list;
+
+ // Load empty list on empty repository
+ list = handler.findLinks(getDerbyDatabaseConnection());
+ assertEquals(0, list.size());
+
+ loadLinksForLatestVersion();
+
+ list = handler.findLinksForConnector(2, getDerbyDatabaseConnection());
+ assertEquals(0, list.size());
+ }
+
+ @Test
public void testExistsLink() throws Exception {
// There shouldn't be anything on empty repository
assertFalse(handler.existsLink(1, getDerbyDatabaseConnection()));