sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hshreedha...@apache.org
Subject git commit: SQOOP-1180. Sqoop2: Metadata upgrade is calling validators with Model classes instead of configuration objects
Date Thu, 22 Aug 2013 04:12:42 GMT
Updated Branches:
  refs/heads/sqoop2 22f6ca5a4 -> da06408f2


SQOOP-1180. Sqoop2: Metadata upgrade is calling validators with Model classes instead of configuration
objects

(Jarek Jarcec Cecho via Hari Shreedharan)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/da06408f
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/da06408f
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/da06408f

Branch: refs/heads/sqoop2
Commit: da06408f2320ad09a7cbf0cfaa1fa9097c31c00d
Parents: 22f6ca5
Author: Hari Shreedharan <hshreedharan@apache.org>
Authored: Wed Aug 21 21:11:56 2013 -0700
Committer: Hari Shreedharan <hshreedharan@apache.org>
Committed: Wed Aug 21 21:11:56 2013 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/repository/Repository.java | 33 +++++++++++++-------
 .../sqoop/repository/TestJdbcRepository.java    | 23 +++++++++++++-
 2 files changed, 44 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/da06408f/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 7c7673f..a7ccf10 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -23,21 +23,16 @@ import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.connector.spi.MetadataUpgrader;
 import org.apache.sqoop.connector.spi.SqoopConnector;
 import org.apache.sqoop.framework.FrameworkManager;
-import org.apache.sqoop.model.MBooleanInput;
+import org.apache.sqoop.model.FormUtils;
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MConnectionForms;
 import org.apache.sqoop.model.MConnector;
-import org.apache.sqoop.model.MEnumInput;
 import org.apache.sqoop.model.MForm;
 import org.apache.sqoop.model.MFramework;
-import org.apache.sqoop.model.MInput;
-import org.apache.sqoop.model.MIntegerInput;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MJobForms;
-import org.apache.sqoop.model.MMapInput;
-import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.model.MSubmission;
-import org.apache.sqoop.model.ModelError;
+import org.apache.sqoop.utils.ClassUtils;
 import org.apache.sqoop.validation.Validation;
 import org.apache.sqoop.validation.Validator;
 
@@ -431,7 +426,11 @@ public abstract class Repository {
           newConnectionForms, connection.getFrameworkPart());
         newConnection.setPersistenceId(connectionID);
 
-        Validation validation = validator.validateConnection(newConnection);
+        // Transform form structures to objects for validations
+        Object newConfigurationObject = ClassUtils.instantiate(connector.getConnectionConfigurationClass());
+        FormUtils.fromForms(newConnection.getConnectorPart().getForms(), newConfigurationObject);
+
+        Validation validation = validator.validateConnection(newConfigurationObject);
         if (validation.getStatus().canProceed()) {
           updateConnection(newConnection, tx);
         } else {
@@ -449,7 +448,11 @@ public abstract class Repository {
           job.getType(), newJobForms, job.getFrameworkPart());
         newJob.setPersistenceId(job.getPersistenceId());
 
-        Validation validation = validator.validateJob(newJob.getType(), newJob);
+        // Transform form structures to objects for validations
+        Object newConfigurationObject = ClassUtils.instantiate(connector.getJobConfigurationClass(job.getType()));
+        FormUtils.fromForms(newJob.getConnectorPart().getForms(), newConfigurationObject);
+
+        Validation validation = validator.validateJob(newJob.getType(), newConfigurationObject);
         if (validation.getStatus().canProceed()) {
           updateJob(newJob, tx);
         } else {
@@ -530,7 +533,11 @@ public abstract class Repository {
           connection.getConnectorPart(), newConnectionForms);
         newConnection.setPersistenceId(connectionID);
 
-        Validation validation = validator.validateConnection(newConnection);
+        // Transform form structures to objects for validations
+        Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getConnectionConfigurationClass());
+        FormUtils.fromForms(newConnection.getFrameworkPart().getForms(), newConfigurationObject);
+
+        Validation validation = validator.validateConnection(newConfigurationObject);
         if (validation.getStatus().canProceed()) {
           updateConnection(newConnection, tx);
         } else {
@@ -548,7 +555,11 @@ public abstract class Repository {
           job.getType(), job.getConnectorPart(), newJobForms);
         newJob.setPersistenceId(job.getPersistenceId());
 
-        Validation validation = validator.validateJob(newJob.getType(), newJob);
+        // Transform form structures to objects for validations
+        Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getJobConfigurationClass(job.getType()));
+        FormUtils.fromForms(newJob.getFrameworkPart().getForms(), newConfigurationObject);
+
+        Validation validation = validator.validateJob(newJob.getType(), newConfigurationObject);
         if (validation.getStatus().canProceed()) {
           updateJob(newJob, tx);
         } else {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/da06408f/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 40a6eca..d557b87 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -29,6 +29,7 @@ import org.apache.sqoop.connector.spi.MetadataUpgrader;
 import org.apache.sqoop.connector.spi.SqoopConnector;
 import org.apache.sqoop.framework.FrameworkManager;
 import org.apache.sqoop.framework.configuration.ImportJobConfiguration;
+import org.apache.sqoop.model.ConfigurationClass;
 import org.apache.sqoop.model.FormUtils;
 import org.apache.sqoop.model.MConnection;
 import org.apache.sqoop.model.MConnectionForms;
@@ -201,6 +202,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
     when(sqconnector.getValidator()).thenReturn(validator);
     when(sqconnector.getMetadataUpgrader()).thenReturn(upgrader);
+    when(sqconnector.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(sqconnector.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
     when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
 
     // prepare the connections and jobs
@@ -258,6 +261,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(invalid);
     when(sqconnector.getValidator()).thenReturn(validator);
     when(sqconnector.getMetadataUpgrader()).thenReturn(upgrader);
+    when(sqconnector.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(sqconnector.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
     when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
@@ -316,6 +321,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
     when(frameworkMgr.getValidator()).thenReturn(validator);
     when(frameworkMgr.getMetadataUpgrader()).thenReturn(upgrader);
+    when(frameworkMgr.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(frameworkMgr.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
     List<MJob> jobList = jobs(job(1,1,1), job(2,1,2));
@@ -368,6 +375,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(invalid);
     when(frameworkMgr.getValidator()).thenReturn(validator);
     when(frameworkMgr.getMetadataUpgrader()).thenReturn(upgrader);
+    when(frameworkMgr.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(frameworkMgr.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
     List<MJob> jobList = jobs(job(1,1,1), job(2,1,2));
@@ -608,6 +617,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
     when(sqconnector.getValidator()).thenReturn(validator);
     when(sqconnector.getMetadataUpgrader()).thenReturn(upgrader);
+    when(sqconnector.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(sqconnector.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
     when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
@@ -655,6 +666,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
     when(sqconnector.getValidator()).thenReturn(validator);
     when(sqconnector.getMetadataUpgrader()).thenReturn(upgrader);
+    when(sqconnector.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(sqconnector.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
     when(connectorMgr.getConnector(anyString())).thenReturn(sqconnector);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
@@ -870,6 +883,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
     when(frameworkMgr.getValidator()).thenReturn(validator);
     when(frameworkMgr.getMetadataUpgrader()).thenReturn(upgrader);
+    when(frameworkMgr.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(frameworkMgr.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
     List<MJob> jobList = jobs(job(1,1,1), job(2,1,2));
@@ -914,6 +929,8 @@ public class TestJdbcRepository {
     when(validator.validateJob(any(MJob.Type.class), any(MJob.class))).thenReturn(valid);
     when(frameworkMgr.getValidator()).thenReturn(validator);
     when(frameworkMgr.getMetadataUpgrader()).thenReturn(upgrader);
+    when(frameworkMgr.getConnectionConfigurationClass()).thenReturn(EmptyConfigurationClass.class);
+    when(frameworkMgr.getJobConfigurationClass(any(MJob.Type.class))).thenReturn(ImportJobConfiguration.class);
 
     List<MConnection> connectionList = connections(connection(1,1), connection(2,1));
     List<MJob> jobList = jobs(job(1,1,1), job(2,1,2));
@@ -1006,4 +1023,8 @@ public class TestJdbcRepository {
     Collections.addAll(jobs, js);
     return jobs;
   }
-}
\ No newline at end of file
+
+  @ConfigurationClass
+  public static class EmptyConfigurationClass {
+  }
+}


Mime
View raw message