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 2015/09/17 16:39:29 UTC
[1/2] sqoop git commit: SQOOP-2573: Sqoop2: Use object name instead
of object id for job, link and connector in Sqoop 2 server
Repository: sqoop
Updated Branches:
refs/heads/sqoop2 f241f82c3 -> a3c374723
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 560fd58..aa872ab 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
@@ -277,25 +277,24 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
private static final String STMT_ENABLE_LINK =
"UPDATE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " SET "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ENABLED) + " = ? "
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + " = ?";
-
-
- // UPDATE the LINK Input
- private static final String STMT_UPDATE_LINK_INPUT =
- "UPDATE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " SET "
- + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_VALUE) + " = ? "
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + " = ?"
- + " AND " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME) + " = ?";
// DML: Delete rows from link input table
- private static final String STMT_DELETE_LINK_INPUT =
+ private static final String STMT_DELETE_LINK_INPUT_BY_NAME =
+ "DELETE FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME)
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK)
+ + " IN (SELECT " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ + " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME) + " = ?)";
+
+ private static final String STMT_DELETE_LINK_INPUT_BY_ID =
"DELETE FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME)
+ " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " = ?";
// DML: Delete row from link table
private static final String STMT_DELETE_LINK =
"DELETE FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME) + " = ?";
// DML: Select all links
private static final String STMT_SELECT_LINK_ALL =
@@ -332,12 +331,14 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
+ CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_UPDATE_USER) + ", "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_UPDATE_DATE)
+ " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONFIGURABLE) + " = ?";
+ + " INNER JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME)
+ + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONFIGURABLE) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID)
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQC_NAME) + " = ?";
// DML: Check if given link exists
- private static final String STMT_SELECT_LINK_CHECK_BY_ID =
+ private static final String STMT_SELECT_LINK_CHECK_BY_NAME =
"SELECT count(*) FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME) + " = ?";
/**
* *******JOB TABLE *************
@@ -374,38 +375,34 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
private static final String STMT_ENABLE_JOB =
"UPDATE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " SET "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQB_ENABLED) + " = ? "
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + " = ?";
-
- // UPDATE the JOB Input
- private static final String STMT_UPDATE_JOB_INPUT =
- "UPDATE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_INPUT_NAME) + " SET "
- + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_VALUE) + " = ? "
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + " = ?"
- + " AND " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " = ?";
// DML: Delete rows from job input table
private static final String STMT_DELETE_JOB_INPUT =
"DELETE FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_INPUT_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB)
+ + " IN (SELECT " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
+ + " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " = ?)";
// DML: Delete row from job table
private static final String STMT_DELETE_JOB =
"DELETE FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " = ?";
// DML: Check if given job exists
- private static final String STMT_SELECT_JOB_CHECK_BY_ID =
+ private static final String STMT_SELECT_JOB_CHECK_BY_NAME =
"SELECT count(*) FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + " = ?";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " = ?";
// DML: Check if there are jobs for given link
private static final String STMT_SELECT_JOBS_FOR_LINK_CHECK =
"SELECT"
+ " count(*)"
+ " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
- + " JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
+ + " INNER JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
+ " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_FROM_LINK) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + " = ? ";
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME) + " = ? ";
//DML: Select all jobs
private static final String STMT_SELECT_JOB_ALL =
@@ -537,7 +534,9 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
+ CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_SUMMARY) + ", "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS)
+ " FROM " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME)
- + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " = ?"
+ + " INNER JOIN " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME)
+ + " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
+ + " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " = ?"
+ " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQS_UPDATE_DATE) + " DESC";
// DML: Select context type
@@ -747,12 +746,12 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
return STMT_ENABLE_LINK;
}
- public String getStmtUpdateLinkInput() {
- return STMT_UPDATE_LINK_INPUT;
+ public String getStmtDeleteLinkInputByLinkId() {
+ return STMT_DELETE_LINK_INPUT_BY_ID;
}
- public String getStmtDeleteLinkInput() {
- return STMT_DELETE_LINK_INPUT;
+ public String getStmtDeleteLinkInputByLinkName() {
+ return STMT_DELETE_LINK_INPUT_BY_NAME;
}
public String getStmtDeleteLink() {
@@ -775,8 +774,8 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
return STMT_SELECT_LINK_FOR_CONNECTOR_CONFIGURABLE;
}
- public String getStmtSelectLinkCheckById() {
- return STMT_SELECT_LINK_CHECK_BY_ID;
+ public String getStmtSelectLinkCheckByName() {
+ return STMT_SELECT_LINK_CHECK_BY_NAME;
}
public String getStmtInsertJob() {
@@ -795,10 +794,6 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
return STMT_ENABLE_JOB;
}
- public String getStmtUpdateJobInput() {
- return STMT_UPDATE_JOB_INPUT;
- }
-
public String getStmtDeleteJobInput() {
return STMT_DELETE_JOB_INPUT;
}
@@ -807,8 +802,8 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
return STMT_DELETE_JOB;
}
- public String getStmtSelectJobCheckById() {
- return STMT_SELECT_JOB_CHECK_BY_ID;
+ public String getStmtSelectJobCheckByName() {
+ return STMT_SELECT_JOB_CHECK_BY_NAME;
}
public String getStmtSelectJobsForLinkCheck() {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 6c36f02..9f8e570 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
@@ -22,24 +22,18 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
import java.sql.Connection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.sqoop.common.Direction;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.model.MConfig;
-import org.apache.sqoop.model.MConfigUpdateEntityType;
import org.apache.sqoop.model.MDriver;
-import org.apache.sqoop.model.MFromConfig;
import org.apache.sqoop.model.MJob;
import org.apache.sqoop.model.MMapInput;
import org.apache.sqoop.model.MStringInput;
-import org.apache.sqoop.model.MToConfig;
-import org.apache.sqoop.error.code.CommonRepositoryError;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -150,19 +144,19 @@ public class TestJobHandling extends DerbyTestCase {
@Test
public void testExistsJob() throws Exception {
// There shouldn't be anything on empty repository
- assertFalse(handler.existsJob(1, derbyConnection));
- assertFalse(handler.existsJob(2, derbyConnection));
- assertFalse(handler.existsJob(3, derbyConnection));
- assertFalse(handler.existsJob(4, derbyConnection));
- assertFalse(handler.existsJob(5, derbyConnection));
+ assertFalse(handler.existsJob("JA0", derbyConnection));
+ assertFalse(handler.existsJob("JB0", derbyConnection));
+ assertFalse(handler.existsJob("JC0", derbyConnection));
+ assertFalse(handler.existsJob("JD0", derbyConnection));
+ assertFalse(handler.existsJob("NONEXISTJOB", derbyConnection));
loadJobsForLatestVersion();
- assertTrue(handler.existsJob(1, derbyConnection));
- assertTrue(handler.existsJob(2, derbyConnection));
- assertTrue(handler.existsJob(3, derbyConnection));
- assertTrue(handler.existsJob(4, derbyConnection));
- assertFalse(handler.existsJob(5, derbyConnection));
+ assertTrue(handler.existsJob("JA0", derbyConnection));
+ assertTrue(handler.existsJob("JB0", derbyConnection));
+ assertTrue(handler.existsJob("JC0", derbyConnection));
+ assertTrue(handler.existsJob("JD0", derbyConnection));
+ assertFalse(handler.existsJob("NONEXISTJOB", derbyConnection));
}
@Test
@@ -170,10 +164,10 @@ public class TestJobHandling extends DerbyTestCase {
loadJobsForLatestVersion();
loadSubmissions();
- assertTrue(handler.inUseJob(1, derbyConnection));
- assertFalse(handler.inUseJob(2, derbyConnection));
- assertFalse(handler.inUseJob(3, derbyConnection));
- assertFalse(handler.inUseJob(4, derbyConnection));
+ assertTrue(handler.inUseJob("JA0", derbyConnection));
+ assertFalse(handler.inUseJob("JB0", derbyConnection));
+ assertFalse(handler.inUseJob("JC0", derbyConnection));
+ assertFalse(handler.inUseJob("JD0", derbyConnection));
}
@Test
@@ -295,14 +289,14 @@ public class TestJobHandling extends DerbyTestCase {
loadJobsForLatestVersion();
// disable job 1
- handler.enableJob(1, false, derbyConnection);
+ handler.enableJob("JA0", false, derbyConnection);
MJob retrieved = handler.findJob(1, derbyConnection);
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable job 1
- handler.enableJob(1, true, derbyConnection);
+ handler.enableJob("JA0", true, derbyConnection);
retrieved = handler.findJob(1, derbyConnection);
assertNotNull(retrieved);
@@ -313,150 +307,23 @@ public class TestJobHandling extends DerbyTestCase {
public void testDeleteJob() throws Exception {
loadJobsForLatestVersion();
- handler.deleteJob(1, derbyConnection);
+ handler.deleteJob("JA0", derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 3);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 18);
- handler.deleteJob(2, derbyConnection);
+ handler.deleteJob("JB0", derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 2);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 12);
- handler.deleteJob(3, derbyConnection);
+ handler.deleteJob("JC0", derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 1);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 6);
- handler.deleteJob(4, derbyConnection);
+ handler.deleteJob("JD0", derbyConnection);
assertCountForTable("SQOOP.SQ_JOB", 0);
assertCountForTable("SQOOP.SQ_JOB_INPUT", 0);
}
- @Test
- public void testUpdateJobConfig() throws Exception {
- loadJobsForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- MJob job = handler.findJob(1, derbyConnection);
-
- List<MConfig> fromConfigs = job.getFromJobConfig().getConfigs();
- MConfig fromConfig = fromConfigs.get(0).clone(false);
- MConfig newFromConfig = new MConfig(fromConfig.getName(), fromConfig.getInputs());
-
- ((MStringInput) newFromConfig.getInputs().get(0)).setValue("FromJobConfigUpdated");
-
- handler.updateJobConfig(job.getPersistenceId(), newFromConfig, MConfigUpdateEntityType.USER,
- derbyConnection);
-
- MJob updatedJob = handler.findJob(1, derbyConnection);
- MFromConfig newFromConfigs = updatedJob.getFromJobConfig();
- assertEquals(2, newFromConfigs.getConfigs().size());
- MConfig updatedFromConfig = newFromConfigs.getConfigs().get(0);
- assertEquals("FromJobConfigUpdated", updatedFromConfig.getInputs().get(0).getValue());
-
- List<MConfig> toConfigs = job.getToJobConfig().getConfigs();
- MConfig toConfig = toConfigs.get(0).clone(false);
- MConfig newToConfig = new MConfig(toConfig.getName(), toConfig.getInputs());
-
- ((MStringInput) newToConfig.getInputs().get(0)).setValue("ToJobConfigUpdated");
-
- handler.updateJobConfig(job.getPersistenceId(), newToConfig, MConfigUpdateEntityType.USER,
- derbyConnection);
-
- updatedJob = handler.findJob(1, derbyConnection);
- MToConfig newToConfigs = updatedJob.getToJobConfig();
- assertEquals(2, newToConfigs.getConfigs().size());
- MConfig updatedToConfig = newToConfigs.getConfigs().get(0);
- assertEquals("ToJobConfigUpdated", updatedToConfig.getInputs().get(0).getValue());
- }
-
- @Test(expectedExceptions = SqoopException.class)
- public void testIncorrectEntityCausingConfigUpdate() throws Exception {
- loadJobsForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- MJob job = handler.findJob(1, derbyConnection);
-
- List<MConfig> fromConfigs = job.getFromJobConfig().getConfigs();
- MConfig fromConfig = fromConfigs.get(0).clone(false);
- MConfig newFromConfig = new MConfig(fromConfig.getName(), fromConfig.getInputs());
- HashMap<String, String> newMap = new HashMap<String, String>();
- newMap.put("1", "foo");
- newMap.put("2", "bar");
-
- ((MMapInput) newFromConfig.getInputs().get(1)).setValue(newMap);
-
- handler.updateJobConfig(job.getPersistenceId(), newFromConfig, MConfigUpdateEntityType.USER,
- derbyConnection);
- }
-
- @Test
- public void testFindAndUpdateJobConfig() throws Exception {
- loadJobsForLatestVersion();
- MJob job = handler.findJob(1, derbyConnection);
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- MConfig fromConfig = handler.findFromJobConfig(1, "C1JOB1", derbyConnection);
- assertEquals("Value5", fromConfig.getInputs().get(0).getValue());
- assertNull(fromConfig.getInputs().get(1).getValue());
-
- MConfig toConfig = handler.findToJobConfig(1, "C2JOB2", derbyConnection);
- assertEquals("Value11", toConfig.getInputs().get(0).getValue());
- assertNull(toConfig.getInputs().get(1).getValue());
- HashMap<String, String> newMap = new HashMap<String, String>();
- newMap.put("1UPDATED", "foo");
- newMap.put("2UPDATED", "bar");
- ((MStringInput) toConfig.getInputs().get(0)).setValue("test");
- ((MMapInput) toConfig.getInputs().get(1)).setValue(newMap);
-
- handler.updateJobConfig(job.getPersistenceId(), toConfig, MConfigUpdateEntityType.USER,
- derbyConnection);
- assertEquals("test", toConfig.getInputs().get(0).getValue());
- assertEquals(newMap, toConfig.getInputs().get(1).getValue());
-
- MConfig driverConfig = handler.findDriverJobConfig(1, "d1", derbyConnection);
- assertEquals("Value13", driverConfig.getInputs().get(0).getValue());
- assertNull(driverConfig.getInputs().get(1).getValue());
- }
-
- @Test(expectedExceptions = SqoopException.class)
- public void testNonExistingFromConfigFetch() throws Exception {
- loadJobsForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- handler.findFromJobConfig(1, "Non-ExistingC1JOB1", derbyConnection);
- }
-
- @Test(expectedExceptions = SqoopException.class)
- public void testNonExistingToConfigFetch() throws Exception {
- loadJobsForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- handler.findToJobConfig(1, "Non-ExistingC2JOB1", derbyConnection);
- }
-
- @Test(expectedExceptions = SqoopException.class)
- public void testNonExistingDriverConfigFetch() throws Exception {
- loadJobsForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- handler.findDriverJobConfig(1, "Non-Existingd1", derbyConnection);
- }
-
- @Test(expectedExceptions = SqoopException.class)
- public void testNonExistingJobConfig() throws Exception {
- loadJobsForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_JOB", 4);
- assertCountForTable("SQOOP.SQ_JOB_INPUT", 24);
- // 11 does not exist
- handler.findDriverJobConfig(11, "Non-d1", derbyConnection);
- }
-
public MJob getJob() {
return new MJob(1, 1, 1, 1, handler.findConnector("A", derbyConnection).getFromConfig(),
handler.findConnector("A", derbyConnection).getToConfig(), handler.findDriver(
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 4be3641..40bac8b 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
@@ -22,18 +22,14 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
import java.util.List;
import org.apache.sqoop.common.SqoopException;
import org.apache.sqoop.model.MConfig;
-import org.apache.sqoop.model.MConfigUpdateEntityType;
import org.apache.sqoop.model.MLink;
-import org.apache.sqoop.model.MLinkConfig;
import org.apache.sqoop.model.MMapInput;
import org.apache.sqoop.model.MStringInput;
-import org.apache.sqoop.error.code.CommonRepositoryError;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -129,7 +125,7 @@ public class TestLinkHandling extends DerbyTestCase {
loadLinksForLatestVersion();
// Load all two links on loaded repository
- list = handler.findLinksForConnector(1, getDerbyDatabaseConnection());
+ list = handler.findLinksForConnector("A", getDerbyDatabaseConnection());
assertEquals(2, list.size());
assertEquals("CA", list.get(0).getName());
@@ -145,22 +141,22 @@ public class TestLinkHandling extends DerbyTestCase {
loadLinksForLatestVersion();
- list = handler.findLinksForConnector(2, getDerbyDatabaseConnection());
+ list = handler.findLinksForConnector("NONEXISTCONNECTOR", getDerbyDatabaseConnection());
assertEquals(0, list.size());
}
@Test
public void testExistsLink() throws Exception {
// There shouldn't be anything on empty repository
- assertFalse(handler.existsLink(1, getDerbyDatabaseConnection()));
- assertFalse(handler.existsLink(2, getDerbyDatabaseConnection()));
- assertFalse(handler.existsLink(3, getDerbyDatabaseConnection()));
+ assertFalse(handler.existsLink("CA", getDerbyDatabaseConnection()));
+ assertFalse(handler.existsLink("CB", getDerbyDatabaseConnection()));
+ assertFalse(handler.existsLink("CC", getDerbyDatabaseConnection()));
loadLinksForLatestVersion();
- assertTrue(handler.existsLink(1, getDerbyDatabaseConnection()));
- assertTrue(handler.existsLink(2, getDerbyDatabaseConnection()));
- assertFalse(handler.existsLink(3, getDerbyDatabaseConnection()));
+ assertTrue(handler.existsLink("CA", getDerbyDatabaseConnection()));
+ assertTrue(handler.existsLink("CB", getDerbyDatabaseConnection()));
+ assertFalse(handler.existsLink("CC", getDerbyDatabaseConnection()));
}
@Test
@@ -213,11 +209,11 @@ public class TestLinkHandling extends DerbyTestCase {
public void testInUseLink() throws Exception {
loadLinksForLatestVersion();
- assertFalse(handler.inUseLink(1, getDerbyDatabaseConnection()));
+ assertFalse(handler.inUseLink("CA", getDerbyDatabaseConnection()));
loadJobsForLatestVersion();
- assertTrue(handler.inUseLink(1, getDerbyDatabaseConnection()));
+ assertTrue(handler.inUseLink("CA", getDerbyDatabaseConnection()));
}
@Test
@@ -257,14 +253,14 @@ public class TestLinkHandling extends DerbyTestCase {
loadLinksForLatestVersion();
// disable link 1
- handler.enableLink(1, false, getDerbyDatabaseConnection());
+ handler.enableLink("CA", false, getDerbyDatabaseConnection());
MLink retrieved = handler.findLink(1, getDerbyDatabaseConnection());
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable link 1
- handler.enableLink(1, true, getDerbyDatabaseConnection());
+ handler.enableLink("CA", true, getDerbyDatabaseConnection());
retrieved = handler.findLink(1, getDerbyDatabaseConnection());
assertNotNull(retrieved);
@@ -275,57 +271,15 @@ public class TestLinkHandling extends DerbyTestCase {
public void testDeleteLink() throws Exception {
loadLinksForLatestVersion();
- handler.deleteLink(1, getDerbyDatabaseConnection());
+ handler.deleteLink("CA", getDerbyDatabaseConnection());
assertCountForTable("SQOOP.SQ_LINK", 1);
assertCountForTable("SQOOP.SQ_LINK_INPUT", 4);
- handler.deleteLink(2, getDerbyDatabaseConnection());
+ handler.deleteLink("CB", getDerbyDatabaseConnection());
assertCountForTable("SQOOP.SQ_LINK", 0);
assertCountForTable("SQOOP.SQ_LINK_INPUT", 0);
}
- @Test
- public void testUpdateLinkConfig() throws Exception {
- loadLinksForLatestVersion();
-
- assertCountForTable("SQOOP.SQ_LINK", 2);
- assertCountForTable("SQOOP.SQ_LINK_INPUT", 8);
- MLink link = handler.findLink(1, getDerbyDatabaseConnection());
-
- List<MConfig> configs = link.getConnectorLinkConfig().getConfigs();
- MConfig config = configs.get(0).clone(false);
- MConfig newConfig = new MConfig(config.getName(), config.getInputs());
-
- ((MStringInput) newConfig.getInputs().get(0)).setValue("LinkConfigUpdated");
-
- handler.updateLinkConfig(link.getPersistenceId(), newConfig, MConfigUpdateEntityType.USER,
- getDerbyDatabaseConnection());
-
- MLink updatedLink = handler.findLink(1, getDerbyDatabaseConnection());
- MLinkConfig newConfigs = updatedLink.getConnectorLinkConfig();
- assertEquals(2, newConfigs.getConfigs().size());
- MConfig updatedLinkConfig = newConfigs.getConfigs().get(0);
- assertEquals("LinkConfigUpdated", updatedLinkConfig.getInputs().get(0).getValue());
- }
-
- @Test(expectedExceptions = SqoopException.class)
- public void testNonExistingLinkConfigFetch() throws Exception {
- loadLinksForLatestVersion();
- assertCountForTable("SQOOP.SQ_LINK", 2);
- assertCountForTable("SQOOP.SQ_LINK_INPUT", 8);
- handler.findLinkConfig(1, "Non-ExistingC1LINK1", getDerbyDatabaseConnection());
- }
-
- @Test
- public void testLinkConfigFetch() throws Exception {
- loadLinksForLatestVersion();
- assertCountForTable("SQOOP.SQ_LINK", 2);
- assertCountForTable("SQOOP.SQ_LINK_INPUT", 8);
- MConfig config = handler.findLinkConfig(1, "C1LINK0", getDerbyDatabaseConnection());
- assertEquals("Value1", config.getInputs().get(0).getValue());
- assertNull(config.getInputs().get(1).getValue());
- }
-
public MLink getLink() {
return new MLink(1, handler.findConnector("A", getDerbyDatabaseConnection()).getLinkConfig());
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 405c0b8..79aced7 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
@@ -242,7 +242,7 @@ public class TestSubmissionHandling extends DerbyTestCase {
submission.getError().setErrorSummary(errorSummary + "morethan150");
handler.createSubmission(submission, getDerbyDatabaseConnection());
- List<MSubmission> submissions = handler.findSubmissionsForJob(1, getDerbyDatabaseConnection());
+ List<MSubmission> submissions = handler.findSubmissionsForJob("JA0", getDerbyDatabaseConnection());
assertNotNull(submissions);
assertEquals(errorDetail, submissions.get(0).getError().getErrorDetails());
@@ -333,16 +333,16 @@ public class TestSubmissionHandling extends DerbyTestCase {
loadSubmissions();
assertCountForTable("SQOOP.SQ_SUBMISSION", 5);
- handler.deleteJob(1, getDerbyDatabaseConnection());
+ handler.deleteJob("JA0", getDerbyDatabaseConnection());
assertCountForTable("SQOOP.SQ_SUBMISSION", 3);
- handler.deleteJob(2, getDerbyDatabaseConnection());
+ handler.deleteJob("JB0", getDerbyDatabaseConnection());
assertCountForTable("SQOOP.SQ_SUBMISSION", 2);
- handler.deleteJob(3, getDerbyDatabaseConnection());
+ handler.deleteJob("JC0", getDerbyDatabaseConnection());
assertCountForTable("SQOOP.SQ_SUBMISSION", 1);
- handler.deleteJob(4, getDerbyDatabaseConnection());
+ handler.deleteJob("JD0", getDerbyDatabaseConnection());
assertCountForTable("SQOOP.SQ_SUBMISSION", 0);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
index 0614d7a..ed6543d 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestJobHandling.java
@@ -76,7 +76,7 @@ public class TestJobHandling extends MySqlTestCase {
@Test
public void testFindJobFail() throws Exception {
for (MJob job : handler.findJobs(provider.getConnection())) {
- handler.deleteJob(job.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(job.getName(), provider.getConnection());
}
// Let's try to find non existing job
@@ -125,7 +125,7 @@ public class TestJobHandling extends MySqlTestCase {
// Delete jobs
for (MJob job : handler.findJobs(provider.getConnection())) {
- handler.deleteJob(job.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(job.getName(), provider.getConnection());
}
// Load all two links on loaded repository
@@ -153,30 +153,30 @@ public class TestJobHandling extends MySqlTestCase {
@Test
public void testExistsJob() throws Exception {
- assertTrue(handler.existsJob(1, provider.getConnection()));
- assertTrue(handler.existsJob(2, provider.getConnection()));
- assertFalse(handler.existsJob(3, provider.getConnection()));
+ assertTrue(handler.existsJob(JOB_A_NAME, provider.getConnection()));
+ assertTrue(handler.existsJob(JOB_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsJob("NONEXISTJOB", provider.getConnection()));
// Delete jobs
for (MJob job : handler.findJobs(provider.getConnection())) {
- handler.deleteJob(job.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(job.getName(), provider.getConnection());
}
// There shouldn't be anything on empty repository
- assertFalse(handler.existsJob(1, provider.getConnection()));
- assertFalse(handler.existsJob(2, provider.getConnection()));
- assertFalse(handler.existsJob(3, provider.getConnection()));
+ assertFalse(handler.existsJob(JOB_A_NAME, provider.getConnection()));
+ assertFalse(handler.existsJob(JOB_A_NAME, provider.getConnection()));
+ assertFalse(handler.existsJob("NONEXISTJOB", provider.getConnection()));
}
@Test
public void testInUseJob() throws Exception {
MSubmission submission = getSubmission(
- handler.findJob(1, provider.getConnection()), SubmissionStatus.RUNNING);
+ handler.findJob(JOB_A_NAME, provider.getConnection()), SubmissionStatus.RUNNING);
handler.createSubmission(submission, provider.getConnection());
- assertTrue(handler.inUseJob(1, provider.getConnection()));
- assertFalse(handler.inUseJob(2, provider.getConnection()));
- assertFalse(handler.inUseJob(3, provider.getConnection()));
+ assertTrue(handler.inUseJob(JOB_A_NAME, provider.getConnection()));
+ assertFalse(handler.inUseJob(JOB_B_NAME, provider.getConnection()));
+ assertFalse(handler.inUseJob("NONEXISTJOB", provider.getConnection()));
}
@Test
@@ -273,14 +273,14 @@ public class TestJobHandling extends MySqlTestCase {
@Test
public void testEnableAndDisableJob() throws Exception {
// disable job 1
- handler.enableJob(1, false, provider.getConnection());
+ handler.enableJob(JOB_A_NAME, false, provider.getConnection());
MJob retrieved = handler.findJob(1, provider.getConnection());
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable job 1
- handler.enableJob(1, true, provider.getConnection());
+ handler.enableJob(JOB_A_NAME, true, provider.getConnection());
retrieved = handler.findJob(1, provider.getConnection());
assertNotNull(retrieved);
@@ -289,12 +289,12 @@ public class TestJobHandling extends MySqlTestCase {
@Test
public void testDeleteJob() throws Exception {
- handler.deleteJob(1, provider.getConnection());
+ handler.deleteJob(JOB_A_NAME, provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB")), 1);
Assert.assertEquals(
provider.rowCount(new TableName("SQOOP", "SQ_JOB_INPUT")), 6);
- handler.deleteJob(2, provider.getConnection());
+ handler.deleteJob(JOB_B_NAME, provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB")), 0);
Assert.assertEquals(
provider.rowCount(new TableName("SQOOP", "SQ_JOB_INPUT")), 0);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
index cceef09..72fa981 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestLinkHandling.java
@@ -69,7 +69,7 @@ public class TestLinkHandling extends MySqlTestCase {
public void testFindLinkFail() {
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
assertNull(handler.findLink(1, provider.getConnection()));
@@ -120,7 +120,7 @@ public class TestLinkHandling extends MySqlTestCase {
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
// Load empty list on empty repository
@@ -131,45 +131,43 @@ public class TestLinkHandling extends MySqlTestCase {
@Test
public void testFindLinksByConnector() throws Exception {
List<MLink> list;
- Long connectorId = handler.findConnector("A", provider.getConnection())
- .getPersistenceId();
// Load all two links on loaded repository
- list = handler.findLinksForConnector(connectorId, provider.getConnection());
+ list = handler.findLinksForConnector("A", provider.getConnection());
assertEquals(1, list.size());
assertEquals(LINK_A_NAME, list.get(0).getName());
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
// Load empty list on empty repository
- list = handler.findLinksForConnector(connectorId, provider.getConnection());
+ list = handler.findLinksForConnector("A", provider.getConnection());
assertEquals(0, list.size());
}
@Test
public void testFindLinksByNonExistingConnector() throws Exception {
- List<MLink> list = handler.findLinksForConnector(11,
+ List<MLink> list = handler.findLinksForConnector("NONEXISTCONNECTOR",
provider.getConnection());
assertEquals(0, list.size());
}
@Test
public void testExistsLink() throws Exception {
- assertTrue(handler.existsLink(1, provider.getConnection()));
- assertTrue(handler.existsLink(2, provider.getConnection()));
- assertFalse(handler.existsLink(3, provider.getConnection()));
+ assertTrue(handler.existsLink(LINK_A_NAME, provider.getConnection()));
+ assertTrue(handler.existsLink(LINK_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsLink("NONEXISTLINK", provider.getConnection()));
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
- assertFalse(handler.existsLink(1, provider.getConnection()));
- assertFalse(handler.existsLink(2, provider.getConnection()));
- assertFalse(handler.existsLink(3, provider.getConnection()));
+ assertFalse(handler.existsLink(LINK_A_NAME, provider.getConnection()));
+ assertFalse(handler.existsLink(LINK_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsLink("NONEXISTLINK", provider.getConnection()));
}
@Test
@@ -214,7 +212,7 @@ public class TestLinkHandling extends MySqlTestCase {
@Test
public void testInUseLink() throws Exception {
- assertFalse(handler.inUseLink(1, provider.getConnection()));
+ assertFalse(handler.inUseLink(LINK_A_NAME, provider.getConnection()));
// Create job and submission and make that job in use to make sure link is
// in use.
@@ -227,7 +225,7 @@ public class TestLinkHandling extends MySqlTestCase {
MSubmission submission = getSubmission(job, SubmissionStatus.RUNNING);
handler.createSubmission(submission, provider.getConnection());
- assertTrue(handler.inUseLink(linkA.getPersistenceId(),
+ assertTrue(handler.inUseLink(linkA.getName(),
provider.getConnection()));
}
@@ -266,14 +264,14 @@ public class TestLinkHandling extends MySqlTestCase {
@Test
public void testEnableAndDisableLink() throws Exception {
// disable link 1
- handler.enableLink(1, false, provider.getConnection());
+ handler.enableLink(LINK_A_NAME, false, provider.getConnection());
MLink retrieved = handler.findLink(1, provider.getConnection());
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable link 1
- handler.enableLink(1, true, provider.getConnection());
+ handler.enableLink(LINK_A_NAME, true, provider.getConnection());
retrieved = handler.findLink(1, provider.getConnection());
assertNotNull(retrieved);
@@ -282,13 +280,13 @@ public class TestLinkHandling extends MySqlTestCase {
@Test
public void testDeleteLink() throws Exception {
- handler.deleteLink(1, provider.getConnection());
+ handler.deleteLink(LINK_A_NAME, provider.getConnection());
Assert
.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_LINK")), 1);
Assert.assertEquals(
provider.rowCount(new TableName("SQOOP", "SQ_LINK_INPUT")), 2);
- handler.deleteLink(2, provider.getConnection());
+ handler.deleteLink(LINK_B_NAME, provider.getConnection());
Assert
.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_LINK")), 0);
Assert.assertEquals(
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
index e2a3011..faf01cb 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/TestSubmissionHandling.java
@@ -291,7 +291,7 @@ public class TestSubmissionHandling extends MySqlTestCase {
submission.getError().setErrorSummary(errorSummary + "morethan150");
handler.createSubmission(submission, provider.getConnection());
- List<MSubmission> submissions = handler.findSubmissionsForJob(1,
+ List<MSubmission> submissions = handler.findSubmissionsForJob(JOB_A_NAME,
provider.getConnection());
assertNotNull(submissions);
@@ -395,11 +395,11 @@ public class TestSubmissionHandling extends MySqlTestCase {
Assert.assertEquals(
provider.rowCount(new TableName("SQOOP", "SQ_SUBMISSION")), 4);
- handler.deleteJob(jobA.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(jobA.getName(), provider.getConnection());
Assert.assertEquals(
provider.rowCount(new TableName("SQOOP", "SQ_SUBMISSION")), 2);
- handler.deleteJob(jobB.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(jobB.getName(), provider.getConnection());
Assert.assertEquals(
provider.rowCount(new TableName("SQOOP", "SQ_SUBMISSION")), 0);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestJobHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestJobHandling.java b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestJobHandling.java
index 2ad43dd..3a08268 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestJobHandling.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestJobHandling.java
@@ -79,7 +79,7 @@ public class TestJobHandling extends PostgresqlTestCase {
@Test
public void testFindJobFail() throws Exception {
for (MJob job : handler.findJobs(provider.getConnection())) {
- handler.deleteJob(job.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(job.getName(), provider.getConnection());
}
// Let's try to find non existing job
@@ -128,7 +128,7 @@ public class TestJobHandling extends PostgresqlTestCase {
// Delete jobs
for (MJob job : handler.findJobs(provider.getConnection())) {
- handler.deleteJob(job.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(job.getName(), provider.getConnection());
}
// Load all two links on loaded repository
@@ -154,19 +154,19 @@ public class TestJobHandling extends PostgresqlTestCase {
@Test
public void testExistsJob() throws Exception {
- assertTrue(handler.existsJob(1, provider.getConnection()));
- assertTrue(handler.existsJob(2, provider.getConnection()));
- assertFalse(handler.existsJob(3, provider.getConnection()));
+ assertTrue(handler.existsJob(JOB_A_NAME, provider.getConnection()));
+ assertTrue(handler.existsJob(JOB_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsJob("NONEXISTJOB", provider.getConnection()));
// Delete jobs
for (MJob job : handler.findJobs(provider.getConnection())) {
- handler.deleteJob(job.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(job.getName(), provider.getConnection());
}
// There shouldn't be anything on empty repository
- assertFalse(handler.existsJob(1, provider.getConnection()));
- assertFalse(handler.existsJob(2, provider.getConnection()));
- assertFalse(handler.existsJob(3, provider.getConnection()));
+ assertFalse(handler.existsJob(JOB_A_NAME, provider.getConnection()));
+ assertFalse(handler.existsJob(JOB_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsJob("NONEXISTJOB", provider.getConnection()));
}
@Test
@@ -174,9 +174,9 @@ public class TestJobHandling extends PostgresqlTestCase {
MSubmission submission = getSubmission(handler.findJob(1, provider.getConnection()), SubmissionStatus.RUNNING);
handler.createSubmission(submission, provider.getConnection());
- assertTrue(handler.inUseJob(1, provider.getConnection()));
- assertFalse(handler.inUseJob(2, provider.getConnection()));
- assertFalse(handler.inUseJob(3, provider.getConnection()));
+ assertTrue(handler.inUseJob(JOB_A_NAME, provider.getConnection()));
+ assertFalse(handler.inUseJob(JOB_B_NAME, provider.getConnection()));
+ assertFalse(handler.inUseJob("NONEXISTJOB", provider.getConnection()));
}
@Test
@@ -263,14 +263,14 @@ public class TestJobHandling extends PostgresqlTestCase {
@Test
public void testEnableAndDisableJob() throws Exception {
// disable job 1
- handler.enableJob(1, false, provider.getConnection());
+ handler.enableJob(JOB_A_NAME, false, provider.getConnection());
MJob retrieved = handler.findJob(1, provider.getConnection());
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable job 1
- handler.enableJob(1, true, provider.getConnection());
+ handler.enableJob(JOB_A_NAME, true, provider.getConnection());
retrieved = handler.findJob(1, provider.getConnection());
assertNotNull(retrieved);
@@ -279,11 +279,11 @@ public class TestJobHandling extends PostgresqlTestCase {
@Test
public void testDeleteJob() throws Exception {
- handler.deleteJob(1, provider.getConnection());
+ handler.deleteJob(JOB_A_NAME, provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB")), 1);
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB_INPUT")), 6);
- handler.deleteJob(2, provider.getConnection());
+ handler.deleteJob(JOB_B_NAME, provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB")), 0);
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB_INPUT")), 0);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestLinkHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestLinkHandling.java b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestLinkHandling.java
index 92bb15b..498f18f 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestLinkHandling.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestLinkHandling.java
@@ -73,7 +73,7 @@ public class TestLinkHandling extends PostgresqlTestCase {
public void testFindLinkFail() {
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
assertNull(handler.findLink(1, provider.getConnection()));
@@ -124,7 +124,7 @@ public class TestLinkHandling extends PostgresqlTestCase {
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
// Load empty list on empty repository
@@ -135,43 +135,42 @@ public class TestLinkHandling extends PostgresqlTestCase {
@Test
public void testFindLinksByConnector() throws Exception {
List<MLink> list;
- Long connectorId = handler.findConnector("A", provider.getConnection()).getPersistenceId();
// Load all two links on loaded repository
- list = handler.findLinksForConnector(connectorId, provider.getConnection());
+ list = handler.findLinksForConnector("A", provider.getConnection());
assertEquals(1, list.size());
assertEquals(LINK_A_NAME, list.get(0).getName());
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
// Load empty list on empty repository
- list = handler.findLinksForConnector(connectorId, provider.getConnection());
+ list = handler.findLinksForConnector("A", provider.getConnection());
assertEquals(0, list.size());
}
@Test
public void testFindLinksByNonExistingConnector() throws Exception {
- List<MLink> list = handler.findLinksForConnector(11, provider.getConnection());
+ List<MLink> list = handler.findLinksForConnector("NONEXISTCONNECTOR", provider.getConnection());
assertEquals(0, list.size());
}
@Test
public void testExistsLink() throws Exception {
- assertTrue(handler.existsLink(1, provider.getConnection()));
- assertTrue(handler.existsLink(2, provider.getConnection()));
- assertFalse(handler.existsLink(3, provider.getConnection()));
+ assertTrue(handler.existsLink(LINK_A_NAME, provider.getConnection()));
+ assertTrue(handler.existsLink(LINK_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsLink("NONEXISTLINK", provider.getConnection()));
// Delete links
for (MLink link : handler.findLinks(provider.getConnection())) {
- handler.deleteLink(link.getPersistenceId(), provider.getConnection());
+ handler.deleteLink(link.getName(), provider.getConnection());
}
- assertFalse(handler.existsLink(1, provider.getConnection()));
- assertFalse(handler.existsLink(2, provider.getConnection()));
- assertFalse(handler.existsLink(3, provider.getConnection()));
+ assertFalse(handler.existsLink(LINK_A_NAME, provider.getConnection()));
+ assertFalse(handler.existsLink(LINK_B_NAME, provider.getConnection()));
+ assertFalse(handler.existsLink("NONEXISTLINK", provider.getConnection()));
}
@Test
@@ -209,7 +208,7 @@ public class TestLinkHandling extends PostgresqlTestCase {
@Test
public void testInUseLink() throws Exception {
- assertFalse(handler.inUseLink(1, provider.getConnection()));
+ assertFalse(handler.inUseLink(LINK_A_NAME, provider.getConnection()));
// Create job and submission and make that job in use to make sure link is in use.
MLink linkA = handler.findLink(LINK_A_NAME, provider.getConnection());
@@ -222,7 +221,7 @@ public class TestLinkHandling extends PostgresqlTestCase {
MSubmission submission = getSubmission(job, SubmissionStatus.RUNNING);
handler.createSubmission(submission, provider.getConnection());
- assertTrue(handler.inUseLink(linkA.getPersistenceId(), provider.getConnection()));
+ assertTrue(handler.inUseLink(linkA.getName(), provider.getConnection()));
}
@Test
@@ -258,14 +257,14 @@ public class TestLinkHandling extends PostgresqlTestCase {
@Test
public void testEnableAndDisableLink() throws Exception {
// disable link 1
- handler.enableLink(1, false, provider.getConnection());
+ handler.enableLink(LINK_A_NAME, false, provider.getConnection());
MLink retrieved = handler.findLink(1, provider.getConnection());
assertNotNull(retrieved);
assertEquals(false, retrieved.getEnabled());
// enable link 1
- handler.enableLink(1, true, provider.getConnection());
+ handler.enableLink(LINK_A_NAME, true, provider.getConnection());
retrieved = handler.findLink(1, provider.getConnection());
assertNotNull(retrieved);
@@ -274,11 +273,11 @@ public class TestLinkHandling extends PostgresqlTestCase {
@Test
public void testDeleteLink() throws Exception {
- handler.deleteLink(1, provider.getConnection());
+ handler.deleteLink(LINK_A_NAME, provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_LINK")), 1);
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_LINK_INPUT")), 2);
- handler.deleteLink(2, provider.getConnection());
+ handler.deleteLink(LINK_B_NAME, provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_LINK")), 0);
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_LINK_INPUT")), 0);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
index c97b4f8..cd3367e 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
@@ -276,7 +276,7 @@ public class TestSubmissionHandling extends PostgresqlTestCase {
submission.getError().setErrorSummary(errorSummary + "morethan150");
handler.createSubmission(submission, provider.getConnection());
- List<MSubmission> submissions = handler.findSubmissionsForJob(1, provider.getConnection());
+ List<MSubmission> submissions = handler.findSubmissionsForJob(JOB_A_NAME, provider.getConnection());
assertNotNull(submissions);
assertEquals(errorDetail, submissions.get(0).getError().getErrorDetails());
@@ -370,10 +370,10 @@ public class TestSubmissionHandling extends PostgresqlTestCase {
loadSubmissions();
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_SUBMISSION")), 4);
- handler.deleteJob(jobA.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(jobA.getName(), provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_SUBMISSION")), 2);
- handler.deleteJob(jobB.getPersistenceId(), provider.getConnection());
+ handler.deleteJob(jobB.getName(), provider.getConnection());
Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_SUBMISSION")), 0);
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
index 60b124c..f9c1de2 100644
--- a/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/ConnectorRequestHandler.java
@@ -79,12 +79,13 @@ public class ConnectorRequestHandler implements RequestHandler {
} else {
// NOTE: we now support using unique name as well as the connector id
// NOTE: connectorId is a fallback for older sqoop clients if any, since we want to primarily use unique conenctorNames
- long cId = HandlerUtils.getConnectorIdFromIdentifier(cIdentifier);
+ String cName = HandlerUtils.getConnectorNameFromIdentifier(cIdentifier);
configParamBundles = new HashMap<Long, ResourceBundle>();
- MConnector connector = ConnectorManager.getInstance().getConnectorConfigurable(cId);
- configParamBundles.put(cId, ConnectorManager.getInstance().getResourceBundle(cId, locale));
+ MConnector connector = ConnectorManager.getInstance().getConnectorConfigurable(cName);
+ configParamBundles.put(connector.getPersistenceId(),
+ ConnectorManager.getInstance().getResourceBundle(cName, locale));
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "get", "connector", String.valueOf(cIdentifier));
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index cb9485f..f65cb81 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -139,7 +139,6 @@ public class JobRequestHandler implements RequestHandler {
Repository repository = RepositoryManager.getInstance().getRepository();
String jobIdentifier = ctx.getLastURLElement();
- long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
String jobName = HandlerUtils.getJobNameFromIdentifier(jobIdentifier);
// Authorization check
@@ -147,7 +146,7 @@ public class JobRequestHandler implements RequestHandler {
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "delete", "job", jobIdentifier);
- repository.deleteJob(jobId);
+ repository.deleteJob(jobName);
MResource resource = new MResource(jobName, MResource.TYPE.JOB);
AuthorizationManager.getInstance().getAuthorizationHandler().removeResource(resource);
return JsonBean.EMPTY_BEAN;
@@ -322,19 +321,19 @@ public class JobRequestHandler implements RequestHandler {
private JobBean createJobBean(List<MJob> jobs, Locale locale) {
JobBean jobBean = new JobBean(jobs);
- addJob(jobs, locale, jobBean);
+ addConnectorConfigBundle(jobBean, locale);
return jobBean;
}
private JobsBean createJobsBean(List<MJob> jobs, Locale locale) {
JobsBean jobsBean = new JobsBean(jobs);
- addJob(jobs, locale, jobsBean);
+ addConnectorConfigBundle(jobsBean, locale);
return jobsBean;
}
- private void addJob(List<MJob> jobs, Locale locale, JobBean bean) {
+ private void addConnectorConfigBundle(JobBean bean, Locale locale) {
// Add associated resources into the bean
- for (MJob job : jobs) {
+ for (MJob job : bean.getJobs()) {
long fromConnectorId = job.getFromConnectorId();
long toConnectorId = job.getToConnectorId();
// replace it only if it does not already exist
@@ -353,13 +352,12 @@ public class JobRequestHandler implements RequestHandler {
Repository repository = RepositoryManager.getInstance().getRepository();
String[] elements = ctx.getUrlElements();
String jobIdentifier = elements[elements.length - 2];
- long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
String jobName = HandlerUtils.getJobNameFromIdentifier(jobIdentifier);
// Authorization check
AuthorizationEngine.enableDisableJob(ctx.getUserName(), jobName);
- repository.enableJob(jobId, enabled);
+ repository.enableJob(jobName, enabled);
return JsonBean.EMPTY_BEAN;
}
@@ -385,7 +383,7 @@ public class JobRequestHandler implements RequestHandler {
}
MSubmission submission = JobManager.getInstance()
- .start(jobId, prepareRequestEventContext(ctx));
+ .start(jobId, jobName, prepareRequestEventContext(ctx));
return new SubmissionBean(submission);
}
@@ -400,7 +398,7 @@ public class JobRequestHandler implements RequestHandler {
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "stop", "job", String.valueOf(jobId));
- MSubmission submission = JobManager.getInstance().stop(jobId, prepareRequestEventContext(ctx));
+ MSubmission submission = JobManager.getInstance().stop(jobId, jobName, prepareRequestEventContext(ctx));
return new SubmissionBean(submission);
}
@@ -415,7 +413,7 @@ public class JobRequestHandler implements RequestHandler {
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "status", "job", String.valueOf(jobId));
- MSubmission submission = JobManager.getInstance().status(jobId);
+ MSubmission submission = JobManager.getInstance().status(jobId, jobName);
return new SubmissionBean(submission);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index 3041646..fe0c4d8 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -93,7 +93,6 @@ public class LinkRequestHandler implements RequestHandler {
Repository repository = RepositoryManager.getInstance().getRepository();
String linkIdentifier = ctx.getLastURLElement();
// support linkName or linkId for the api
- long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier);
String linkName = HandlerUtils.getLinkNameFromIdentifier(linkIdentifier);
// Authorization check
@@ -102,7 +101,7 @@ public class LinkRequestHandler implements RequestHandler {
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "delete", "link", linkIdentifier);
- repository.deleteLink(linkId);
+ repository.deleteLink(linkName);
MResource resource = new MResource(linkName, MResource.TYPE.LINK);
AuthorizationManager.getInstance().getAuthorizationHandler().removeResource(resource);
return JsonBean.EMPTY_BEAN;
@@ -156,9 +155,9 @@ public class LinkRequestHandler implements RequestHandler {
if (!create) {
String linkIdentifier = ctx.getLastURLElement();
// support linkName or linkId for the api
- long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier);
+ String linkName = HandlerUtils.getLinkNameFromIdentifier(linkIdentifier);
if (postedLink.getPersistenceId() == MPersistableEntity.PERSISTANCE_ID_DEFAULT) {
- MLink existingLink = repository.findLink(linkId);
+ MLink existingLink = repository.findLink(linkName);
postedLink.setPersistenceId(existingLink.getPersistenceId());
}
}
@@ -207,8 +206,8 @@ public class LinkRequestHandler implements RequestHandler {
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "get", "linksByConnector", identifier);
if (repository.findConnector(identifier) != null) {
- long connectorId = repository.findConnector(identifier).getPersistenceId();
- List<MLink> linkList = repository.findLinksForConnector(connectorId);
+ String connectorName = repository.findConnector(identifier).getUniqueName();
+ List<MLink> linkList = repository.findLinksForConnector(connectorName);
// Authorization check
linkList = AuthorizationEngine.filterResource(ctx.getUserName(), MResource.TYPE.LINK, linkList);
@@ -237,8 +236,8 @@ public class LinkRequestHandler implements RequestHandler {
AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
ctx.getRequest().getRemoteAddr(), "get", "link", identifier);
- long linkId = HandlerUtils.getLinkIdFromIdentifier(identifier);
- MLink link = repository.findLink(linkId);
+ String linkName = HandlerUtils.getLinkNameFromIdentifier(identifier);
+ MLink link = repository.findLink(linkName);
// Authorization check
AuthorizationEngine.readLink(ctx.getUserName(), link.getName());
@@ -250,19 +249,19 @@ public class LinkRequestHandler implements RequestHandler {
private LinkBean createLinkBean(List<MLink> links, Locale locale) {
LinkBean linkBean = new LinkBean(links);
- addLink(links, locale, linkBean);
+ addConnectorConfigBundle(locale, linkBean);
return linkBean;
}
private LinksBean createLinksBean(List<MLink> links, Locale locale) {
LinksBean linksBean = new LinksBean(links);
- addLink(links, locale, linksBean);
+ addConnectorConfigBundle(locale, linksBean);
return linksBean;
}
- private void addLink(List<MLink> links, Locale locale, LinkBean bean) {
+ private void addConnectorConfigBundle(Locale locale, LinkBean bean) {
// Add associated resources into the bean
- for (MLink link : links) {
+ for (MLink link : bean.getLinks()) {
long connectorId = link.getConnectorId();
if (!bean.hasConnectorConfigBundle(connectorId)) {
bean.addConnectorConfigBundle(connectorId, ConnectorManager.getInstance()
@@ -275,13 +274,12 @@ public class LinkRequestHandler implements RequestHandler {
Repository repository = RepositoryManager.getInstance().getRepository();
String[] elements = ctx.getUrlElements();
String linkIdentifier = elements[elements.length - 2];
- long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier);
String linkName = HandlerUtils.getLinkNameFromIdentifier(linkIdentifier);
// Authorization check
AuthorizationEngine.enableDisableLink(ctx.getUserName(), linkName);
- repository.enableLink(linkId, enabled);
+ repository.enableLink(linkName, enabled);
return JsonBean.EMPTY_BEAN;
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
index 4b99239..02937bb 100644
--- a/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/SubmissionRequestHandler.java
@@ -75,14 +75,13 @@ public class SubmissionRequestHandler implements RequestHandler {
}
private JsonBean getSubmissionsForJob(String jobIdentifier, RequestContext ctx) {
- long jobId = HandlerUtils.getJobIdFromIdentifier(jobIdentifier);
String jobName = HandlerUtils.getJobNameFromIdentifier(jobIdentifier);
//Authorization check
AuthorizationEngine.statusJob(ctx.getUserName(), jobName);
List<MSubmission> submissions = RepositoryManager.getInstance().getRepository()
- .findSubmissionsForJob(jobId);
+ .findSubmissionsForJob(jobName);
return new SubmissionsBean(submissions);
}
[2/2] sqoop git commit: SQOOP-2573: Sqoop2: Use object name instead
of object id for job, link and connector in Sqoop 2 server
Posted by ja...@apache.org.
SQOOP-2573: Sqoop2: Use object name instead of object id for job, link and connector in Sqoop 2 server
(Dian Fu 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/a3c37472
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/a3c37472
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/a3c37472
Branch: refs/heads/sqoop2
Commit: a3c374723f7e55423be820c58a5bdc4127c0c414
Parents: f241f82
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Thu Sep 17 07:38:53 2015 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Thu Sep 17 07:38:53 2015 -0700
----------------------------------------------------------------------
.../sqoop/connector/ConnectorManager.java | 20 +-
.../org/apache/sqoop/driver/JobManager.java | 12 +-
.../apache/sqoop/repository/JdbcRepository.java | 191 ++++-------------
.../sqoop/repository/JdbcRepositoryHandler.java | 131 ++++--------
.../org/apache/sqoop/repository/Repository.java | 126 +++--------
.../sqoop/repository/RepositoryError.java | 12 +-
.../sqoop/repository/TestJdbcRepository.java | 156 +++++++-------
.../common/CommonRepositoryHandler.java | 209 ++++---------------
...RepositoryInsertUpdateDeleteSelectQuery.java | 77 ++++---
.../sqoop/repository/derby/TestJobHandling.java | 173 ++-------------
.../repository/derby/TestLinkHandling.java | 74 ++-----
.../derby/TestSubmissionHandling.java | 10 +-
.../repository/mysql/TestJobHandling.java | 34 +--
.../repository/mysql/TestLinkHandling.java | 40 ++--
.../mysql/TestSubmissionHandling.java | 6 +-
.../repository/postgresql/TestJobHandling.java | 32 +--
.../repository/postgresql/TestLinkHandling.java | 39 ++--
.../postgresql/TestSubmissionHandling.java | 6 +-
.../sqoop/handler/ConnectorRequestHandler.java | 7 +-
.../apache/sqoop/handler/JobRequestHandler.java | 20 +-
.../sqoop/handler/LinkRequestHandler.java | 26 ++-
.../sqoop/handler/SubmissionRequestHandler.java | 3 +-
22 files changed, 426 insertions(+), 978 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index 5f269aa..b0a6841 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -127,30 +127,34 @@ public class ConnectorManager implements Reconfigurable {
}
public ResourceBundle getResourceBundle(long connectorId, Locale locale) {
- ConnectorHandler handler = handlerMap.get(idToNameMap.get(connectorId));
+ return getResourceBundle(idToNameMap.get(connectorId), locale);
+ }
+
+ public ResourceBundle getResourceBundle(String connectorName, Locale locale) {
+ ConnectorHandler handler = handlerMap.get(connectorName);
return handler.getSqoopConnector().getBundle(locale);
}
public MConnector getConnectorConfigurable(long connectorId) {
- ConnectorHandler handler = handlerMap.get(idToNameMap.get(connectorId));
- if (handler == null) {
+ String connectorName = idToNameMap.get(connectorId);
+ if (connectorName == null) {
throw new SqoopException(CommonRepositoryError.COMMON_0057, "Couldn't find"
- + " connector with id " + connectorId);
+ + " connector with id " + connectorId);
}
- return handler.getConnectorConfigurable();
+ return getConnectorConfigurable(connectorName);
}
public MConnector getConnectorConfigurable(String connectorName) {
ConnectorHandler handler = handlerMap.get(connectorName);
if (handler == null) {
- return null;
+ throw new SqoopException(CommonRepositoryError.COMMON_0057, "Couldn't find"
+ + " connector with name " + connectorName);
}
return handler.getConnectorConfigurable();
}
public SqoopConnector getSqoopConnector(long connectorId) {
- ConnectorHandler handler = handlerMap.get(idToNameMap.get(connectorId));
- return handler.getSqoopConnector();
+ return getSqoopConnector(idToNameMap.get(connectorId));
}
public SqoopConnector getSqoopConnector(String uniqueName) {
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 dc90a0e..923df0d 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
@@ -277,7 +277,7 @@ public class JobManager implements Reconfigurable {
LOG.info("Submission manager initialized: OK");
}
- public MSubmission start(long jobId, HttpEventContext ctx) {
+ public MSubmission start(long jobId, String jobName, HttpEventContext ctx) {
MSubmission mSubmission = createJobSubmission(ctx, jobId);
JobRequest jobRequest = createJobRequest(jobId, mSubmission);
@@ -287,7 +287,7 @@ public class JobManager implements Reconfigurable {
// only if it's not.
synchronized (JobManager.class) {
MSubmission lastSubmission = RepositoryManager.getInstance().getRepository()
- .findLastSubmissionForJob(jobId);
+ .findLastSubmissionForJob(jobName);
if (lastSubmission != null && lastSubmission.getStatus().isRunning()) {
throw new SqoopException(DriverError.DRIVER_0002, "Job with id " + jobId);
}
@@ -606,10 +606,10 @@ public class JobManager implements Reconfigurable {
request.getJobConfig(Direction.TO));
}
- public MSubmission stop(long jobId, HttpEventContext ctx) {
+ public MSubmission stop(long jobId, String jobName, HttpEventContext ctx) {
Repository repository = RepositoryManager.getInstance().getRepository();
- MSubmission mSubmission = repository.findLastSubmissionForJob(jobId);
+ MSubmission mSubmission = repository.findLastSubmissionForJob(jobName);
if (mSubmission == null || !mSubmission.getStatus().isRunning()) {
throw new SqoopException(DriverError.DRIVER_0003, "Job with id " + jobId
@@ -626,9 +626,9 @@ public class JobManager implements Reconfigurable {
return mSubmission;
}
- public MSubmission status(long jobId) {
+ public MSubmission status(long jobId, String jobName) {
Repository repository = RepositoryManager.getInstance().getRepository();
- MSubmission mSubmission = repository.findLastSubmissionForJob(jobId);
+ MSubmission mSubmission = repository.findLastSubmissionForJob(jobName);
if (mSubmission == null) {
return new MSubmission(jobId, new Date(), SubmissionStatus.NEVER_EXECUTED);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 d7aa8ef..0bddf5b 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -23,8 +23,6 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.sqoop.common.SqoopException;
-import org.apache.sqoop.model.MConfig;
-import org.apache.sqoop.model.MConfigUpdateEntityType;
import org.apache.sqoop.model.MConnector;
import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MJob;
@@ -307,9 +305,9 @@ public class JdbcRepository extends Repository {
if (!link.hasPersistenceId()) {
throw new SqoopException(RepositoryError.JDBCREPO_0016);
}
- if (!handler.existsLink(link.getPersistenceId(), conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0017, "Invalid id: "
- + link.getPersistenceId());
+ if (!handler.existsLink(link.getName(), conn)) {
+ throw new SqoopException(RepositoryError.JDBCREPO_0017, "Invalid name: "
+ + link.getName());
}
handler.updateLink(link, conn);
@@ -322,16 +320,16 @@ public class JdbcRepository extends Repository {
* {@inheritDoc}
*/
@Override
- public void enableLink(final long linkId, final boolean enabled) {
+ public void enableLink(final String linkName, final boolean enabled) {
doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) {
- if(!handler.existsLink(linkId, conn)) {
+ if(!handler.existsLink(linkName, conn)) {
throw new SqoopException(RepositoryError.JDBCREPO_0017,
- "Invalid id: " + linkId);
+ "Invalid name: " + linkName);
}
- handler.enableLink(linkId, enabled, conn);
+ handler.enableLink(linkName, enabled, conn);
return null;
}
});
@@ -341,20 +339,20 @@ public class JdbcRepository extends Repository {
* {@inheritDoc}
*/
@Override
- public void deleteLink(final long linkId) {
+ public void deleteLink(final String linkName) {
doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) {
- if(!handler.existsLink(linkId, conn)) {
+ if(!handler.existsLink(linkName, conn)) {
throw new SqoopException(RepositoryError.JDBCREPO_0017,
- "Invalid id: " + linkId);
+ "Invalid name: " + linkName);
}
- if(handler.inUseLink(linkId, conn)) {
+ if(handler.inUseLink(linkName, conn)) {
throw new SqoopException(RepositoryError.JDBCREPO_0021,
- "Id in use: " + linkId);
+ "Name in use: " + linkName);
}
- handler.deleteLink(linkId, conn);
+ handler.deleteLink(linkName, conn);
return null;
}
});
@@ -405,11 +403,11 @@ public class JdbcRepository extends Repository {
*/
@SuppressWarnings("unchecked")
@Override
- public List<MLink> findLinksForConnector(final long connectorId) {
+ public List<MLink> findLinksForConnector(final String connectorName) {
return (List<MLink>) doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) throws Exception {
- return handler.findLinksForConnector(connectorId, conn);
+ return handler.findLinksForConnector(connectorName, conn);
}
});
}
@@ -451,7 +449,7 @@ public class JdbcRepository extends Repository {
if(!job.hasPersistenceId()) {
throw new SqoopException(RepositoryError.JDBCREPO_0019);
}
- if(!handler.existsJob(job.getPersistenceId(), conn)) {
+ if(!handler.existsJob(job.getName(), conn)) {
throw new SqoopException(RepositoryError.JDBCREPO_0020,
"Invalid id: " + job.getPersistenceId());
}
@@ -466,16 +464,16 @@ public class JdbcRepository extends Repository {
* {@inheritDoc}
*/
@Override
- public void enableJob(final long id, final boolean enabled) {
+ public void enableJob(final String jobName, final boolean enabled) {
doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) {
- if(!handler.existsJob(id, conn)) {
+ if(!handler.existsJob(jobName, conn)) {
throw new SqoopException(RepositoryError.JDBCREPO_0020,
- "Invalid id: " + id);
+ "Invalid name: " + jobName);
}
- handler.enableJob(id, enabled, conn);
+ handler.enableJob(jobName, enabled, conn);
return null;
}
});
@@ -485,18 +483,18 @@ public class JdbcRepository extends Repository {
* {@inheritDoc}
*/
@Override
- public void deleteJob(final long id) {
+ public void deleteJob(final String jobName) {
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(jobName, conn)) {
+ throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobName);
}
- if (handler.inUseJob(id, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0022, "Id in use: " + id);
+ if (handler.inUseJob(jobName, conn)) {
+ throw new SqoopException(RepositoryError.JDBCREPO_0022, "Name in use: " + jobName);
}
- handler.deleteJob(id, conn);
+ handler.deleteJob(jobName, conn);
return null;
}
});
@@ -643,15 +641,15 @@ public class JdbcRepository extends Repository {
*/
@SuppressWarnings("unchecked")
@Override
- public List<MSubmission> findSubmissionsForJob(final long jobId) {
+ public List<MSubmission> findSubmissionsForJob(final String jobName) {
return (List<MSubmission>) doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) throws Exception {
- if(!handler.existsJob(jobId, conn)) {
+ if(!handler.existsJob(jobName, conn)) {
throw new SqoopException(RepositoryError.JDBCREPO_0020,
- "Invalid id: " + jobId);
+ "Invalid name: " + jobName);
}
- return handler.findSubmissionsForJob(jobId, conn);
+ return handler.findSubmissionsForJob(jobName, conn);
}
});
}
@@ -660,148 +658,35 @@ public class JdbcRepository extends Repository {
* {@inheritDoc}
*/
@Override
- public MSubmission findLastSubmissionForJob(final long jobId) {
+ public MSubmission findLastSubmissionForJob(final String jobName) {
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(jobName, conn)) {
+ throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid name: " + jobName);
}
- return handler.findLastSubmissionForJob(jobId, conn);
+ return handler.findLastSubmissionForJob(jobName, conn);
}
});
}
- /**
- * {@inheritDoc}
- */
- @Override
- public MConfig findFromJobConfig(final long jobId, final String configName) {
- return (MConfig) doWithConnection(new DoWithConnection() {
- @Override
- public Object doIt(Connection conn) {
- if (!handler.existsJob(jobId, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- return handler.findFromJobConfig(jobId, configName, conn);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public MConfig findToJobConfig(final long jobId, final String configName) {
- return (MConfig) doWithConnection(new DoWithConnection() {
- @Override
- public Object doIt(Connection conn) {
- if (!handler.existsJob(jobId, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- return handler.findToJobConfig(jobId, configName, conn);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public MConfig findDriverJobConfig(final long jobId, final String configName) {
- return (MConfig) doWithConnection(new DoWithConnection() {
- @Override
- public Object doIt(Connection conn) {
- if (!handler.existsJob(jobId, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- return handler.findDriverJobConfig(jobId, configName, conn);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public MConfig findLinkConfig(final long linkId, final String configName) {
- return (MConfig) doWithConnection(new DoWithConnection() {
- @Override
- public Object doIt(Connection conn) {
- if (!handler.existsLink(linkId, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0017, "Invalid id: " + linkId);
- }
- return handler.findLinkConfig(linkId, configName, conn);
- }
- });
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void updateJobConfig(final long jobId, final MConfig config, final MConfigUpdateEntityType type) {
- updateJobConfig(jobId, config, type, null);
- }
- /**
- * {@inheritDoc}
- */
- @Override
- public void updateJobConfig(final long jobId, final MConfig config, final MConfigUpdateEntityType type, RepositoryTransaction tx) {
- doWithConnection(new DoWithConnection() {
- @Override
- public Object doIt(Connection conn) {
- if (!handler.existsJob(jobId, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- handler.updateJobConfig(jobId, config, type, conn);
- return null;
- }
- }, (JdbcRepositoryTransaction) tx);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void updateLinkConfig(final long linkId, final MConfig config, final MConfigUpdateEntityType type) {
- updateLinkConfig(linkId, config, type, null);
- }
- /**
- * {@inheritDoc}
- */
- @Override
- public void updateLinkConfig(final long linkId, final MConfig config, final MConfigUpdateEntityType type, RepositoryTransaction tx) {
- doWithConnection(new DoWithConnection() {
- @Override
- public Object doIt(Connection conn) {
- if (!handler.existsLink(linkId, conn)) {
- throw new SqoopException(RepositoryError.JDBCREPO_0017, "Invalid id: " + linkId);
- }
- handler.updateLinkConfig(linkId, config, type, conn);
- return null;
- }
- }, (JdbcRepositoryTransaction) tx);
- }
-
@Override
- protected void deleteJobInputs(final long jobID, RepositoryTransaction tx) {
+ protected void deleteJobInputs(final String jobName, RepositoryTransaction tx) {
doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) throws Exception {
- handler.deleteJobInputs(jobID, conn);
+ handler.deleteJobInputs(jobName, conn);
return null;
}
}, (JdbcRepositoryTransaction) tx);
}
@Override
- protected void deleteLinkInputs(final long linkId, RepositoryTransaction tx) {
+ protected void deleteLinkInputs(final String linkName, RepositoryTransaction tx) {
doWithConnection(new DoWithConnection() {
@Override
public Object doIt(Connection conn) throws Exception {
- handler.deleteLinkInputs(linkId, conn);
+ handler.deleteLinkInputs(linkName, conn);
return null;
}
}, (JdbcRepositoryTransaction) tx);
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 5cbeda8..b4c3d9b 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
@@ -21,8 +21,6 @@ import java.sql.Connection;
import java.util.Date;
import java.util.List;
-import org.apache.sqoop.model.MConfig;
-import org.apache.sqoop.model.MConfigUpdateEntityType;
import org.apache.sqoop.model.MConnector;
import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MJob;
@@ -84,11 +82,11 @@ public abstract class JdbcRepositoryHandler {
/**
* Retrieve links which use the given connector.
- * @param connectorId Connector ID whose links should be fetched
+ * @param connectorName Connector name whose links should be fetched
* @param conn JDBC link for querying repository
* @return List of MLinks that use <code>connectorID</code>.
*/
- public abstract List<MLink> findLinksForConnector(long connectorId, Connection conn);
+ public abstract List<MLink> findLinksForConnector(String connectorName, Connection conn);
/**
* Retrieve jobs which use the given link.
@@ -209,46 +207,46 @@ public abstract class JdbcRepositoryHandler {
/**
* Check if given link exists in repository.
*
- * @param linkId Link id
+ * @param linkName Link name
* @param conn Connection to the repository
* @return True if the link exists
*/
- public abstract boolean existsLink(long linkId, Connection conn);
+ public abstract boolean existsLink(String linkName, Connection conn);
/**
- * Check if given Connection id is referenced somewhere and thus can't
+ * Check if given link is referenced somewhere and thus can't
* be removed.
*
- * @param linkId Link id
+ * @param linkName Link name
* @param conn Connection to the repository
* @return
*/
- public abstract boolean inUseLink(long linkId, Connection conn);
+ public abstract boolean inUseLink(String linkName, Connection conn);
/**
- * Enable or disable link with given id from the repository
+ * Enable or disable link with given name from the repository
*
- * @param linkId Link object that is going to be enabled or disabled
+ * @param linkName Link object that is going to be enabled or disabled
* @param enabled Enable or disable
* @param conn Connection to the repository
*/
- public abstract void enableLink(long linkId, boolean enabled, Connection conn);
+ public abstract void enableLink(String linkName, boolean enabled, Connection conn);
/**
- * Delete link with given id from the repository.
+ * Delete link with given name from the repository.
*
- * @param linkId Link object that should be removed from repository
+ * @param linkName Link object that should be removed from repository
* @param conn Connection to the repository
*/
- public abstract void deleteLink(long linkId, Connection conn);
+ public abstract void deleteLink(String linkName, Connection conn);
/**
- * Delete the input values for the link with given id from the
+ * Delete the input values for the link with given name from the
* repository.
- * @param linkId Link object whose inputs should be removed from repository
+ * @param linkName Link object whose inputs should be removed from repository
* @param conn Connection to the repository
*/
- protected abstract void deleteLinkInputs(long linkId, Connection conn);
+ protected abstract void deleteLinkInputs(String linkName, Connection conn);
/**
* Find link with given id in repository.
@@ -299,45 +297,45 @@ public abstract class JdbcRepositoryHandler {
/**
* Check if given job exists in the repository.
*
- * @param jobId Job id
+ * @param jobName Job name
* @param conn Connection to the repository
* @return True if the job exists
*/
- public abstract boolean existsJob(long jobId, Connection conn);
+ public abstract boolean existsJob(String jobName, Connection conn);
/**
- * Check if given job id is referenced somewhere and thus can't
+ * Check if given job is referenced somewhere and thus can't
* be removed.
*
- * @param jobId Job id
+ * @param jobName Job name
* @param conn Connection to the repository
* @return
*/
- public abstract boolean inUseJob(long jobId, Connection conn);
+ public abstract boolean inUseJob(String jobName, Connection conn);
/**
- * Enable or disable job with given id from the repository
+ * Enable or disable job with given name from the repository
*
- * @param jobId Job id
+ * @param jobName Job name
* @param enabled Enable or disable
* @param conn Connection to the repository
*/
- public abstract void enableJob(long jobId, boolean enabled, Connection conn);
+ public abstract void enableJob(String jobName, boolean enabled, Connection conn);
/**
- * Delete the input values for the job with given id from the repository.
- * @param id Job object whose inputs should be removed from repository
+ * Delete the input values for the job with given name from the repository.
+ * @param jobName Job object whose inputs should be removed from repository
* @param conn Connection to the repository
*/
- protected abstract void deleteJobInputs(long id, Connection conn);
+ protected abstract void deleteJobInputs(String jobName, Connection conn);
/**
- * Delete job with given id from the repository. This method will
+ * Delete job with given name from the repository. This method will
* delete all inputs for this job also.
*
- * @param jobId Job object that should be removed from repository
+ * @param jobName Job object that should be removed from repository
* @param conn Connection to the repository
*/
- public abstract void deleteJob(long jobId, Connection conn);
+ public abstract void deleteJob(String jobName, Connection conn);
/**
* Find job with given id in repository.
@@ -414,77 +412,20 @@ public abstract class JdbcRepositoryHandler {
public abstract List<MSubmission> findSubmissions(Connection conn);
/**
- * Return list of submissions from the repository for given jobId.
- * @param jobId Job id
+ * Return list of submissions from the repository for given jobName.
+ * @param jobName Job name
* @param conn Connection to the repository
* @return List of submissions
*/
- public abstract List<MSubmission> findSubmissionsForJob(long jobId, Connection conn);
+ public abstract List<MSubmission> findSubmissionsForJob(String jobName, Connection conn);
/**
- * Find last submission for given jobId.
+ * Find last submission for given jobName.
*
- * @param jobId Job id
+ * @param jobName Job name
* @param conn Connection to the repository
* @return Most recent submission
*/
- public abstract MSubmission findLastSubmissionForJob(long jobId, Connection conn);
-
- /**
- * fetch the job config for the FROM type for the given name
- * @param jobId id of the job
- * @param configName name of the config unique to this job and type
- * @param conn Connection to the repository
- * @return config object
- */
- public abstract MConfig findFromJobConfig(long jobId, String configName, Connection con);
-
-
- /**
- * fetch the job config for the TO type for the given name
- * @param jobId id of the job
- * @param configName name of the config unique to this job and type
- * @param conn Connection to the repository
- * @return config object
- */
- public abstract MConfig findToJobConfig(long jobId, String configName, Connection con);
-
-
- /**
- * fetch the job config for the DRIVER type for the given name
- * @param jobId id of the job
- * @param configName name of the config unique to this job and type
- * @param conn Connection to the repository
- * @return config object
- */
- public abstract MConfig findDriverJobConfig(long jobId, String configName, Connection con);
-
-
- /**
- * fetch the link config for the link type for the given name
- * @param linkId id of the link
- * @param configName name of the config unique to this link and type
- * @param conn Connection to the repository
- * @return config object
- */
- public abstract MConfig findLinkConfig(long linkId, String configName, Connection con);
-
- /**
- * Update the config object for the job
- * @param jobId id of the job
- * @param config name of the config
- * @param type entity type updating the link config
- * @param conn Connection to the repository
- */
- public abstract void updateJobConfig(long jobId, MConfig config, MConfigUpdateEntityType type, Connection con);
-
- /**
- * Update the config object for the link
- * @param linkId id of the link
- * @param config name of the config
- * @param type entity type updating the link config
- * @param conn Connection to the repository
- */
- public abstract void updateLinkConfig(long linkId, MConfig config, MConfigUpdateEntityType type, Connection con);
+ public abstract MSubmission findLastSubmissionForJob(String jobName, Connection conn);
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 10af697..c15c96d 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -34,7 +34,6 @@ import org.apache.sqoop.driver.DriverUpgrader;
import org.apache.sqoop.json.DriverBean;
import org.apache.sqoop.model.ConfigUtils;
import org.apache.sqoop.model.MConfig;
-import org.apache.sqoop.model.MConfigUpdateEntityType;
import org.apache.sqoop.model.MConnector;
import org.apache.sqoop.model.MDriver;
import org.apache.sqoop.model.MDriverConfig;
@@ -169,19 +168,19 @@ public abstract class Repository {
public abstract void updateLink(final MLink link, RepositoryTransaction tx);
/**
- * Enable or disable Link with given id from the repository
+ * Enable or disable Link with given name from the repository
*
- * @param id Link object that is going to be enabled or disabled
+ * @param linkName Link object that is going to be enabled or disabled
* @param enabled enable or disable
*/
- public abstract void enableLink(long id, boolean enabled);
+ public abstract void enableLink(String linkName, boolean enabled);
/**
- * Delete Link with given id from the repository.
+ * Delete Link with given name from the repository.
*
- * @param id Link object that should be removed from repository
+ * @param linkName Link object that should be removed from repository
*/
- public abstract void deleteLink(long id);
+ public abstract void deleteLink(String linkName);
/**
* Find link with given id in repository.
@@ -201,10 +200,10 @@ public abstract class Repository {
/**
* Retrieve links which use the given connector.
- * @param connectorId Connector id whose links should be fetched
+ * @param connectorName Connector name whose links should be fetched
* @return List of MLink that use <code>connectorId</code>.
*/
- public abstract List<MLink> findLinksForConnector(long connectorId);
+ public abstract List<MLink> findLinksForConnector(String connectorName);
/**
* Get all Link objects.
@@ -242,19 +241,19 @@ public abstract class Repository {
public abstract void updateJob(MJob job, RepositoryTransaction tx);
/**
- * Enable or disable job with given id from entity repository
+ * Enable or disable job with given name from entity repository
*
- * @param id Job object that is going to be enabled or disabled
+ * @param jobName Job object that is going to be enabled or disabled
* @param enabled Enable or disable
*/
- public abstract void enableJob(long id, boolean enabled);
+ public abstract void enableJob(String jobName, boolean enabled);
/**
- * Delete job with given id from entity repository.
+ * Delete job with given name from entity repository.
*
- * @param id Job id that should be removed
+ * @param jobName Job name that should be removed
*/
- public abstract void deleteJob(long id);
+ public abstract void deleteJob(String jobName);
/**
* Find job object with given id.
@@ -323,90 +322,19 @@ public abstract class Repository {
public abstract List<MSubmission> findSubmissions();
/**
- * Return all submissions for given jobId.
+ * Return all submissions for given jobName.
*
* @return List of of submissions
*/
- public abstract List<MSubmission> findSubmissionsForJob(long jobId);
+ public abstract List<MSubmission> findSubmissionsForJob(String jobName);
/**
- * Find last submission for given jobId.
+ * Find last submission for given jobName.
*
- * @param jobId Job id
+ * @param jobName Job name
* @return Most recent submission
*/
- public abstract MSubmission findLastSubmissionForJob(long jobId);
-
- /**
- * fetch the job config for the FROM type for the given name
- * @param jobId id of the job
- * @param configName name of the config unique to this job and type
- * @return config object
- */
- public abstract MConfig findFromJobConfig(long jobId, String configName);
-
-
- /**
- * fetch the job config for the TO type for the given name
- * @param jobId id of the job
- * @param configName name of the config unique to this job and type
- * @return config object
- */
- public abstract MConfig findToJobConfig(long jobId, String configName);
-
-
- /**
- * fetch the job config for the DRIVER type for the given name
- * @param jobId id of the job
- * @param configName name of the config unique to this job and type
- * @return config object
- */
- public abstract MConfig findDriverJobConfig(long jobId, String configName);
-
-
- /**
- * fetch the link config for the link type for the given name
- * @param linkId id of the link
- * @param configName name of the config unique to this link and type
- * @return config object
- */
- public abstract MConfig findLinkConfig(long linkId, String configName);
-
-
- /**
- * Update the config object for the job
- * @param jobId id of the job
- * @param config name of the config
- * @param updateEntityType entity type updating the link config
- */
- public abstract void updateJobConfig(long jobId, MConfig config, MConfigUpdateEntityType updateEntityType);
-
- /**
- * Update the config object for the job
- * @param jobId id of the job
- * @param config name of the config
- * @param updateEntityType entity type updating the link config
- * @param tx database transaction
- */
- public abstract void updateJobConfig(long jobId, MConfig config, MConfigUpdateEntityType updateEntityType, RepositoryTransaction tx);
-
-
- /**
- * Update the config object for the link
- * @param linkId id of the link
- * @param config name of the config
- * @param updateEntityType entity type updating the link config
- */
- public abstract void updateLinkConfig(long linkId, MConfig config, MConfigUpdateEntityType updateEntityType);
-
- /**
- * Update the config object for the link
- * @param linkId id of the link
- * @param config name of the config
- * @param updateEntityType entity type updating the link config
- * @param tx database transaction
- */
- public abstract void updateLinkConfig(long linkId, MConfig config, MConfigUpdateEntityType updateEntityType, RepositoryTransaction tx);
+ public abstract MSubmission findLastSubmissionForJob(String jobName);
/*********************Configurable Upgrade APIs ******************************/
@@ -449,40 +377,40 @@ public abstract class Repository {
/**
* Delete all inputs for a job
- * @param jobId The id of the job whose inputs are to be deleted.
+ * @param jobName The name of the job whose inputs are to be deleted.
* @param tx A transaction on the repository. This
* method will not call <code>begin, commit,
* rollback or close on this transaction.</code>
*/
- protected abstract void deleteJobInputs(long jobId, RepositoryTransaction tx);
+ protected abstract void deleteJobInputs(String jobName, RepositoryTransaction tx);
/**
* Delete all inputs for a link
- * @param linkId The id of the link whose inputs are to be
+ * @param linkName The name of the link whose inputs are to be
* deleted.
* @param tx The repository transaction to use to push the data to the
* repository. If this is null, a new transaction will be created.
* method will not call begin, commit,
* rollback or close on this transaction.
*/
- protected abstract void deleteLinkInputs(long linkId, RepositoryTransaction tx);
+ protected abstract void deleteLinkInputs(String linkName, RepositoryTransaction tx);
private void deletelinksAndJobInputs(List<MLink> links, List<MJob> jobs, RepositoryTransaction tx) {
if (jobs != null) {
for (MJob job : jobs) {
- deleteJobInputs(job.getPersistenceId(), tx);
+ deleteJobInputs(job.getName(), tx);
}
}
if (links != null) {
for (MLink link : links) {
- deleteLinkInputs(link.getPersistenceId(), tx);
+ deleteLinkInputs(link.getName(), tx);
}
}
}
private void deleteJobInputsOnly(List<MJob> jobs, RepositoryTransaction tx) {
for (MJob job : jobs) {
- deleteJobInputs(job.getPersistenceId(), tx);
+ deleteJobInputs(job.getName(), tx);
}
}
@@ -513,7 +441,7 @@ public abstract class Repository {
// 1. Get an upgrader for the connector
ConnectorConfigurableUpgrader upgrader = connector.getConfigurableUpgrader();
// 2. Get all links associated with the connector.
- List<MLink> existingLinksByConnector = findLinksForConnector(connectorId);
+ List<MLink> existingLinksByConnector = findLinksForConnector(connectorName);
// 3. Get all jobs associated with the connector.
List<MJob> existingJobsByConnector = findJobsForConnector(connectorId);
// -- BEGIN TXN --
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
index f684e85..90cd78a 100644
--- a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
+++ b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
@@ -91,8 +91,8 @@ public enum RepositoryError implements ErrorCode {
/** link that we're trying to update is not yet saved **/
JDBCREPO_0016("Cannot update link that was not yet created"),
- /** Invalid link id **/
- JDBCREPO_0017("Given link id is invalid"),
+ /** Invalid link name **/
+ JDBCREPO_0017("Given link name is invalid"),
/** Job that we're trying to create is already saved in repository **/
JDBCREPO_0018("Cannot create job that was already created"),
@@ -100,11 +100,11 @@ public enum RepositoryError implements ErrorCode {
/** Job that we're trying to update is not yet saved **/
JDBCREPO_0019("Cannot update job that was not yet created"),
- /** Invalid job id **/
- JDBCREPO_0020("Given job id is invalid"),
+ /** Invalid job name **/
+ JDBCREPO_0020("Given job name is invalid"),
- /** link ID is in use **/
- JDBCREPO_0021("Given link id is in use"),
+ /** link name is in use **/
+ JDBCREPO_0021("Given link name is in use"),
/** Job ID is in use **/
JDBCREPO_0022("Given job id is in use"),
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
index 4999159..7ab1182 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -220,11 +220,11 @@ public class TestJdbcRepository {
// prepare the links and jobs
// the connector Id for both are the same
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,2));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 2));
// mock necessary methods for upgradeConnector() procedure
- doReturn(linkList).when(repoSpy).findLinksForConnector(anyLong());
+ doReturn(linkList).when(repoSpy).findLinksForConnector(anyString());
doReturn(jobList).when(repoSpy).findJobsForConnector(anyLong());
doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
@@ -236,13 +236,13 @@ public class TestJdbcRepository {
InOrder txOrder = inOrder(repoTransactionMock);
InOrder upgraderOrder = inOrder(connectorUpgraderMock);
- repoOrder.verify(repoSpy, times(1)).findLinksForConnector(anyLong());
+ repoOrder.verify(repoSpy, times(1)).findLinksForConnector(anyString());
repoOrder.verify(repoSpy, times(1)).findJobsForConnector(anyLong());
repoOrder.verify(repoSpy, times(1)).getTransaction();
- repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(2, repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteJobInputs("JA", repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteJobInputs("JB", repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteLinkInputs("LA", repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteLinkInputs("LB", repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).upgradeConnectorAndConfigs(any(MConnector.class), any(RepositoryTransaction.class));
repoOrder.verify(repoSpy, times(2)).updateLink(any(MLink.class), any(RepositoryTransaction.class));
repoOrder.verify(repoSpy, times(2)).updateJob(any(MJob.class), any(RepositoryTransaction.class));
@@ -269,7 +269,7 @@ public class TestJdbcRepository {
when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
when(driverMock.getDriverJobConfigurationClass()).thenReturn(ValidConfiguration.class);
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
doReturn(jobList).when(repoSpy).findJobs();
doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
@@ -284,8 +284,8 @@ public class TestJdbcRepository {
repoOrder.verify(repoSpy, times(1)).findJobs();
repoOrder.verify(repoSpy, times(1)).getTransaction();
- repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteJobInputs("JA", repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteJobInputs("JB", repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).upgradeDriverAndConfigs(any(MDriver.class), any(RepositoryTransaction.class));
repoOrder.verify(repoSpy, times(2)).updateJob(any(MJob.class), any(RepositoryTransaction.class));
repoOrder.verifyNoMoreInteractions();
@@ -307,7 +307,7 @@ public class TestJdbcRepository {
when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
when(driverMock.getDriverJobConfigurationClass()).thenReturn(InvalidConfiguration.class);
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
doReturn(jobList).when(repoSpy).findJobs();
doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
@@ -324,8 +324,8 @@ public class TestJdbcRepository {
repoOrder.verify(repoSpy, times(1)).findJobs();
repoOrder.verify(repoSpy, times(1)).getTransaction();
- repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
- repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteJobInputs("JA", repoTransactionMock);
+ repoOrder.verify(repoSpy, times(1)).deleteJobInputs("JB", repoTransactionMock);
repoOrder.verify(repoSpy, times(1)).upgradeDriverAndConfigs(any(MDriver.class), any(RepositoryTransaction.class));
repoOrder.verifyNoMoreInteractions();
txOrder.verify(repoTransactionMock, times(1)).begin();
@@ -355,13 +355,13 @@ public class TestJdbcRepository {
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"find links for connector error.");
- doThrow(exception).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
try {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -382,8 +382,8 @@ public class TestJdbcRepository {
when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
- List<MLink> linkList = links(link(1,1), link(2,1));
- doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
+ doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"find jobs for connector error.");
@@ -393,7 +393,7 @@ public class TestJdbcRepository {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -415,22 +415,22 @@ public class TestJdbcRepository {
when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+ doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"delete job inputs for connector error.");
- doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
try {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).deleteJobInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).deleteJobInputs(anyString(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -451,24 +451,24 @@ public class TestJdbcRepository {
when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+ doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"delete link inputs for connector error.");
- doThrow(exception).when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).deleteLinkInputs(anyString(), any(Connection.class));
try {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(1)).deleteLinkInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteJobInputs(anyString(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).deleteLinkInputs(anyString(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -489,12 +489,12 @@ public class TestJdbcRepository {
when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+ doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteLinkInputs(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update connector error.");
@@ -504,10 +504,10 @@ public class TestJdbcRepository {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteJobInputs(anyString(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteLinkInputs(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).upgradeConnectorAndConfigs(any(MConnector.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -531,14 +531,14 @@ public class TestJdbcRepository {
when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(ValidConfiguration.class);
when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+ doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteLinkInputs(anyString(), any(Connection.class));
doNothing().when(repoHandlerMock).upgradeConnectorAndConfigs(any(MConnector.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
+ doReturn(true).when(repoHandlerMock).existsLink(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update link error.");
@@ -548,12 +548,12 @@ public class TestJdbcRepository {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteJobInputs(anyString(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteLinkInputs(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).upgradeConnectorAndConfigs(any(MConnector.class), any(Connection.class));
- verify(repoHandlerMock, times(1)).existsLink(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).existsLink(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).updateLink(any(MLink.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -577,16 +577,16 @@ public class TestJdbcRepository {
when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(ValidConfiguration.class);
when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
- List<MLink> linkList = links(link(1,1), link(2,1));
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
- doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyLong(), any(Connection.class));
+ List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));;
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+ doReturn(linkList).when(repoHandlerMock).findLinksForConnector(anyString(), any(Connection.class));
doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteLinkInputs(anyString(), any(Connection.class));
doNothing().when(repoHandlerMock).upgradeConnectorAndConfigs(any(MConnector.class), any(Connection.class));
doNothing().when(repoHandlerMock).updateLink(any(MLink.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsJob(anyLong(), any(Connection.class));
+ doReturn(true).when(repoHandlerMock).existsLink(anyString(), any(Connection.class));
+ doReturn(true).when(repoHandlerMock).existsJob(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update job error.");
@@ -596,14 +596,14 @@ public class TestJdbcRepository {
repoSpy.upgradeConnector(oldConnector, newConnector);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
- verify(repoHandlerMock, times(1)).findLinksForConnector(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).findLinksForConnector(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteJobInputs(anyString(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteLinkInputs(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).upgradeConnectorAndConfigs(any(MConnector.class), any(Connection.class));
- verify(repoHandlerMock, times(2)).existsLink(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).existsLink(anyString(), any(Connection.class));
verify(repoHandlerMock, times(2)).updateLink(any(MLink.class), any(Connection.class));
- verify(repoHandlerMock, times(1)).existsJob(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).existsJob(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).updateJob(any(MJob.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -648,19 +648,19 @@ public class TestJdbcRepository {
when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"delete job inputs error.");
- doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
+ doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
try {
repoSpy.upgradeDriver(newDriverConfig);
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(1)).deleteJobInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).deleteJobInputs(anyString(), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
}
@@ -678,10 +678,10 @@ public class TestJdbcRepository {
when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
- doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteLinkInputs(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update driverConfig entity error.");
@@ -692,7 +692,7 @@ public class TestJdbcRepository {
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteJobInputs(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).upgradeDriverAndConfigs(any(MDriver.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -712,11 +712,11 @@ public class TestJdbcRepository {
when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
when(driverMock.getDriverJobConfigurationClass()).thenReturn(ValidConfiguration.class);
- List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
+ List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
- doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
+ doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
doNothing().when(repoHandlerMock).upgradeDriverAndConfigs(any(MDriver.class), any(Connection.class));
- doReturn(true).when(repoHandlerMock).existsJob(anyLong(), any(Connection.class));
+ doReturn(true).when(repoHandlerMock).existsJob(anyString(), any(Connection.class));
SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
"update job error.");
@@ -727,9 +727,9 @@ public class TestJdbcRepository {
} catch (SqoopException ex) {
assertEquals(ex.getMessage(), exception.getMessage());
verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
- verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(2)).deleteJobInputs(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).upgradeDriverAndConfigs(any(MDriver.class), any(Connection.class));
- verify(repoHandlerMock, times(1)).existsJob(anyLong(), any(Connection.class));
+ verify(repoHandlerMock, times(1)).existsJob(anyString(), any(Connection.class));
verify(repoHandlerMock, times(1)).updateJob(any(MJob.class), any(Connection.class));
verifyNoMoreInteractions(repoHandlerMock);
return ;
@@ -764,18 +764,20 @@ public class TestJdbcRepository {
return driver;
}
- private MLink link(long linkId, long connectorId) {
+ private MLink link(long linkId, String linkName, long connectorId) {
MLink link = new MLink(connectorId, new MLinkConfig(new LinkedList<MConfig>()));
link.setPersistenceId(linkId);
+ link.setName(linkName);
return link;
}
- private MJob job(long id, long fromConnectorId, long toConnectorId, long fromLinkId, long toLinkId) {
+ private MJob job(long id, String jobName, long fromConnectorId, long toConnectorId, long fromLinkId, long toLinkId) {
MJob job = new MJob(fromConnectorId, toConnectorId, fromLinkId, toLinkId,
new MFromConfig(new LinkedList<MConfig>()),
new MToConfig(new LinkedList<MConfig>()),
new MDriverConfig(new LinkedList<MConfig>()));
job.setPersistenceId(id);
+ job.setName(jobName);
return job;
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/a3c37472/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 c2ba6e3..9c45fe7 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
@@ -46,7 +46,6 @@ import org.apache.sqoop.model.InputEditable;
import org.apache.sqoop.model.MBooleanInput;
import org.apache.sqoop.model.MConfig;
import org.apache.sqoop.model.MConfigType;
-import org.apache.sqoop.model.MConfigUpdateEntityType;
import org.apache.sqoop.model.MConfigurableType;
import org.apache.sqoop.model.MConnector;
import org.apache.sqoop.model.MDateTimeInput;
@@ -68,7 +67,6 @@ import org.apache.sqoop.model.MSubmission;
import org.apache.sqoop.model.MToConfig;
import org.apache.sqoop.model.SubmissionError;
import org.apache.sqoop.repository.JdbcRepositoryHandler;
-import org.apache.sqoop.repository.RepositoryError;
import org.apache.sqoop.submission.SubmissionStatus;
import org.apache.sqoop.submission.counter.Counter;
import org.apache.sqoop.submission.counter.CounterGroup;
@@ -396,7 +394,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
*/
@Override
public void updateLink(MLink link, Connection conn) {
- try (PreparedStatement deleteStmt = conn.prepareStatement(crudQueries.getStmtDeleteLinkInput());
+ try (PreparedStatement deleteStmt = conn.prepareStatement(crudQueries.getStmtDeleteLinkInputByLinkId());
PreparedStatement updateStmt = conn.prepareStatement(crudQueries.getStmtUpdateLink());) {
// Firstly remove old values
deleteStmt.setLong(1, link.getPersistenceId());
@@ -426,9 +424,9 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public boolean existsLink(long linkId, Connection conn) {
- try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectLinkCheckById())) {
- stmt.setLong(1, linkId);
+ public boolean existsLink(String linkName, Connection conn) {
+ try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectLinkCheckByName())) {
+ stmt.setString(1, linkName);
try (ResultSet rs = stmt.executeQuery()) {
// Should be always valid in query with count
@@ -437,7 +435,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
return rs.getLong(1) == 1;
}
} catch (SQLException ex) {
- logException(ex, linkId);
+ logException(ex, linkName);
throw new SqoopException(CommonRepositoryError.COMMON_0022, ex);
}
}
@@ -446,10 +444,10 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public boolean inUseLink(long linkId, Connection conn) {
+ public boolean inUseLink(String linkName, Connection conn) {
try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectJobsForLinkCheck())) {
- stmt.setLong(1, linkId);
+ stmt.setString(1, linkName);
try (ResultSet rs = stmt.executeQuery()) {
// Should be always valid in case of count(*) query
@@ -458,7 +456,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
return rs.getLong(1) != 0;
}
} catch (SQLException e) {
- logException(e, linkId);
+ logException(e, linkName);
throw new SqoopException(CommonRepositoryError.COMMON_0029, e);
}
}
@@ -467,14 +465,14 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void enableLink(long linkId, boolean enabled, Connection conn) {
+ public void enableLink(String linkName, boolean enabled, Connection conn) {
try (PreparedStatement enableConn = conn.prepareStatement(crudQueries.getStmtEnableLink())) {
enableConn.setBoolean(1, enabled);
- enableConn.setLong(2, linkId);
+ enableConn.setString(2, linkName);
enableConn.executeUpdate();
} catch (SQLException ex) {
- logException(ex, linkId);
+ logException(ex, linkName);
throw new SqoopException(CommonRepositoryError.COMMON_0038, ex);
}
}
@@ -483,13 +481,13 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void deleteLink(long linkId, Connection conn) {
+ public void deleteLink(String linkName, Connection conn) {
try (PreparedStatement dltConn = conn.prepareStatement(crudQueries.getStmtDeleteLink())) {
- deleteLinkInputs(linkId, conn);
- dltConn.setLong(1, linkId);
+ deleteLinkInputs(linkName, conn);
+ dltConn.setString(1, linkName);
dltConn.executeUpdate();
} catch (SQLException ex) {
- logException(ex, linkId);
+ logException(ex, linkName);
throw new SqoopException(CommonRepositoryError.COMMON_0019, ex);
}
}
@@ -498,12 +496,12 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void deleteLinkInputs(long id, Connection conn) {
- try (PreparedStatement dltConnInput = conn.prepareStatement(crudQueries.getStmtDeleteLinkInput())) {
- dltConnInput.setLong(1, id);
+ public void deleteLinkInputs(String linkName, Connection conn) {
+ try (PreparedStatement dltConnInput = conn.prepareStatement(crudQueries.getStmtDeleteLinkInputByLinkName())) {
+ dltConnInput.setString(1, linkName);
dltConnInput.executeUpdate();
} catch (SQLException ex) {
- logException(ex, id);
+ logException(ex, linkName);
throw new SqoopException(CommonRepositoryError.COMMON_0019, ex);
}
}
@@ -576,13 +574,13 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public List<MLink> findLinksForConnector(long connectorId, Connection conn) {
+ public List<MLink> findLinksForConnector(String connectorName, Connection conn) {
try (PreparedStatement linkByConnectorFetchStmt = conn.prepareStatement(crudQueries.getStmtSelectLinkForConnectorConfigurable())) {
- linkByConnectorFetchStmt.setLong(1, connectorId);
+ linkByConnectorFetchStmt.setString(1, connectorName);
return loadLinks(linkByConnectorFetchStmt, conn);
} catch (SQLException ex) {
- logException(ex, connectorId);
+ logException(ex, connectorName);
throw new SqoopException(CommonRepositoryError.COMMON_0020, ex);
}
}
@@ -656,7 +654,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
updateStmt.executeUpdate();
// Secondly remove old values
- deleteStmt.setLong(1, job.getPersistenceId());
+ deleteStmt.setString(1, job.getName());
deleteStmt.executeUpdate();
// And reinsert new values
@@ -683,9 +681,9 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public boolean existsJob(long jobId, Connection conn) {
- try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectJobCheckById())) {
- stmt.setLong(1, jobId);
+ public boolean existsJob(String jobName, Connection conn) {
+ try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectJobCheckByName())) {
+ stmt.setString(1, jobName);
try (ResultSet rs = stmt.executeQuery()) {
// Should be always valid in query with count
@@ -694,7 +692,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
return rs.getLong(1) == 1;
}
} catch (SQLException ex) {
- logException(ex, jobId);
+ logException(ex, jobName);
throw new SqoopException(CommonRepositoryError.COMMON_0026, ex);
}
}
@@ -703,8 +701,8 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public boolean inUseJob(long jobId, Connection conn) {
- MSubmission submission = findLastSubmissionForJob(jobId, conn);
+ public boolean inUseJob(String jobName, Connection conn) {
+ MSubmission submission = findLastSubmissionForJob(jobName, conn);
// We have no submissions and thus job can't be in use
if (submission == null) {
@@ -723,13 +721,13 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void enableJob(long jobId, boolean enabled, Connection conn) {
+ public void enableJob(String jobName, boolean enabled, Connection conn) {
try (PreparedStatement enableConn = conn.prepareStatement(crudQueries.getStmtEnableJob())) {
enableConn.setBoolean(1, enabled);
- enableConn.setLong(2, jobId);
+ enableConn.setString(2, jobName);
enableConn.executeUpdate();
} catch (SQLException ex) {
- logException(ex, jobId);
+ logException(ex, jobName);
throw new SqoopException(CommonRepositoryError.COMMON_0039, ex);
}
}
@@ -738,12 +736,12 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void deleteJobInputs(long id, Connection conn) {
+ public void deleteJobInputs(String jobName, Connection conn) {
try (PreparedStatement dltInput = conn.prepareStatement(crudQueries.getStmtDeleteJobInput())) {
- dltInput.setLong(1, id);
+ dltInput.setString(1, jobName);
dltInput.executeUpdate();
} catch (SQLException ex) {
- logException(ex, id);
+ logException(ex, jobName);
throw new SqoopException(CommonRepositoryError.COMMON_0025, ex);
}
}
@@ -752,13 +750,13 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public void deleteJob(long jobId, Connection conn) {
+ public void deleteJob(String jobName, Connection conn) {
try (PreparedStatement dlt = conn.prepareStatement(crudQueries.getStmtDeleteJob())) {
- deleteJobInputs(jobId, conn);
- dlt.setLong(1, jobId);
+ deleteJobInputs(jobName, conn);
+ dlt.setString(1, jobName);
dlt.executeUpdate();
} catch (SQLException ex) {
- logException(ex, jobId);
+ logException(ex, jobName);
throw new SqoopException(CommonRepositoryError.COMMON_0025, ex);
}
}
@@ -993,10 +991,10 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public List<MSubmission> findSubmissionsForJob(long jobId, Connection conn) {
+ public List<MSubmission> findSubmissionsForJob(String jobName, Connection conn) {
List<MSubmission> submissions = new LinkedList<MSubmission>();
try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectSubmissionsForJob())) {
- stmt.setLong(1, jobId);
+ stmt.setString(1, jobName);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
@@ -1015,10 +1013,10 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
* {@inheritDoc}
*/
@Override
- public MSubmission findLastSubmissionForJob(long jobId, Connection conn) {
+ public MSubmission findLastSubmissionForJob(String jobName, Connection conn) {
try (PreparedStatement stmt = conn.prepareStatement(crudQueries.getStmtSelectSubmissionsForJob())) {
- stmt.setLong(1, jobId);
+ stmt.setString(1, jobName);
stmt.setMaxRows(1);
try (ResultSet rs = stmt.executeQuery()) {
@@ -1029,7 +1027,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
return loadSubmission(rs, conn);
}
} catch (SQLException ex) {
- logException(ex, jobId);
+ logException(ex, jobName);
throw new SqoopException(CommonRepositoryError.COMMON_0037, ex);
}
}
@@ -1783,125 +1781,6 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
return children;
}
- @Override
- public MConfig findFromJobConfig(long jobId, String configName, Connection conn) {
- MJob job = findJob(jobId, conn);
- if (job == null) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- MFromConfig fromConfigs = job.getFromJobConfig();
- if (fromConfigs != null) {
- MConfig config = fromConfigs.getConfig(configName);
- if (config == null) {
- throw new SqoopException(CommonRepositoryError.COMMON_0049, "for configName :" + configName);
- }
- return config;
- }
- throw new SqoopException(CommonRepositoryError.COMMON_0049, "for configName :" + configName);
- }
-
- @Override
- public MConfig findToJobConfig(long jobId, String configName, Connection conn) {
- MJob job = findJob(jobId, conn);
- if (job == null) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- MToConfig toConfigs = job.getToJobConfig();
- if (toConfigs != null) {
- MConfig config = toConfigs.getConfig(configName);
- if (config == null) {
- throw new SqoopException(CommonRepositoryError.COMMON_0050, "for configName :" + configName);
- }
- return config;
- }
- throw new SqoopException(CommonRepositoryError.COMMON_0050, "for configName :" + configName);
- }
-
- @Override
- public MConfig findDriverJobConfig(long jobId, String configName, Connection conn) {
- MJob job = findJob(jobId, conn);
- if (job == null) {
- throw new SqoopException(RepositoryError.JDBCREPO_0020, "Invalid id: " + jobId);
- }
- MDriverConfig driverConfigs = job.getDriverConfig();
- if (driverConfigs != null) {
- MConfig config = driverConfigs.getConfig(configName);
- if (config == null) {
- throw new SqoopException(CommonRepositoryError.COMMON_0051, "for configName :" + configName);
- }
- return config;
- }
- throw new SqoopException(CommonRepositoryError.COMMON_0051, "for configName :" + configName);
- }
-
- @Override
- public MConfig findLinkConfig(long linkId, String configName, Connection conn) {
- MLink link = findLink(linkId, conn);
- if (link == null) {
- throw new SqoopException(RepositoryError.JDBCREPO_0017, "Invalid id: " + linkId);
- }
- MConfig driverConfig = link.getConnectorLinkConfig(configName);
- if (driverConfig == null) {
- throw new SqoopException(CommonRepositoryError.COMMON_0052, "for configName :" + configName);
- }
- return driverConfig;
- }
-
- @SuppressWarnings("resource")
- @Override
- public void updateJobConfig(long jobId, MConfig config, MConfigUpdateEntityType type,
- Connection conn) {
- List<MInput<?>> inputs = config.getInputs();
-
- try (PreparedStatement updateStmt = conn.prepareStatement(crudQueries.getStmtUpdateJobInput())) {
- for (MInput<?> input : inputs) {
- if (input.isEmpty()) {
- continue;
- }
- validateEditableConstraints(type, input);
- updateStmt.setString(1, input.getUrlSafeValueString());
- updateStmt.setLong(2, input.getPersistenceId());
- updateStmt.setLong(3, jobId);
- updateStmt.executeUpdate();
- }
- } catch (SQLException ex) {
- logException(ex, jobId);
- throw new SqoopException(CommonRepositoryError.COMMON_0053, ex);
- }
- }
-
- private void validateEditableConstraints(MConfigUpdateEntityType type, MInput<?> input) {
- if (input.getEditable().equals(InputEditable.CONNECTOR_ONLY)
- && type.equals(MConfigUpdateEntityType.USER)) {
- throw new SqoopException(CommonRepositoryError.COMMON_0055);
- }
- if (input.getEditable().equals(InputEditable.USER_ONLY)
- && type.equals(MConfigUpdateEntityType.CONNECTOR)) {
- throw new SqoopException(CommonRepositoryError.COMMON_0056);
- }
- }
-
- @Override
- public void updateLinkConfig(long linkId, MConfig config, MConfigUpdateEntityType type,
- Connection conn) {
- List<MInput<?>> inputs = config.getInputs();
- try (PreparedStatement updateStmt = conn.prepareStatement(crudQueries.getStmtUpdateLinkInput());) {
- for (MInput<?> input : inputs) {
- if (input.isEmpty()) {
- continue;
- }
- validateEditableConstraints(type, input);
- updateStmt.setString(1, input.getUrlSafeValueString());
- updateStmt.setLong(2, input.getPersistenceId());
- updateStmt.setLong(3, linkId);
- updateStmt.executeUpdate();
- }
- } catch (SQLException ex) {
- logException(ex, linkId);
- throw new SqoopException(CommonRepositoryError.COMMON_0054, ex);
- }
- }
-
/**
* {@inheritDoc}
*/