sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2703: Sqoop2: Use connector name in MJob
Date Tue, 08 Dec 2015 13:58:39 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 6c4743de1 -> e70b9c259


SQOOP-2703: Sqoop2: Use connector name in MJob

(Colin Ma 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/e70b9c25
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/e70b9c25
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/e70b9c25

Branch: refs/heads/sqoop2
Commit: e70b9c259a90b6499a3bcd60d5dc13cf6c3f0d94
Parents: 6c4743d
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Dec 8 14:58:09 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Dec 8 14:58:09 2015 +0100

----------------------------------------------------------------------
 .../org/apache/sqoop/client/SqoopClient.java    |  4 +--
 .../java/org/apache/sqoop/json/JobBean.java     | 32 ++++++++---------
 .../main/java/org/apache/sqoop/model/MJob.java  | 36 ++++++++++----------
 .../java/org/apache/sqoop/json/TestJobBean.java |  4 +--
 .../org/apache/sqoop/json/TestJobsBean.java     |  4 +--
 .../apache/sqoop/json/util/BeanTestUtil.java    |  6 ++--
 .../java/org/apache/sqoop/model/TestMJob.java   | 14 ++++----
 .../org/apache/sqoop/driver/JobManager.java     | 17 +++++++--
 .../org/apache/sqoop/repository/Repository.java | 30 ++++++++--------
 .../org/apache/sqoop/driver/TestJobManager.java | 22 ++++++------
 .../sqoop/repository/TestJdbcRepository.java    | 26 +++++++-------
 .../common/CommonRepositoryHandler.java         |  8 ++---
 .../sqoop/repository/derby/TestJobHandling.java |  2 +-
 .../repository/mysql/MySqlTestCase.java         |  4 +--
 .../postgresql/PostgresqlTestCase.java          |  4 +--
 .../apache/sqoop/handler/JobRequestHandler.java | 25 +++++++-------
 .../apache/sqoop/shell/CloneJobFunction.java    |  7 ++--
 .../apache/sqoop/shell/CreateJobFunction.java   |  4 +--
 .../org/apache/sqoop/shell/ShowJobFunction.java | 22 +++---------
 .../apache/sqoop/shell/UpdateJobFunction.java   |  8 ++---
 .../apache/sqoop/shell/TestCloneCommand.java    |  4 +--
 .../apache/sqoop/shell/TestCreateCommand.java   | 12 +++----
 .../org/apache/sqoop/shell/TestShowCommand.java |  4 +--
 .../apache/sqoop/shell/TestUpdateCommand.java   |  4 +--
 .../sqoop/tools/tool/RepositoryLoadTool.java    |  8 ++---
 25 files changed, 153 insertions(+), 158 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
index 4abee77..f39ea6a 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -393,8 +393,8 @@ public class SqoopClient {
     MConnector connectorForToLink = getConnector(toLink.getConnectorName());
 
     return new MJob(
-      connectorForFromLink.getPersistenceId(),
-      connectorForToLink.getPersistenceId(),
+      connectorForFromLink.getUniqueName(),
+      connectorForToLink.getUniqueName(),
       fromLink.getPersistenceId(),
       toLink.getPersistenceId(),
       connectorForFromLink.getFromConfig().clone(false),

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/common/src/main/java/org/apache/sqoop/json/JobBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/JobBean.java b/common/src/main/java/org/apache/sqoop/json/JobBean.java
index b703987..2a59c25 100644
--- a/common/src/main/java/org/apache/sqoop/json/JobBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/JobBean.java
@@ -50,8 +50,8 @@ public class JobBean implements JsonBean {
 
   static final String FROM_LINK_ID = "from-link-id";
   static final String TO_LINK_ID = "to-link-id";
-  static final String FROM_CONNECTOR_ID = "from-connector-id";
-  static final String TO_CONNECTOR_ID = "to-connector-id";
+  static final String FROM_CONNECTOR_NAME = "from-connector-name";
+  static final String TO_CONNECTOR_NAME = "to-connector-name";
   static final String FROM_CONFIG_VALUES = "from-config-values";
   static final String TO_CONFIG_VALUES = "to-config-values";
   static final String DRIVER_CONFIG_VALUES = "driver-config-values";
@@ -61,7 +61,7 @@ public class JobBean implements JsonBean {
   private List<MJob> jobs;
 
   // Optional
-  private Map<Long, ResourceBundle> connectorConfigBundles;
+  private Map<String, ResourceBundle> connectorConfigBundles;
   private ResourceBundle driverConfigBundle;
 
   // For "extract"
@@ -78,27 +78,27 @@ public class JobBean implements JsonBean {
 
   // For "restore"
   public JobBean() {
-    connectorConfigBundles = new HashMap<Long, ResourceBundle>();
+    connectorConfigBundles = new HashMap<String, ResourceBundle>();
   }
 
   public void setDriverConfigBundle(ResourceBundle driverConfigBundle) {
     this.driverConfigBundle = driverConfigBundle;
   }
 
-  public void addConnectorConfigBundle(Long id, ResourceBundle connectorConfigBundle) {
-    connectorConfigBundles.put(id, connectorConfigBundle);
+  public void addConnectorConfigBundle(String connectorName, ResourceBundle connectorConfigBundle) {
+    connectorConfigBundles.put(connectorName, connectorConfigBundle);
   }
 
-  public boolean hasConnectorConfigBundle(Long id) {
-    return connectorConfigBundles.containsKey(id);
+  public boolean hasConnectorConfigBundle(String connectorName) {
+    return connectorConfigBundles.containsKey(connectorName);
   }
 
   public List<MJob> getJobs() {
     return jobs;
   }
 
-  public ResourceBundle getConnectorConfigBundle(Long id) {
-    return connectorConfigBundles.get(id);
+  public ResourceBundle getConnectorConfigBundle(String connectorName) {
+    return connectorConfigBundles.get(connectorName);
   }
 
   public ResourceBundle getDriverConfigBundle() {
@@ -134,8 +134,8 @@ public class JobBean implements JsonBean {
     object.put(UPDATE_DATE, job.getLastUpdateDate().getTime());
     // job link associated connectors
     // TODO(SQOOP-1634): fix not to require the connectorIds in the post data
-    object.put(FROM_CONNECTOR_ID, job.getFromConnectorId());
-    object.put(TO_CONNECTOR_ID, job.getToConnectorId());
+    object.put(FROM_CONNECTOR_NAME, job.getFromConnectorName());
+    object.put(TO_CONNECTOR_NAME, job.getToConnectorName());
     // job associated links
     object.put(FROM_LINK_ID, job.getFromLinkId());
     object.put(TO_LINK_ID, job.getToLinkId());
@@ -168,8 +168,8 @@ public class JobBean implements JsonBean {
 
   private MJob restoreJob(Object obj) {
     JSONObject object = (JSONObject) obj;
-    long fromConnectorId = JSONUtils.getLong(object, FROM_CONNECTOR_ID);
-    long toConnectorId = JSONUtils.getLong(object, TO_CONNECTOR_ID);
+    String fromConnectorName = JSONUtils.getString(object, FROM_CONNECTOR_NAME);
+    String toConnectorName = JSONUtils.getString(object, TO_CONNECTOR_NAME);
     long fromConnectionId = JSONUtils.getLong(object, FROM_LINK_ID);
     long toConnectionId = JSONUtils.getLong(object, TO_LINK_ID);
     JSONObject fromConfigJson = JSONUtils.getJSONObject(object, FROM_CONFIG_VALUES);
@@ -186,8 +186,8 @@ public class JobBean implements JsonBean {
     List<MValidator> driverValidators = restoreValidator(JSONUtils.getJSONArray(driverConfigJson, ConfigInputConstants.CONFIG_VALIDATORS));
 
     MJob job = new MJob(
-      fromConnectorId,
-      toConnectorId,
+      fromConnectorName,
+      toConnectorName,
       fromConnectionId,
       toConnectionId,
       new MFromConfig(fromConfigs, fromValidators),

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/common/src/main/java/org/apache/sqoop/model/MJob.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MJob.java b/common/src/main/java/org/apache/sqoop/model/MJob.java
index 4be020a..59bc646 100644
--- a/common/src/main/java/org/apache/sqoop/model/MJob.java
+++ b/common/src/main/java/org/apache/sqoop/model/MJob.java
@@ -35,8 +35,8 @@ public class MJob extends MAccountableEntity implements MClonable {
    * dependency through link object, but having this dependency explicitly
    * carried along helps with not having to make the DB call everytime
    */
-  private final long fromConnectorId;
-  private final long toConnectorId;
+  private final String fromConnectorName;
+  private final String toConnectorName;
   private final long fromLinkId;
   private final long toLinkId;
 
@@ -55,15 +55,15 @@ public class MJob extends MAccountableEntity implements MClonable {
    * @param toConfig TO job config
    * @param driverConfig driver config
    */
-  public MJob(long fromConnectorId,
-              long toConnectorId,
+  public MJob(String fromConnectorName,
+              String toConnectorName,
               long fromLinkId,
               long toLinkId,
               MFromConfig fromConfig,
               MToConfig toConfig,
               MDriverConfig driverConfig) {
-    this.fromConnectorId = fromConnectorId;
-    this.toConnectorId = toConnectorId;
+    this.fromConnectorName = fromConnectorName;
+    this.toConnectorName = toConnectorName;
     this.fromLinkId = fromLinkId;
     this.toLinkId = toLinkId;
     this.fromConfig = fromConfig;
@@ -97,8 +97,8 @@ public class MJob extends MAccountableEntity implements MClonable {
   public MJob(MJob other, MFromConfig fromConfig, MToConfig toConfig, MDriverConfig driverConfig) {
     super(other);
 
-    this.fromConnectorId = other.getFromConnectorId();
-    this.toConnectorId = other.getToConnectorId();
+    this.fromConnectorName = other.getFromConnectorName();
+    this.toConnectorName = other.getToConnectorName();
     this.fromLinkId = other.getFromLinkId();
     this.toLinkId = other.getToLinkId();
     this.fromConfig = fromConfig;
@@ -125,12 +125,12 @@ public class MJob extends MAccountableEntity implements MClonable {
     return toLinkId;
   }
 
-  public long getFromConnectorId() {
-    return fromConnectorId;
+  public String getFromConnectorName() {
+    return fromConnectorName;
   }
 
-  public long getToConnectorId() {
-    return toConnectorId;
+  public String getToConnectorName() {
+    return toConnectorName;
   }
 
   public MFromConfig getFromJobConfig() {
@@ -151,8 +151,8 @@ public class MJob extends MAccountableEntity implements MClonable {
       return new MJob(this);
     } else {
       return new MJob(
-          getFromConnectorId(),
-          getToConnectorId(),
+          getFromConnectorName(),
+          getToConnectorName(),
           getFromLinkId(),
           getToLinkId(),
           getFromJobConfig().clone(false),
@@ -172,8 +172,8 @@ public class MJob extends MAccountableEntity implements MClonable {
     }
 
     MJob job = (MJob)object;
-    return (job.getFromConnectorId() == this.getFromConnectorId())
-        && (job.getToConnectorId() == this.getToConnectorId())
+    return (job.getFromConnectorName().equals(this.getFromConnectorName()))
+        && (job.getToConnectorName().equals(this.getToConnectorName()))
         && (job.getFromLinkId() == this.getFromLinkId())
         && (job.getToLinkId() == this.getToLinkId())
         && (job.getPersistenceId() == this.getPersistenceId())
@@ -184,8 +184,8 @@ public class MJob extends MAccountableEntity implements MClonable {
 
   @Override
   public int hashCode() {
-    int result = (int) (fromConnectorId ^ (fromConnectorId >>> 32));
-    result = 31 * result + (int) (toConnectorId ^ (toConnectorId >>> 32));
+    int result = fromConnectorName != null ? fromConnectorName.hashCode() : 0;
+    result = 31 * result + (toConnectorName != null ? toConnectorName.hashCode() : 0);
     result = 31 * result + (int) (fromLinkId ^ (fromLinkId >>> 32));
     result = 31 * result + (int) (toLinkId ^ (toLinkId >>> 32));
     result = 31 * result + (fromConfig != null ? fromConfig.hashCode() : 0);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
index 5b5aa91..0e8933e 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobBean.java
@@ -63,8 +63,8 @@ public class TestJobBean {
 
     assertEquals(target.getFromLinkId(), 1);
     assertEquals(target.getToLinkId(), 2);
-    assertEquals(target.getFromConnectorId(), 1);
-    assertEquals(target.getToConnectorId(), 2);
+    assertEquals(target.getFromConnectorName(), "from_ahoj");
+    assertEquals(target.getToConnectorName(), "to_ahoj");
     assertEquals(created, target.getCreationDate());
     assertEquals(updated, target.getLastUpdateDate());
     assertEquals(false, target.getEnabled());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java b/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
index 2a9570f..2849497 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestJobsBean.java
@@ -74,8 +74,8 @@ public class TestJobsBean {
 
     assertEquals(retrievedJob1.getFromLinkId(), 1);
     assertEquals(retrievedJob1.getToLinkId(), 2);
-    assertEquals(retrievedJob1.getFromConnectorId(), 1);
-    assertEquals(retrievedJob1.getToConnectorId(), 2);
+    assertEquals(retrievedJob1.getFromConnectorName(), "from_ahoj");
+    assertEquals(retrievedJob1.getToConnectorName(), "to_ahoj");
     assertEquals(created, retrievedJob1.getCreationDate());
     assertEquals(updated, retrievedJob1.getLastUpdateDate());
     assertEquals(false, retrievedJob1.getEnabled());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/common/src/test/java/org/apache/sqoop/json/util/BeanTestUtil.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/BeanTestUtil.java b/common/src/test/java/org/apache/sqoop/json/util/BeanTestUtil.java
index 13774c8..90435c6 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/BeanTestUtil.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/BeanTestUtil.java
@@ -77,8 +77,10 @@ public class BeanTestUtil {
   }
 
   public static MJob getJob(String connectorName) {
-    return new MJob(1, 2, 1, 2, getConnector(1L, connectorName).getFromConfig(), getConnector(1L, connectorName)
-        .getToConfig(), ConfigTestUtil.getDriverConfig());
+    String fromConnectorName = "from_" + connectorName;
+    String toConnectorName = "to_" + connectorName;
+    return new MJob(fromConnectorName, toConnectorName, 1, 2, getConnector(1L, fromConnectorName).getFromConfig(),
+            getConnector(2L, toConnectorName).getToConfig(), ConfigTestUtil.getDriverConfig());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/common/src/test/java/org/apache/sqoop/model/TestMJob.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJob.java b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
index 17388cd..7d1c2c1 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
@@ -36,8 +36,8 @@ public class TestMJob {
   public void testInitialization() {
     // Test default constructor
     MJob job = job();
-    assertEquals(123l, job.getFromConnectorId());
-    assertEquals(456l, job.getToConnectorId());
+    assertEquals("fromConnectorName", job.getFromConnectorName());
+    assertEquals("toConnectorName", job.getToConnectorName());
     assertEquals("Buffy", job.getCreationUser());
     assertEquals("Vampire", job.getName());
     assertEquals(fromConfig(), job.getFromJobConfig());
@@ -46,8 +46,8 @@ public class TestMJob {
 
     // Test copy constructor
     MJob copy = new MJob(job);
-    assertEquals(123l, copy.getFromConnectorId());
-    assertEquals(456l, copy.getToConnectorId());
+    assertEquals("fromConnectorName", copy.getFromConnectorName());
+    assertEquals("toConnectorName", copy.getToConnectorName());
     assertEquals("Buffy", copy.getCreationUser());
     assertEquals("Vampire", copy.getName());
     assertEquals(fromConfig(), copy.getFromJobConfig());
@@ -56,8 +56,8 @@ public class TestMJob {
 
     // Test constructor for metadata upgrade (the order of configs is different)
     MJob upgradeCopy = new MJob(job, fromConfig(), toConfig(), driverConfig());
-    assertEquals(123l, upgradeCopy.getFromConnectorId());
-    assertEquals(456l, upgradeCopy.getToConnectorId());
+    assertEquals("fromConnectorName", upgradeCopy.getFromConnectorName());
+    assertEquals("toConnectorName", upgradeCopy.getToConnectorName());
     assertEquals("Buffy", upgradeCopy.getCreationUser());
     assertEquals("Vampire", upgradeCopy.getName());
     assertEquals(fromConfig(), upgradeCopy.getFromJobConfig());
@@ -98,7 +98,7 @@ public class TestMJob {
         .getConfig("CONFIGFROMNAME").getInput("STRING-INPUT").getValue());  }
 
   private MJob job() {
-    MJob job = new MJob(123l, 456l, 1L, 2L, fromConfig(), toConfig(), driverConfig());
+    MJob job = new MJob("fromConnectorName", "toConnectorName", 1L, 2L, fromConfig(), toConfig(), driverConfig());
     job.setName("Vampire");
     job.setCreationUser("Buffy");
     return job;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/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 35c4451..021aafe 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
@@ -496,6 +496,7 @@ public class JobManager implements Reconfigurable {
     return link;
   }
 
+  // TODO: this method should be removed when MSubmission link job with jobName
   MJob getJob(long jobId) {
     MJob job = RepositoryManager.getInstance().getRepository().findJob(jobId);
     if (job == null) {
@@ -508,6 +509,18 @@ public class JobManager implements Reconfigurable {
     return job;
   }
 
+  MJob getJob(String jobName) {
+    MJob job = RepositoryManager.getInstance().getRepository().findJob(jobName);
+    if (job == null) {
+      throw new SqoopException(DriverError.DRIVER_0004, "Unknown job name: " + jobName);
+    }
+
+    if (!job.getEnabled()) {
+      throw new SqoopException(DriverError.DRIVER_0009, "Job: " + jobName);
+    }
+    return job;
+  }
+
   @SuppressWarnings({ "unchecked", "rawtypes" })
   private void initializeConnector(JobRequest jobRequest, Direction direction, Initializer initializer, InitializerContext initializerContext) {
     // Initialize submission from the connector perspective
@@ -569,8 +582,8 @@ public class JobManager implements Reconfigurable {
     try {
       MJob job = getJob(submission.getJobId());
 
-      SqoopConnector fromConnector = getSqoopConnector(job.getFromConnectorId());
-      SqoopConnector toConnector = getSqoopConnector(job.getToConnectorId());
+      SqoopConnector fromConnector = getSqoopConnector(job.getFromConnectorName());
+      SqoopConnector toConnector = getSqoopConnector(job.getToConnectorName());
 
       MLink fromConnection = getLink(job.getFromLinkId());
       MLink toConnection = getLink(job.getToLinkId());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/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 9396ef6..975e2aa 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -447,7 +447,7 @@ public abstract class Repository {
   public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
     LOG.info("Upgrading connector: " + oldConnector.getUniqueName());
     long connectorId = oldConnector.getPersistenceId();
-    String connectorName = oldConnector.getUniqueName();
+    String oldConnectorName = oldConnector.getUniqueName();
     String oldVersion = oldConnector.getVersion();
     newConnector.setPersistenceId(connectorId);
 
@@ -460,7 +460,7 @@ public abstract class Repository {
       // 1. Get an upgrader for the connector
       ConnectorConfigurableUpgrader upgrader = connector.getConfigurableUpgrader(oldVersion);
       // 2. Get all links associated with the connector.
-      List<MLink> existingLinksByConnector = findLinksForConnectorUpgrade(connectorName);
+      List<MLink> existingLinksByConnector = findLinksForConnectorUpgrade(oldConnectorName);
       // 3. Get all jobs associated with the connector.
       List<MJob> existingJobsByConnector = findJobsForConnectorUpgrade(connectorId);
       // -- BEGIN TXN --
@@ -476,7 +476,7 @@ public abstract class Repository {
       // dont always rely on the repository implementation to return empty list for links
       if (existingLinksByConnector != null) {
         for (MLink link : existingLinksByConnector) {
-          LOG.info(" Link upgrade for link:" + link.getName() + " for connector:" + connectorName);
+          LOG.info(" Link upgrade for link:" + link.getName() + " for connector:" + oldConnectorName);
           // Make a new copy of the configs
           MConfigList linkConfig = newConnector.getLinkConfig().clone(false);
           MLinkConfig newLinkConfig = new MLinkConfig(linkConfig.getConfigs(), linkConfig.getCloneOfValidators());
@@ -496,7 +496,7 @@ public abstract class Repository {
             // and stop the bootup of Sqoop server
             logInvalidModelObject("link", newlink, validationResult);
             upgradeSuccessful = false;
-            LOG.info(" LINK config upgrade FAILED for link: " + link.getName() + " for connector:" + connectorName);
+            LOG.info(" LINK config upgrade FAILED for link: " + link.getName() + " for connector:" + oldConnectorName);
           }
         }
       }
@@ -506,14 +506,15 @@ public abstract class Repository {
         for (MJob job : existingJobsByConnector) {
           // every job has 2 parts, the FROM and the TO links and their
           // corresponding connectors.
-          LOG.info(" Job upgrade for job:" + job.getName()+ " for connector:" + connectorName);
+          LOG.info(" Job upgrade for job:" + job.getName()+ " for connector:" + oldConnectorName);
 
           SupportedDirections supportedDirections = newConnector.getSupportedDirections();
 
+          // compare the old connector name with job's connector name
           if (supportedDirections.isDirectionSupported(Direction.FROM)
-              && job.getFromConnectorId() == newConnector.getPersistenceId()
+              && job.getFromConnectorName().equals(oldConnectorName)
               && supportedDirections.isDirectionSupported(Direction.TO)
-              && job.getToConnectorId() == newConnector.getPersistenceId()) {
+              && job.getToConnectorName().equals(oldConnectorName)) {
             // Upgrade both configs
             MFromConfig newFromConfig = new MFromConfig(newConnector.getFromConfig().clone(false).getConfigs(), newConnector.getFromConfig().getCloneOfValidators());
             MFromConfig oldFromConfig = job.getFromJobConfig();
@@ -528,16 +529,15 @@ public abstract class Repository {
                 newJob.getFromJobConfig().getConfigs(),
                 connector.getJobConfigurationClass(Direction.FROM)
             );
-
             if (validationResult.getStatus().canProceed()) {
               updateJob(newJob, tx);
             } else {
               logInvalidModelObject("job", newJob, validationResult);
               upgradeSuccessful = false;
-              LOG.error(" JOB config upgrade FAILED for job: " + job.getName() + " for connector:" + connectorName);
+              LOG.error(" JOB config upgrade FAILED for job: " + job.getName() + " for connector:" + oldConnectorName);
             }
           } else if (supportedDirections.isDirectionSupported(Direction.FROM)
-              && job.getFromConnectorId() == newConnector.getPersistenceId()) {
+              && job.getFromConnectorName().equals(oldConnectorName)) {
             MFromConfig newFromConfig = new MFromConfig(newConnector.getFromConfig().clone(false).getConfigs(), newConnector.getFromConfig().getCloneOfValidators());
             MFromConfig oldFromConfig = job.getFromJobConfig();
             upgrader.upgradeFromJobConfig(oldFromConfig, newFromConfig);
@@ -556,10 +556,10 @@ public abstract class Repository {
             } else {
               logInvalidModelObject("job", newJob, validationResult);
               upgradeSuccessful = false;
-              LOG.error(" FROM JOB config upgrade FAILED for job: " + job.getName() + " for connector:" + connectorName);
+              LOG.error(" FROM JOB config upgrade FAILED for job: " + job.getName() + " for connector:" + oldConnectorName);
             }
           } else if (supportedDirections.isDirectionSupported(Direction.TO)
-              && job.getToConnectorId() == newConnector.getPersistenceId()) {
+              && job.getToConnectorName().equals(oldConnectorName)) {
             MToConfig oldToConfig = job.getToJobConfig();
             MToConfig newToConfig = new MToConfig(newConnector.getToConfig().clone(false).getConfigs(), newConnector.getToConfig().getCloneOfValidators());
             upgrader.upgradeToJobConfig(oldToConfig, newToConfig);
@@ -578,7 +578,7 @@ public abstract class Repository {
             } else {
               logInvalidModelObject("job", newJob, validationResult);
               upgradeSuccessful = false;
-              LOG.error(" TO JOB config upgrade FAILED for job: " + job.getName() + " for connector:" + connectorName);
+              LOG.error(" TO JOB config upgrade FAILED for job: " + job.getName() + " for connector:" + oldConnectorName);
             }
           }
         }
@@ -587,7 +587,7 @@ public abstract class Repository {
       if (upgradeSuccessful) {
         tx.commit();
       } else {
-        throw new SqoopException(RepositoryError.JDBCREPO_0027, " for connector:" + connectorName);
+        throw new SqoopException(RepositoryError.JDBCREPO_0027, " for connector:" + oldConnectorName);
       }
     } catch (SqoopException ex) {
       if (tx != null) {
@@ -603,7 +603,7 @@ public abstract class Repository {
       if (tx != null) {
         tx.close();
       }
-      LOG.info("Connector upgrade finished for: " + connectorName);
+      LOG.info("Connector upgrade finished for: " + oldConnectorName);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
index 3b200e9..ef4d359 100644
--- a/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
+++ b/core/src/test/java/org/apache/sqoop/driver/TestJobManager.java
@@ -141,19 +141,19 @@ public class TestJobManager {
 
   @Test
   public void testGetJob() {
-    MJob testJob = job(123l, 456l);
+    MJob testJob = job("jobName", "fromConnectorName", "toConnectorName");
     testJob.setEnabled(true);
     MJob mJobSpy = org.mockito.Mockito.spy(testJob);
     when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
-    when(jdbcRepoMock.findJob(123l)).thenReturn(mJobSpy);
-    assertEquals(jobManager.getJob(123l), mJobSpy);
+    when(jdbcRepoMock.findJob("jobName")).thenReturn(mJobSpy);
+    assertEquals(jobManager.getJob("jobName"), mJobSpy);
     verify(repositoryManagerMock, times(1)).getRepository();
-    verify(jdbcRepoMock, times(1)).findJob(123l);
+    verify(jdbcRepoMock, times(1)).findJob("jobName");
   }
 
   @Test
   public void testDisabledJob() {
-    MJob testJob = job(123l, 456l);
+    MJob testJob = job("jobName", "fromConnectorName", "toConnectorName");
     testJob.setEnabled(false);
     testJob.setPersistenceId(1111);
     SqoopException exception = new SqoopException(DriverError.DRIVER_0009, "Job: "
@@ -161,13 +161,13 @@ public class TestJobManager {
 
     MJob mJobSpy = org.mockito.Mockito.spy(testJob);
     when(repositoryManagerMock.getRepository()).thenReturn(jdbcRepoMock);
-    when(jdbcRepoMock.findJob(123l)).thenReturn(mJobSpy);
+    when(jdbcRepoMock.findJob("jobName")).thenReturn(mJobSpy);
     try {
-      jobManager.getJob(123l);
+      jobManager.getJob("jobName");
     } catch (SqoopException ex) {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repositoryManagerMock, times(1)).getRepository();
-      verify(jdbcRepoMock, times(1)).findJob(123l);
+      verify(jdbcRepoMock, times(1)).findJob("jobName");
     }
   }
 
@@ -187,9 +187,9 @@ public class TestJobManager {
     }
   }
 
-  private MJob job(long fromId, long toId) {
-    MJob job = new MJob(fromId, toId, 1L, 2L, null, null, null);
-    job.setName("Vampire");
+  private MJob job(String jobName, String fromConnectorName, String toConnectorName) {
+    MJob job = new MJob(fromConnectorName, toConnectorName, 1L, 2L, null, null, null);
+    job.setName(jobName);
     job.setCreationUser("Buffy");
     return job;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/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 a665fd1..04c88c6 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -229,7 +229,7 @@ public class TestJdbcRepository {
     // prepare the links and jobs
     // the connector Id for both are the same
     List<MLink> linkList = links(link(1, "LA", oldConnector.getUniqueName()), link(2, "LB", oldConnector.getUniqueName()));
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 2));
+    List<MJob> jobList = jobs(job(1, "JA", "A1", "A1", 1, 1), job(2, "JB", "A1", "A1", 2, 2));
 
     // mock necessary methods for upgradeConnector() procedure
     doReturn(linkList).when(repoSpy).findLinksForConnectorUpgrade(anyString());
@@ -277,7 +277,7 @@ public class TestJdbcRepository {
 
     when(driverMock.getConfigurableUpgrader(DriverBean.CURRENT_DRIVER_VERSION)).thenReturn(driverUpgraderMock);
     when(driverMock.getDriverJobConfigurationClass()).thenReturn(ValidConfiguration.class);
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
 
     doReturn(jobList).when(repoSpy).findJobs();
     doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
@@ -315,7 +315,7 @@ public class TestJdbcRepository {
 
     when(driverMock.getConfigurableUpgrader(DriverBean.CURRENT_DRIVER_VERSION)).thenReturn(driverUpgraderMock);
     when(driverMock.getDriverJobConfigurationClass()).thenReturn(InvalidConfiguration.class);
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
 
     doReturn(jobList).when(repoSpy).findJobs();
     doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
@@ -425,7 +425,7 @@ public class TestJdbcRepository {
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", oldConnector.getUniqueName()), link(2, "LB", oldConnector.getUniqueName()));
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(linkList).when(repoHandlerMock).findLinksForConnectorUpgrade(anyString(), any(Connection.class));
     doReturn(jobList).when(repoHandlerMock).findJobsForConnectorUpgrade
       (anyLong(), any(Connection.class));
@@ -463,7 +463,7 @@ public class TestJdbcRepository {
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", oldConnector.getUniqueName()), link(2, "LB", oldConnector.getUniqueName()));
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(linkList).when(repoHandlerMock).findLinksForConnectorUpgrade(anyString(), any(Connection.class));
     doReturn(jobList).when(repoHandlerMock).findJobsForConnectorUpgrade(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
@@ -501,7 +501,7 @@ public class TestJdbcRepository {
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", oldConnector.getUniqueName()), link(2, "LB", oldConnector.getUniqueName()));
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(linkList).when(repoHandlerMock).findLinksForConnectorUpgrade(anyString(), any(Connection.class));
     doReturn(jobList).when(repoHandlerMock).findJobsForConnectorUpgrade(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
@@ -543,7 +543,7 @@ public class TestJdbcRepository {
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", oldConnector.getUniqueName()), link(2, "LB", oldConnector.getUniqueName()));
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(linkList).when(repoHandlerMock).findLinksForConnectorUpgrade(anyString(), any(Connection.class));
     doReturn(jobList).when(repoHandlerMock).findJobsForConnectorUpgrade(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
@@ -589,7 +589,7 @@ public class TestJdbcRepository {
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", oldConnector.getUniqueName()), link(2, "LB", oldConnector.getUniqueName()));;
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "A1", "A1", 1, 1), job(2, "JB", "A1", "A1", 2, 1));
     doReturn(linkList).when(repoHandlerMock).findLinksForConnectorUpgrade(anyString(), any(Connection.class));
     doReturn(jobList).when(repoHandlerMock).findJobsForConnectorUpgrade(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
@@ -659,7 +659,7 @@ public class TestJdbcRepository {
 
     when(driverMock.getConfigurableUpgrader(DriverBean.CURRENT_DRIVER_VERSION)).thenReturn(driverUpgraderMock);
 
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
@@ -689,7 +689,7 @@ public class TestJdbcRepository {
 
     when(driverMock.getConfigurableUpgrader(DriverBean.CURRENT_DRIVER_VERSION)).thenReturn(driverUpgraderMock);
 
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteLinkInputs(anyString(), any(Connection.class));
@@ -723,7 +723,7 @@ public class TestJdbcRepository {
 
     when(driverMock.getConfigurableUpgrader(DriverBean.CURRENT_DRIVER_VERSION)).thenReturn(driverUpgraderMock);
     when(driverMock.getDriverJobConfigurationClass()).thenReturn(ValidConfiguration.class);
-    List<MJob> jobList = jobs(job(1, "JA", 1, 1, 1, 1), job(2, "JB", 1, 1, 2, 1));
+    List<MJob> jobList = jobs(job(1, "JA", "fromConnectorName", "toConnectorName", 1, 1), job(2, "JB", "fromConnectorName", "toConnectorName", 2, 1));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
     doNothing().when(repoHandlerMock).upgradeDriverAndConfigs(any(MDriver.class), any(Connection.class));
@@ -782,8 +782,8 @@ public class TestJdbcRepository {
     return link;
   }
 
-  private MJob job(long id, String jobName, long fromConnectorId, long toConnectorId, long fromLinkId, long toLinkId) {
-    MJob job = new MJob(fromConnectorId, toConnectorId, fromLinkId, toLinkId,
+  private MJob job(long id, String jobName, String fromConnectorName, String toConnectorName, long fromLinkId, long toLinkId) {
+    MJob job = new MJob(fromConnectorName, toConnectorName, fromLinkId, toLinkId,
         new MFromConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()),
         new MToConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()),
         new MDriverConfig(new LinkedList<MConfig>(), new LinkedList<MValidator>()));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/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 586ef12..7db8718 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
@@ -1539,7 +1539,6 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
             connectorConfigInputStatement, 2, conn);
 
         MLink link = new MLink(connectorName, new MLinkConfig(connectorLinkConfig, Collections.EMPTY_LIST));
-
         link.setPersistenceId(id);
         link.setName(name);
         link.setCreationUser(creationUser);
@@ -1581,7 +1580,6 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
         loadInputsForConfigs(connectorLinkConfig, configStmt, inputStmt);
 
         MLink link = new MLink(connectorName, connectorLinkConfig);
-
         link.setPersistenceId(id);
         link.setName(name);
         link.setCreationUser(creationUser);
@@ -1624,6 +1622,8 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
         Date creationDate = rsJob.getTimestamp(9);
         String updateBy = rsJob.getString(10);
         Date lastUpdateDate = rsJob.getTimestamp(11);
+        String fromConnectorName = rsJob.getString(12);
+        String toConnectorName = rsJob.getString(13);
 
         fromConfigFetchStmt.setLong(1, fromConnectorId);
         toConfigFetchStmt.setLong(1,toConnectorId);
@@ -1652,7 +1652,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
         loadDriverConfigs(driverConfig, driverConfigfetchStmt, jobInputFetchStmt, 2, conn);
 
         MJob job = new MJob(
-            fromConnectorId, toConnectorId,
+            fromConnectorName, toConnectorName,
             fromLinkId, toLinkId,
             new MFromConfig(fromConnectorFromJobConfig, Collections.EMPTY_LIST),
             new MToConfig(toConnectorToJobConfig, Collections.EMPTY_LIST),
@@ -1727,7 +1727,7 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler {
         loadDriverConfigs(driverConfig, driverConfigfetchStmt, jobInputFetchStmt, 2, conn);
 
         MJob job = new MJob(
-          fromConnectorId, toConnectorId,
+          fromConnectorName, toConnectorName,
           fromLinkId, toLinkId,
           new MFromConfig(mFromConfig.getConfigs(), Collections.EMPTY_LIST),
           new MToConfig(mToConfig.getConfigs(), Collections.EMPTY_LIST),

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/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 a9e1881..acacaa9 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
@@ -343,7 +343,7 @@ public class TestJobHandling extends DerbyTestCase {
   }
 
   public MJob getJob() {
-    return new MJob(1, 1, 1, 1, handler.findConnector("A", derbyConnection).getFromConfig(),
+    return new MJob("A", "A", 1, 1, handler.findConnector("A", derbyConnection).getFromConfig(),
         handler.findConnector("A", derbyConnection).getToConfig(), handler.findDriver(
             MDriver.DRIVER_NAME, derbyConnection).getDriverConfig());
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
index 53e4da5..90fffae 100644
--- a/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
+++ b/repository/repository-mysql/src/test/java/org/apache/sqoop/integration/repository/mysql/MySqlTestCase.java
@@ -105,8 +105,8 @@ abstract public class MySqlTestCase {
       MConnector connectorB, MLink linkA, MLink linkB) {
     MDriver driver = handler.findDriver(MDriver.DRIVER_NAME,
         provider.getConnection());
-    MJob job = new MJob(connectorA.getPersistenceId(),
-        connectorB.getPersistenceId(), linkA.getPersistenceId(),
+    MJob job = new MJob(connectorA.getUniqueName(),
+        connectorB.getUniqueName(), linkA.getPersistenceId(),
         linkB.getPersistenceId(), connectorA.getFromConfig(),
         connectorB.getToConfig(), driver.getDriverConfig());
     job.setName(name);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
index 18e33fc..dae3760 100644
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/PostgresqlTestCase.java
@@ -92,8 +92,8 @@ abstract public class PostgresqlTestCase {
   protected MJob getJob(String name, MConnector connectorA, MConnector connectorB, MLink linkA, MLink linkB) {
     MDriver driver = handler.findDriver(MDriver.DRIVER_NAME, provider.getConnection());
     MJob job = new MJob(
-        connectorA.getPersistenceId(),
-        connectorB.getPersistenceId(),
+        connectorA.getUniqueName(),
+        connectorB.getUniqueName(),
         linkA.getPersistenceId(),
         linkB.getPersistenceId(),
         connectorA.getFromConfig(),

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/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 80f7681..ad67a23 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -191,9 +191,9 @@ public class JobRequestHandler implements RequestHandler {
 
     // Verify that user is not trying to spoof us
     MFromConfig fromConfig = ConnectorManager.getInstance()
-        .getConnectorConfigurable(postedJob.getFromConnectorId()).getFromConfig();
+        .getConnectorConfigurable(postedJob.getFromConnectorName()).getFromConfig();
     MToConfig toConfig = ConnectorManager.getInstance()
-        .getConnectorConfigurable(postedJob.getToConnectorId()).getToConfig();
+        .getConnectorConfigurable(postedJob.getToConnectorName()).getToConfig();
     MDriverConfig driverConfig = Driver.getInstance().getDriver().getDriverConfig();
 
     if (!fromConfig.equals(postedJob.getFromJobConfig())
@@ -213,9 +213,9 @@ public class JobRequestHandler implements RequestHandler {
 
     // Corresponding connectors for this
     SqoopConnector fromConnector = ConnectorManager.getInstance().getSqoopConnector(
-        postedJob.getFromConnectorId());
+        postedJob.getFromConnectorName());
     SqoopConnector toConnector = ConnectorManager.getInstance().getSqoopConnector(
-        postedJob.getToConnectorId());
+        postedJob.getToConnectorName());
 
     if (!fromConnector.getSupportedDirections().contains(Direction.FROM)) {
       throw new SqoopException(ServerError.SERVER_0004, "Connector "
@@ -325,16 +325,17 @@ public class JobRequestHandler implements RequestHandler {
   private void addConnectorConfigBundle(JobBean bean, Locale locale) {
     // Add associated resources into the bean
     for (MJob job : bean.getJobs()) {
-      long fromConnectorId = job.getFromConnectorId();
-      long toConnectorId = job.getToConnectorId();
+      String fromConnectorName = job.getFromConnectorName();
+      String toConnectorName = job.getToConnectorName();
+
       // replace it only if it does not already exist
-      if (!bean.hasConnectorConfigBundle(fromConnectorId)) {
-        bean.addConnectorConfigBundle(fromConnectorId, ConnectorManager.getInstance()
-            .getResourceBundle(fromConnectorId, locale));
+      if (!bean.hasConnectorConfigBundle(fromConnectorName)) {
+        bean.addConnectorConfigBundle(fromConnectorName, ConnectorManager.getInstance()
+            .getResourceBundle(fromConnectorName, locale));
       }
-      if (!bean.hasConnectorConfigBundle(toConnectorId)) {
-        bean.addConnectorConfigBundle(toConnectorId, ConnectorManager.getInstance()
-            .getResourceBundle(toConnectorId, locale));
+      if (!bean.hasConnectorConfigBundle(toConnectorName)) {
+        bean.addConnectorConfigBundle(toConnectorName, ConnectorManager.getInstance()
+            .getResourceBundle(toConnectorName, locale));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
index 5e8391c..5191f43 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CloneJobFunction.java
@@ -67,13 +67,10 @@ public class CloneJobFunction extends SqoopFunction {
     MJob job = client.getJob(jobArg);
     job.setPersistenceId(MPersistableEntity.PERSISTANCE_ID_DEFAULT);
 
-    // TODO: the job should be related with connector by connectorName
-    MConnector fromConnector = getClient().getConnector(job.getFromConnectorId());
-    MConnector toConnector = getClient().getConnector(job.getToConnectorId());
     ResourceBundle fromConnectorBundle = client.getConnectorConfigBundle(
-            fromConnector.getUniqueName());
+            job.getFromConnectorName());
     ResourceBundle toConnectorBundle = client.getConnectorConfigBundle(
-            toConnector.getUniqueName());
+            job.getToConnectorName());
     ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
 
     Status status = Status.OK;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
index b0adb3d..4f1d51d 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/CreateJobFunction.java
@@ -77,13 +77,13 @@ public class CreateJobFunction extends  SqoopFunction {
     ConsoleReader reader = getConsoleReader();
     MJob job = getClient().createJob(fromLinkArg, toLinkArg);
 
-    MConnector fromConnector = getClient().getConnector(job.getFromConnectorId());
+    MConnector fromConnector = getClient().getConnector(job.getFromConnectorName());
     if (!fromConnector.getSupportedDirections().isDirectionSupported(Direction.FROM)) {
       errorMessage("Connector " + fromConnector.getUniqueName() + " does not support direction " + Direction.FROM);
       return Status.ERROR;
     }
 
-    MConnector toConnector = getClient().getConnector(job.getToConnectorId());
+    MConnector toConnector = getClient().getConnector(job.getToConnectorName());
     if (!toConnector.getSupportedDirections().isDirectionSupported(Direction.TO)) {
       errorMessage("Connector " + toConnector.getUniqueName() + " does not support direction " + Direction.TO);
       return Status.ERROR;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
index faad505..e36a903 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowJobFunction.java
@@ -99,12 +99,7 @@ public class ShowJobFunction extends SqoopFunction {
       if (fromLink != null) {
         fromLinkName = fromLink.getName();
       }
-      String fromConnectorName = "";
-      MConnector fromConnector = client.getConnector(job.getFromConnectorId());
-      if (fromConnector != null) {
-        fromConnectorName = fromConnector.getUniqueName();
-      }
-      fromConnectors.add(fromLinkName + " (" + fromConnectorName + ")");
+      fromConnectors.add(fromLinkName + " (" + job.getFromConnectorName() + ")");
 
       // To link and connector
       String toLinkName = "";
@@ -112,12 +107,7 @@ public class ShowJobFunction extends SqoopFunction {
       if (toLink != null) {
         toLinkName = toLink.getName();
       }
-      String toConnnectorName = "";
-      MConnector toConnector = client.getConnector(job.getToConnectorId());
-      if (toConnector != null) {
-        toConnnectorName = toConnector.getUniqueName();
-      }
-      toConnectors.add(toLinkName + " (" + toConnnectorName + ")");
+      toConnectors.add(toLinkName + " (" + job.getToConnectorName() + ")");
 
       availabilities.add(String.valueOf(job.getEnabled()));
     }
@@ -160,19 +150,15 @@ public class ShowJobFunction extends SqoopFunction {
       formatter.format(job.getLastUpdateDate())
     );
 
-    // TODO: should be removed when MJob link with Connector by name.
-    MConnector fromConnector = getClient().getConnector(job.getFromConnectorId());
-    MConnector toConnector = getClient().getConnector(job.getToConnectorId());
-
     displayConfig(job.getDriverConfig().getConfigs(),
             client.getDriverConfigBundle());
     printlnResource(Constants.RES_SHOW_PROMPT_JOB_FROM_LID_INFO,
         job.getFromLinkId());
     displayConfig(job.getFromJobConfig().getConfigs(),
-                 client.getConnectorConfigBundle(fromConnector.getUniqueName()));
+                 client.getConnectorConfigBundle(job.getFromConnectorName()));
     printlnResource(Constants.RES_SHOW_PROMPT_JOB_TO_LID_INFO,
             job.getToLinkId());
     displayConfig(job.getToJobConfig().getConfigs(),
-                 client.getConnectorConfigBundle(toConnector.getUniqueName()));
+                 client.getConnectorConfigBundle(job.getToConnectorName()));
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java b/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
index 95f044f..ff23a68 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/UpdateJobFunction.java
@@ -68,14 +68,10 @@ public class UpdateJobFunction extends SqoopFunction {
     // TODO(SQOOP-1634): using from/to and driver config id, this call can be avoided
     MJob job = client.getJob(jobArg);
 
-    // TODO: should be removed when MJob link with Connector by name.
-    MConnector fromConnector = getClient().getConnector(job.getFromConnectorId());
-    MConnector toConnector = getClient().getConnector(job.getToConnectorId());
-
     ResourceBundle fromConnectorBundle = client.getConnectorConfigBundle(
-            fromConnector.getUniqueName());
+            job.getFromConnectorName());
     ResourceBundle toConnectorBundle = client.getConnectorConfigBundle(
-            toConnector.getUniqueName());
+            job.getToConnectorName());
     ResourceBundle driverConfigBundle = client.getDriverConfigBundle();
 
     Status status = Status.OK;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
index 14daa87..4cb855b 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
@@ -155,7 +155,7 @@ public class TestCloneCommand {
   @Test
   public void testCloneJob() {
     ShellEnvironment.setInteractive(false);
-    MJob job = new MJob(1L, 2L, 1L, 2L,
+    MJob job = new MJob("fromConnectorName", "toConnectorName", 1L, 2L,
         new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MDriverConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()));
@@ -192,7 +192,7 @@ public class TestCloneCommand {
   public void testCloneJobInteractive() {
     ShellEnvironment.setInteractive(true);
     initEnv();
-    MJob job = new MJob(1, 2, 1, 2, new MFromConfig(getConfig("fromJobConfig"), new ArrayList<MValidator>()),
+    MJob job = new MJob("fromConnectorName", "toConnectorName", 1, 2, new MFromConfig(getConfig("fromJobConfig"), new ArrayList<MValidator>()),
         new MToConfig(getConfig("toJobConfig"), new ArrayList<MValidator>()),
         new MDriverConfig(getConfig("driverConfig"), new ArrayList<MValidator>()));
     when(client.getJob("job_test")).thenReturn(job);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
index 89f4fe8..f2e8fc0 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
@@ -182,11 +182,11 @@ public class TestCreateCommand {
     MConnector fromConnector = new MConnector("connector_from", "", "", null, new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()), null);
     MConnector toConnector = new MConnector("connector_to", "", "", null, null, new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()));
     when(client.createJob("link_from", "link_to")).thenReturn(
-        new MJob(1, 2, 1, 2, new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
+        new MJob("fromConnectorName", "toConnectorName", 1, 2, new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
             new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
             new MDriverConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>())));
-    when(client.getConnector(1)).thenReturn(fromConnector);
-    when(client.getConnector(2)).thenReturn(toConnector);
+    when(client.getConnector("fromConnectorName")).thenReturn(fromConnector);
+    when(client.getConnector("toConnectorName")).thenReturn(toConnector);
     when(client.saveJob(any(MJob.class))).thenReturn(Status.OK);
 
     // create job -f link_from -to link_to
@@ -222,12 +222,12 @@ public class TestCreateCommand {
     initEnv();
     MConnector fromConnector = new MConnector("connector_from", "", "", null, new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()), null);
     MConnector toConnector = new MConnector("connector_to", "", "", null, null, new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()));
-    MJob job = new MJob(1, 2, 1, 2, new MFromConfig(getConfig("fromJobConfig"), new ArrayList<MValidator>()),
+    MJob job = new MJob("fromConnectorName", "toConnectorName", 1, 2, new MFromConfig(getConfig("fromJobConfig"), new ArrayList<MValidator>()),
         new MToConfig(getConfig("toJobConfig"), new ArrayList<MValidator>()),
         new MDriverConfig(getConfig("driverConfig"), new ArrayList<MValidator>()));
     when(client.createJob("link_from", "link_to")).thenReturn(job);
-    when(client.getConnector(1)).thenReturn(fromConnector);
-    when(client.getConnector(2)).thenReturn(toConnector);
+    when(client.getConnector("fromConnectorName")).thenReturn(fromConnector);
+    when(client.getConnector("toConnectorName")).thenReturn(toConnector);
     when(client.saveJob(any(MJob.class))).thenReturn(Status.OK);
     when(client.getConnectorConfigBundle(any(String.class))).thenReturn(resourceBundle);
     when(client.getDriverConfigBundle()).thenReturn(resourceBundle);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
index 870bee3..c7b57af 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
@@ -235,11 +235,11 @@ public class TestShowCommand {
   public void testShowJob() {
     when(client.getJobs()).thenReturn(new ArrayList<MJob>());
     when(client.getConnector(any(Long.class))).thenReturn(new MConnector("", "", "", null, null, null));
-    when(client.getJob("1")).thenReturn(new MJob(1L, 2L, 1L, 2L,
+    when(client.getJob("1")).thenReturn(new MJob("fromConnectorName", "toConnectorName", 1L, 2L,
         new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MDriverConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>())));
-    when(client.getJobsByConnector("2")).thenReturn(Arrays.asList(new MJob(1L, 2L, 1L, 2L,
+    when(client.getJobsByConnector("2")).thenReturn(Arrays.asList(new MJob("fromConnectorName", "toConnectorName", 1L, 2L,
         new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MDriverConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()))));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/shell/src/test/java/org/apache/sqoop/shell/TestUpdateCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestUpdateCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestUpdateCommand.java
index 2a6670d..d9f8c46 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestUpdateCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestUpdateCommand.java
@@ -173,7 +173,7 @@ public class TestUpdateCommand {
   @Test
   public void testUpdateJob() throws InterruptedException {
     ShellEnvironment.setInteractive(false);
-    MJob job = new MJob(1L, 2L, 1L, 2L,
+    MJob job = new MJob("fromConnectorName", "toConnectorName", 1L, 2L,
         new MFromConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MToConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()),
         new MDriverConfig(new ArrayList<MConfig>(), new ArrayList<MValidator>()));
@@ -210,7 +210,7 @@ public class TestUpdateCommand {
   public void testUpdateJobInteractive() {
     ShellEnvironment.setInteractive(true);
     initEnv();
-    MJob job = new MJob(1, 2, 1, 2, new MFromConfig(getConfig("fromJobConfig"), new ArrayList<MValidator>()),
+    MJob job = new MJob("fromConnectorName", "toConnectorName", 1, 2, new MFromConfig(getConfig("fromJobConfig"), new ArrayList<MValidator>()),
         new MToConfig(getConfig("toJobConfig"), new ArrayList<MValidator>()),
         new MDriverConfig(getConfig("driverConfig"), new ArrayList<MValidator>()));
     when(client.getJob("job_test")).thenReturn(job);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/e70b9c25/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
----------------------------------------------------------------------
diff --git a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
index 2afb965..8ba8d84 100644
--- a/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
+++ b/tools/src/main/java/org/apache/sqoop/tools/tool/RepositoryLoadTool.java
@@ -324,8 +324,8 @@ public class RepositoryLoadTool extends ConfiguredTool {
   private long loadJob(MJob job) {
     // starting by pretending we have a brand new job
     resetPersistenceId(job);
-    MConnector mFromConnector = ConnectorManager.getInstance().getConnectorConfigurable(job.getFromConnectorId());
-    MConnector mToConnector = ConnectorManager.getInstance().getConnectorConfigurable(job.getToConnectorId());
+    MConnector mFromConnector = ConnectorManager.getInstance().getConnectorConfigurable(job.getFromConnectorName());
+    MConnector mToConnector = ConnectorManager.getInstance().getConnectorConfigurable(job.getToConnectorName());
 
     MFromConfig fromConfig = job.getFromJobConfig();
     MToConfig toConfig = job.getToJobConfig();
@@ -347,10 +347,10 @@ public class RepositoryLoadTool extends ConfiguredTool {
     // Transform config structures to objects for validations
     SqoopConnector fromConnector =
         ConnectorManager.getInstance().getSqoopConnector(
-            job.getFromConnectorId());
+            job.getFromConnectorName());
     SqoopConnector toConnector =
         ConnectorManager.getInstance().getSqoopConnector(
-            job.getToConnectorId());
+            job.getToConnectorName());
 
     Object fromConnectorConfig = ClassUtils.instantiate(
         fromConnector.getJobConfigurationClass(Direction.FROM));


Mime
View raw message