sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject git commit: SQOOP-997: Sqoop2: Upgrade: Provide ability to disable the automatic upgrade
Date Tue, 02 Jul 2013 19:55:29 GMT
Updated Branches:
  refs/heads/sqoop2 226044d3b -> 8c74223b5


SQOOP-997: Sqoop2: Upgrade: Provide ability to disable the automatic upgrade

(Mengwei Ding 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/8c74223b
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/8c74223b
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/8c74223b

Branch: refs/heads/sqoop2
Commit: 8c74223b593a142e0317528d75a542d99762a333
Parents: 226044d
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Jul 2 12:54:44 2013 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Jul 2 12:54:44 2013 -0700

----------------------------------------------------------------------
 .../sqoop/connector/ConnectorManager.java       | 13 +++++++++---
 .../sqoop/core/ConfigurationConstants.java      |  5 +++++
 .../sqoop/framework/FrameworkManager.java       |  9 +++++++-
 .../apache/sqoop/repository/JdbcRepository.java | 22 ++++++++++++++------
 .../org/apache/sqoop/repository/Repository.java |  6 ++++--
 .../sqoop/repository/RepositoryError.java       |  3 +++
 dist/src/main/server/conf/sqoop.properties      | 10 +++++++++
 7 files changed, 56 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index 0540f6b..fa91d02 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -54,6 +54,11 @@ public class ConnectorManager implements Reconfigurable {
   private static ConnectorManager instance;
 
   /**
+   * Default connector auto upgrade option value
+   */
+  private static boolean DEFAULT_AUTO_UPGRADE = false;
+
+  /**
    * Create default object by default.
    *
    * Every Sqoop server application needs one so this should not be performance issue.
@@ -185,7 +190,9 @@ public class ConnectorManager implements Reconfigurable {
       throw new SqoopException(ConnectorError.CONN_0001, ex);
     }
 
-    registerConnectors();
+    boolean autoUpgrade = SqoopConfiguration.getInstance().getContext().getBoolean(
+        ConfigurationConstants.CONNECTOR_AUTO_UPGRADE, DEFAULT_AUTO_UPGRADE);
+    registerConnectors(autoUpgrade);
 
     SqoopConfiguration.getInstance().getProvider().registerListener(new CoreConfigurationListener(this));
 
@@ -194,7 +201,7 @@ public class ConnectorManager implements Reconfigurable {
     }
   }
 
-  private synchronized void registerConnectors() {
+  private synchronized void registerConnectors(boolean autoUpgrade) {
     Repository repository = RepositoryManager.getInstance().getRepository();
 
     RepositoryTransaction rtx = null;
@@ -205,7 +212,7 @@ public class ConnectorManager implements Reconfigurable {
         ConnectorHandler handler = handlerMap.get(name);
         MConnector connectorMetadata = handler.getMetadata();
         MConnector registeredMetadata =
-            repository.registerConnector(connectorMetadata);
+            repository.registerConnector(connectorMetadata, autoUpgrade);
 
         // Set registered metadata instead of connector metadata as they will
         // have filled persistent ids. We should be confident at this point that

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java b/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
index 838aaaf..f225fcb 100644
--- a/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
+++ b/core/src/main/java/org/apache/sqoop/core/ConfigurationConstants.java
@@ -70,6 +70,11 @@ public final class ConfigurationConstants {
   public static final String PROPERTIES_PROVIDER_SLEEP =
     PREFIX_PROPERTIES_PROVIDER_CONFIG + "sleep";
 
+  public static final String CONNECTOR_AUTO_UPGRADE =
+      "org.apache.sqoop.connector.autoupgrade";
+
+  public static final String FRAMEWORK_AUTO_UPGRADE =
+      "org.apache.sqoop.framework.autoupgrade";
 
   private ConfigurationConstants() {
     // Disable explicit object creation

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
index a81306b..ad6cd0f 100644
--- a/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
+++ b/core/src/main/java/org/apache/sqoop/framework/FrameworkManager.java
@@ -19,6 +19,7 @@ package org.apache.sqoop.framework;
 
 import org.apache.log4j.Logger;
 import org.apache.sqoop.connector.spi.MetadataUpgrader;
+import org.apache.sqoop.core.ConfigurationConstants;
 import org.apache.sqoop.core.Reconfigurable;
 import org.apache.sqoop.core.SqoopConfiguration;
 import org.apache.sqoop.core.SqoopConfiguration.CoreConfigurationListener;
@@ -105,6 +106,10 @@ public class FrameworkManager implements Reconfigurable {
    */
   private final MetadataUpgrader upgrader;
 
+  /**
+   * Default framework auto upgrade option value
+   */
+  private static final boolean DEFAULT_AUTO_UPGRADE = false;
 
   public Class getJobConfigurationClass(MJob.Type jobType) {
       switch (jobType) {
@@ -142,7 +147,9 @@ public class FrameworkManager implements Reconfigurable {
     LOG.trace("Begin submission engine manager initialization");
 
     // Register framework metadata in repository
-    mFramework = RepositoryManager.getInstance().getRepository().registerFramework(mFramework);
+    boolean autoUpgrade = SqoopConfiguration.getInstance().getContext().getBoolean(
+        ConfigurationConstants.FRAMEWORK_AUTO_UPGRADE, DEFAULT_AUTO_UPGRADE);
+    mFramework = RepositoryManager.getInstance().getRepository().registerFramework(mFramework,
autoUpgrade);
 
     SqoopConfiguration.getInstance().getProvider().registerListener(new CoreConfigurationListener(this));
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/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 aa1aa8d..2d9bf4e 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -154,7 +154,7 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
-  public MConnector registerConnector(final MConnector mConnector) {
+  public MConnector registerConnector(final MConnector mConnector, final boolean autoUpgrade)
{
 
     return (MConnector) doWithConnection(new DoWithConnection() {
       @Override
@@ -172,8 +172,13 @@ public class JdbcRepository extends Repository {
           // monotonically increasing.
           if (result.getUniqueName().equals(mConnector.getUniqueName()) &&
             mConnector.getVersion().compareTo(result.getVersion()) > 0) {
-            upgradeConnector(result, mConnector);
-            return mConnector;
+            if (autoUpgrade) {
+              upgradeConnector(result, mConnector);
+              return mConnector;
+            } else {
+              throw new SqoopException(RepositoryError.JDBCREPO_0026,
+                "Connector: " + mConnector.getUniqueName());
+            }
           }
           if (!result.equals(mConnector)) {
             throw new SqoopException(RepositoryError.JDBCREPO_0013,
@@ -204,7 +209,7 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
-  public MFramework registerFramework(final MFramework mFramework) {
+  public MFramework registerFramework(final MFramework mFramework, final boolean autoUpgrade)
{
     return (MFramework) doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) {
@@ -216,8 +221,13 @@ public class JdbcRepository extends Repository {
           // We're currently not serializing framework version into repository
           // so let's just compare the structure to see if we need upgrade.
           if(!mFramework.equals(result)) {
-            upgradeFramework(mFramework);
-            return mFramework;
+            if (autoUpgrade) {
+              upgradeFramework(mFramework);
+              return mFramework;
+            } else {
+              throw new SqoopException(RepositoryError.JDBCREPO_0026,
+                "Framework: " + mFramework.getPersistenceId());
+            }
           }
           return result;
         }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/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 306bd90..46cb7e6 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -81,9 +81,10 @@ public abstract class Repository {
    * given connector are already registered with different structure.
    *
    * @param mConnector the connector metadata to be registered
+   * autoupgrade whether to upgrade framework automatically
    * @return Registered connector structure
    */
-  public abstract MConnector registerConnector(MConnector mConnector);
+  public abstract MConnector registerConnector(MConnector mConnector, boolean autoUpgrade);
 
   /**
    * Search for connector with given name in repository.
@@ -103,9 +104,10 @@ public abstract class Repository {
    * given framework are already registered with different structure.
    *
    * @param mFramework framework metadata to be registered
+   * autoupgrade whether to upgrade framework automatically
    * @return Registered connector structure
    */
-  public abstract MFramework registerFramework(MFramework mFramework);
+  public abstract MFramework registerFramework(MFramework mFramework, boolean autoUpgrade);
 
   /**
    * Save given connection to repository. This connection must not be already

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
index ab5e5a1..c616889 100644
--- a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
+++ b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
@@ -118,6 +118,9 @@ public enum RepositoryError implements ErrorCode {
   /** Invalid submission id **/
   JDBCREPO_0025("Given submission id is invalid"),
 
+  /** Upgrade required but not allowed **/
+  JDBCREPO_0026("Upgrade required but not allowed");
+
   ;
 
   private final String message;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/8c74223b/dist/src/main/server/conf/sqoop.properties
----------------------------------------------------------------------
diff --git a/dist/src/main/server/conf/sqoop.properties b/dist/src/main/server/conf/sqoop.properties
index 07b148e..76596b4 100755
--- a/dist/src/main/server/conf/sqoop.properties
+++ b/dist/src/main/server/conf/sqoop.properties
@@ -83,6 +83,16 @@ org.apache.sqoop.repository.jdbc.password=
 # System properties for embedded Derby configuration
 org.apache.sqoop.repository.sysprop.derby.stream.error.file=@LOGDIR@/derbyrepo.log
 
+#
+# Connector configuration
+#
+org.apache.sqoop.connector.autoupgrade=false
+
+#
+# Framework configuration
+#
+org.apache.sqoop.framework.autoupgrade=false
+
 # Sleeping period for reloading configuration file (once a minute)
 org.apache.sqoop.core.configuration.provider.properties.sleep=60000
 


Mime
View raw message