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-1732: Sqoop2: Add version to connector upgrade API
Date Wed, 14 Oct 2015 21:56:19 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 72a9d4383 -> 1ea3db992


SQOOP-1732: Sqoop2: Add version to connector upgrade API

(Abraham Fine 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/1ea3db99
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/1ea3db99
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/1ea3db99

Branch: refs/heads/sqoop2
Commit: 1ea3db992beaf29189399b4813a258e219e2f69e
Parents: 72a9d43
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Wed Oct 14 14:55:55 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Wed Oct 14 14:55:55 2015 -0700

----------------------------------------------------------------------
 .../sqoop/connector/ftp/FtpConnector.java       |  2 +-
 .../connector/jdbc/GenericJdbcConnector.java    |  2 +-
 .../sqoop/connector/hdfs/HdfsConnector.java     |  2 +-
 .../sqoop/connector/kafka/KafkaConnector.java   |  2 +-
 .../sqoop/connector/kite/KiteConnector.java     |  2 +-
 .../sqoop/connector/spi/SqoopConnector.java     |  2 +-
 .../sqoop/connector/sftp/SftpConnector.java     |  2 +-
 .../java/org/apache/sqoop/driver/Driver.java    |  2 +-
 .../apache/sqoop/repository/JdbcRepository.java |  2 +-
 .../org/apache/sqoop/repository/Repository.java |  7 ++--
 .../sqoop/repository/TestJdbcRepository.java    | 40 ++++++++++----------
 docs/src/site/sphinx/ConnectorDevelopment.rst   |  2 +-
 .../resources/TestConnector/TestConnector.java  |  2 +-
 .../sqoop/tools/tool/RepositoryLoadTool.java    | 25 ++++++++++--
 14 files changed, 56 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/FtpConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/FtpConnector.java
b/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/FtpConnector.java
index ffef1bf..a44253e 100644
--- a/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/FtpConnector.java
+++ b/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/FtpConnector.java
@@ -122,7 +122,7 @@ public class FtpConnector extends SqoopConnector {
    * @return configurable upgrader object
    */
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     return new FtpConnectorUpgrader();
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
index c233ed5..113465a 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnector.java
@@ -91,7 +91,7 @@ public class GenericJdbcConnector extends SqoopConnector {
   }
 
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     return new GenericJdbcConnectorUpgrader();
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
index 2d5ba58..7e7c022 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsConnector.java
@@ -118,7 +118,7 @@ public class HdfsConnector extends SqoopConnector {
    * @return configurable upgrader object
    */
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     return new HdfsConnectorUpgrader();
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaConnector.java
b/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaConnector.java
index e3eafe8..2b03fa0 100644
--- a/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaConnector.java
+++ b/connector/connector-kafka/src/main/java/org/apache/sqoop/connector/kafka/KafkaConnector.java
@@ -107,7 +107,7 @@ public class KafkaConnector extends SqoopConnector {
    * @return ConnectorConfigurableUpgrader object
    */
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     // Nothing to upgrade at this point
     return null;
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/KiteConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/KiteConnector.java
b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/KiteConnector.java
index 5f58a90..ca860b1 100644
--- a/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/KiteConnector.java
+++ b/connector/connector-kite/src/main/java/org/apache/sqoop/connector/kite/KiteConnector.java
@@ -88,7 +88,7 @@ public class KiteConnector extends SqoopConnector {
   }
 
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     return new KiteConnectorUpgrader();
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-sdk/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-sdk/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
b/connector/connector-sdk/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
index bfd5f23..85ba8be 100644
--- a/connector/connector-sdk/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
+++ b/connector/connector-sdk/src/main/java/org/apache/sqoop/connector/spi/SqoopConnector.java
@@ -87,7 +87,7 @@ public abstract class SqoopConnector {
    * configs related to the link and job
    * @return ConnectorConfigurableUpgrader object
    */
-  public abstract ConnectorConfigurableUpgrader getConfigurableUpgrader();
+  public abstract ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion);
 
   /**
    * Returns the {@linkplain IntermediateDataFormat} this connector

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/SftpConnector.java
----------------------------------------------------------------------
diff --git a/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/SftpConnector.java
b/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/SftpConnector.java
index c2ce8da..49d6066 100644
--- a/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/SftpConnector.java
+++ b/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/SftpConnector.java
@@ -122,7 +122,7 @@ public class SftpConnector extends SqoopConnector {
    * @return configurable upgrader object
    */
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     return new SftpConnectorUpgrader();
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/core/src/main/java/org/apache/sqoop/driver/Driver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/Driver.java b/core/src/main/java/org/apache/sqoop/driver/Driver.java
index c4f84d6..2d1d73e 100644
--- a/core/src/main/java/org/apache/sqoop/driver/Driver.java
+++ b/core/src/main/java/org/apache/sqoop/driver/Driver.java
@@ -142,7 +142,7 @@ public class Driver implements Reconfigurable {
     LOG.trace("Begin Driver destroy");
   }
 
-  public DriverUpgrader getConfigurableUpgrader() {
+  public DriverUpgrader getConfigurableUpgrader(String oldDriverVersion) {
     return driverUpgrader;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/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 055ccc4..952ce5d 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -243,7 +243,7 @@ public class JdbcRepository extends Repository {
           if(!mDriver.equals(existingDriver)) {
             if (autoUpgrade) {
               mDriver.setPersistenceId(existingDriver.getPersistenceId());
-              upgradeDriver(mDriver);
+              upgradeDriver(mDriver, existingDriver.getVersion());
               return mDriver;
             } else {
               throw new SqoopException(RepositoryError.JDBCREPO_0026,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/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 144e419..9396ef6 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -448,6 +448,7 @@ public abstract class Repository {
     LOG.info("Upgrading connector: " + oldConnector.getUniqueName());
     long connectorId = oldConnector.getPersistenceId();
     String connectorName = oldConnector.getUniqueName();
+    String oldVersion = oldConnector.getVersion();
     newConnector.setPersistenceId(connectorId);
 
     RepositoryTransaction tx = null;
@@ -457,7 +458,7 @@ public abstract class Repository {
 
       boolean upgradeSuccessful = true;
       // 1. Get an upgrader for the connector
-      ConnectorConfigurableUpgrader upgrader = connector.getConfigurableUpgrader();
+      ConnectorConfigurableUpgrader upgrader = connector.getConfigurableUpgrader(oldVersion);
       // 2. Get all links associated with the connector.
       List<MLink> existingLinksByConnector = findLinksForConnectorUpgrade(connectorName);
       // 3. Get all jobs associated with the connector.
@@ -606,12 +607,12 @@ public abstract class Repository {
     }
   }
 
-  public final void upgradeDriver(MDriver driver) {
+  public final void upgradeDriver(MDriver driver, String oldDriverVersion) {
     LOG.info("Upgrading driver");
     RepositoryTransaction tx = null;
     try {
       //1. find upgrader
-      DriverUpgrader upgrader = Driver.getInstance().getConfigurableUpgrader();
+      DriverUpgrader upgrader = Driver.getInstance().getConfigurableUpgrader(oldDriverVersion);
       //2. find all jobs in the system
       List<MJob> existingJobs = findJobs();
       boolean upgradeSuccessful = true;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/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 78728f6..bb4da65 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -214,7 +214,7 @@ public class TestJdbcRepository {
 
     // prepare the sqoop connector
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfiguration.class);
     when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(EmptyConfiguration.class);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
@@ -268,7 +268,7 @@ public class TestJdbcRepository {
   public void testDriverConfigUpgradeWithValidJobs() {
     MDriver newDriverConfig = driver();
 
-    when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
+    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));
 
@@ -277,7 +277,7 @@ public class TestJdbcRepository {
     doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
     doNothing().when(repoSpy).upgradeDriverAndConfigs(any(MDriver.class), any(RepositoryTransaction.class));
 
-    repoSpy.upgradeDriver(newDriverConfig);
+    repoSpy.upgradeDriver(newDriverConfig, DriverBean.CURRENT_DRIVER_VERSION);
 
     InOrder repoOrder = inOrder(repoSpy);
     InOrder txOrder = inOrder(repoTransactionMock);
@@ -306,7 +306,7 @@ public class TestJdbcRepository {
   public void testDriverConfigUpgradeWithInvalidJobs() {
     MDriver newDriverConfig = driver();
 
-    when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
+    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));
 
@@ -315,7 +315,7 @@ public class TestJdbcRepository {
     doNothing().when(repoSpy).upgradeDriverAndConfigs(any(MDriver.class), any(RepositoryTransaction.class));
 
     try {
-      repoSpy.upgradeDriver(newDriverConfig);
+      repoSpy.upgradeDriver(newDriverConfig, DriverBean.CURRENT_DRIVER_VERSION);
     } catch (SqoopException ex) {
       assertEquals(ex.getErrorCode(), RepositoryError.JDBCREPO_0027);
 
@@ -351,7 +351,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
@@ -380,7 +380,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
@@ -414,7 +414,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
@@ -452,7 +452,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
@@ -490,7 +490,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1, "LA", 1), link(2, "LB", 1));
@@ -530,7 +530,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(sqconnector.getLinkConfigurationClass()).thenReturn(ValidConfiguration.class);
     when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(ValidConfiguration.class);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
@@ -576,7 +576,7 @@ public class TestJdbcRepository {
     MConnector oldConnector = connector(1);
 
     SqoopConnector sqconnector = mock(SqoopConnector.class);
-    when(sqconnector.getConfigurableUpgrader()).thenReturn(connectorUpgraderMock);
+    when(sqconnector.getConfigurableUpgrader(oldConnector.getVersion())).thenReturn(connectorUpgraderMock);
     when(sqconnector.getLinkConfigurationClass()).thenReturn(ValidConfiguration.class);
     when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(ValidConfiguration.class);
     when(connectorMgrMock.getSqoopConnector(anyString())).thenReturn(sqconnector);
@@ -624,14 +624,14 @@ public class TestJdbcRepository {
   public void testDriverConfigUpgradeHandlerWithFindJobsError() {
     MDriver newDriverConfig = driver();
 
-    when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
+    when(driverMock.getConfigurableUpgrader(DriverBean.CURRENT_DRIVER_VERSION)).thenReturn(driverUpgraderMock);
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
         "find jobs error.");
     doThrow(exception).when(repoHandlerMock).findJobs(any(Connection.class));
 
     try {
-      repoSpy.upgradeDriver(newDriverConfig);
+      repoSpy.upgradeDriver(newDriverConfig, "1.0");
     } catch (SqoopException ex) {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
@@ -650,7 +650,7 @@ public class TestJdbcRepository {
   public void testDriverConfigUpgradeHandlerWithDeleteJobInputsError() {
     MDriver newDriverConfig = driver();
 
-    when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
+    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));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
@@ -660,7 +660,7 @@ public class TestJdbcRepository {
     doThrow(exception).when(repoHandlerMock).deleteJobInputs(anyString(), any(Connection.class));
 
     try {
-      repoSpy.upgradeDriver(newDriverConfig);
+      repoSpy.upgradeDriver(newDriverConfig, "1.0");
     } catch (SqoopException ex) {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
@@ -680,7 +680,7 @@ public class TestJdbcRepository {
   public void testDriverConfigUpgradeHandlerWithUpdateDriverConfigError() {
     MDriver newDriverConfig = driver();
 
-    when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
+    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));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
@@ -692,7 +692,7 @@ public class TestJdbcRepository {
     doThrow(exception).when(repoHandlerMock).upgradeDriverAndConfigs(any(MDriver.class),
any(Connection.class));
 
     try {
-      repoSpy.upgradeDriver(newDriverConfig);
+      repoSpy.upgradeDriver(newDriverConfig, "1.0");
     } catch (SqoopException ex) {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
@@ -714,7 +714,7 @@ public class TestJdbcRepository {
   public void testDriverConfigUpgradeHandlerWithUpdateJobError() {
     MDriver driverConfig = driver();
 
-    when(driverMock.getConfigurableUpgrader()).thenReturn(driverUpgraderMock);
+    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));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
@@ -727,7 +727,7 @@ public class TestJdbcRepository {
     doThrow(exception).when(repoHandlerMock).updateJob(any(MJob.class), any(Connection.class));
 
     try {
-      repoSpy.upgradeDriver(driverConfig);
+      repoSpy.upgradeDriver(driverConfig, DriverBean.CURRENT_DRIVER_VERSION);
     } catch (SqoopException ex) {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/docs/src/site/sphinx/ConnectorDevelopment.rst
----------------------------------------------------------------------
diff --git a/docs/src/site/sphinx/ConnectorDevelopment.rst b/docs/src/site/sphinx/ConnectorDevelopment.rst
index 60dae3f..0e8ea92 100644
--- a/docs/src/site/sphinx/ConnectorDevelopment.rst
+++ b/docs/src/site/sphinx/ConnectorDevelopment.rst
@@ -54,7 +54,7 @@ The ``SqoopConnector`` class defines an API for the connectors that must
be impl
   public abstract Class getJobConfigurationClass(Direction direction);
   public abstract From getFrom();
   public abstract To getTo();
-  public abstract ConnectorConfigurableUpgrader getConfigurableUpgrader()
+  public abstract ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
 
 Connectors can optionally override the following methods:
 ::

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/test/src/test/resources/TestConnector/TestConnector.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnector/TestConnector.java b/test/src/test/resources/TestConnector/TestConnector.java
index d58a824..a235a78 100644
--- a/test/src/test/resources/TestConnector/TestConnector.java
+++ b/test/src/test/resources/TestConnector/TestConnector.java
@@ -78,7 +78,7 @@ public class TestConnector extends SqoopConnector {
   }
 
   @Override
-  public ConnectorConfigurableUpgrader getConfigurableUpgrader() {
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion)
{
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1ea3db99/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 2ac8ce8..75d2182 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
@@ -263,6 +263,14 @@ public class RepositoryLoadTool extends ConfiguredTool {
     return true;
   }
 
+  /**
+   * We currently pass through null as the old connector version because we do
+   * not have a good way of determining what the old version of the connector is
+   * here.
+   *
+   * According to Jarcec, this chunk of code will receive some much needed
+   * attention in the near future and this will be fixed.
+   */
   private long loadLink(MLink link) {
 
     // starting by pretending we have a brand new link
@@ -271,7 +279,7 @@ public class RepositoryLoadTool extends ConfiguredTool {
     Repository repository = RepositoryManager.getInstance().getRepository();
 
     MConnector mConnector = ConnectorManager.getInstance().getConnectorConfigurable(link.getConnectorId());
-    ConnectorConfigurableUpgrader connectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mConnector.getUniqueName()).getConfigurableUpgrader();
+    ConnectorConfigurableUpgrader connectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mConnector.getUniqueName()).getConfigurableUpgrader(null);
 
     List<MConfig> connectorConfigs = mConnector.getLinkConfig().clone(false).getConfigs();
     List<MValidator> connectorValidators = mConnector.getLinkConfig().getCloneOfValidators();
@@ -304,6 +312,15 @@ public class RepositoryLoadTool extends ConfiguredTool {
     return newLink.getPersistenceId();
   }
 
+
+  /**
+   * We currently pass through null as the old connector version because we do
+   * not have a good way of determining what the old version of the connector is
+   * here.
+   *
+   * According to Jarcec, this chunk of code will receive some much needed
+   * attention in the near future and this will be fixed.
+   */
   private long loadJob(MJob job) {
     // starting by pretending we have a brand new job
     resetPersistenceId(job);
@@ -313,14 +330,14 @@ public class RepositoryLoadTool extends ConfiguredTool {
     MFromConfig fromConfig = job.getFromJobConfig();
     MToConfig toConfig = job.getToJobConfig();
 
-    ConnectorConfigurableUpgrader fromConnectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mFromConnector.getUniqueName()).getConfigurableUpgrader();
-    ConnectorConfigurableUpgrader toConnectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mToConnector.getUniqueName()).getConfigurableUpgrader();
+    ConnectorConfigurableUpgrader fromConnectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mFromConnector.getUniqueName()).getConfigurableUpgrader(null);
+    ConnectorConfigurableUpgrader toConnectorConfigUpgrader = ConnectorManager.getInstance().getSqoopConnector(mToConnector.getUniqueName()).getConfigurableUpgrader(null);
 
     fromConnectorConfigUpgrader.upgradeFromJobConfig(job.getFromJobConfig(), fromConfig);
 
     toConnectorConfigUpgrader.upgradeToJobConfig(job.getToJobConfig(), toConfig);
 
-    DriverUpgrader driverConfigUpgrader =  Driver.getInstance().getConfigurableUpgrader();
+    DriverUpgrader driverConfigUpgrader =  Driver.getInstance().getConfigurableUpgrader(null);
     MDriver driver = Driver.getInstance().getDriver();
     MDriverConfig driverConfigs = driver.getDriverConfig();
     driverConfigUpgrader.upgradeJobConfig( job.getDriverConfig(), driverConfigs);


Mime
View raw message