Review Board 1.7.22


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

Review Request #13722 - Created Aug. 22, 2013 and updated

Jarek Cecho
SQOOP-1180
Reviewers
Sqoop
sqoop-sqoop2
I've fixed the calls to create the configuration objects and convert the model classes prior calling the validator.
I've fixed the unit tests and verified the upgrade on real cluster.
core/src/main/java/org/apache/sqoop/repository/Repository.java
Revision 7c7673f7df76110e287ca0fbc8093f1f880b8cb5 New Change
[20] 20 lines
[+20]
21
import org.apache.sqoop.common.SqoopException;
21
import org.apache.sqoop.common.SqoopException;
22
import org.apache.sqoop.connector.ConnectorManager;
22
import org.apache.sqoop.connector.ConnectorManager;
23
import org.apache.sqoop.connector.spi.MetadataUpgrader;
23
import org.apache.sqoop.connector.spi.MetadataUpgrader;
24
import org.apache.sqoop.connector.spi.SqoopConnector;
24
import org.apache.sqoop.connector.spi.SqoopConnector;
25
import org.apache.sqoop.framework.FrameworkManager;
25
import org.apache.sqoop.framework.FrameworkManager;
26
import org.apache.sqoop.model.MBooleanInput;
26
import org.apache.sqoop.model.FormUtils;
27
import org.apache.sqoop.model.MConnection;
27
import org.apache.sqoop.model.MConnection;
28
import org.apache.sqoop.model.MConnectionForms;
28
import org.apache.sqoop.model.MConnectionForms;
29
import org.apache.sqoop.model.MConnector;
29
import org.apache.sqoop.model.MConnector;
30
import org.apache.sqoop.model.MEnumInput;

   
31
import org.apache.sqoop.model.MForm;
30
import org.apache.sqoop.model.MForm;
32
import org.apache.sqoop.model.MFramework;
31
import org.apache.sqoop.model.MFramework;
33
import org.apache.sqoop.model.MInput;

   
34
import org.apache.sqoop.model.MIntegerInput;

   
35
import org.apache.sqoop.model.MJob;
32
import org.apache.sqoop.model.MJob;
36
import org.apache.sqoop.model.MJobForms;
33
import org.apache.sqoop.model.MJobForms;
37
import org.apache.sqoop.model.MMapInput;

   
38
import org.apache.sqoop.model.MStringInput;

   
39
import org.apache.sqoop.model.MSubmission;
34
import org.apache.sqoop.model.MSubmission;
40
import org.apache.sqoop.model.ModelError;
35
import org.apache.sqoop.utils.ClassUtils;
41
import org.apache.sqoop.validation.Validation;
36
import org.apache.sqoop.validation.Validation;
42
import org.apache.sqoop.validation.Validator;
37
import org.apache.sqoop.validation.Validator;
43

    
   
38

   
44
import java.util.ArrayList;
39
import java.util.ArrayList;
45
import java.util.Date;
40
import java.util.Date;
[+20] [20] 383 lines
[+20] [+] public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
429
        upgrader.upgrade(connection.getConnectorPart(), newConnectionForms);
424
        upgrader.upgrade(connection.getConnectorPart(), newConnectionForms);
430
        MConnection newConnection = new MConnection(connectorID,
425
        MConnection newConnection = new MConnection(connectorID,
431
          newConnectionForms, connection.getFrameworkPart());
426
          newConnectionForms, connection.getFrameworkPart());
432
        newConnection.setPersistenceId(connectionID);
427
        newConnection.setPersistenceId(connectionID);
433

    
   
428

   
434
        Validation validation = validator.validateConnection(newConnection);
429
        // Transform form structures to objects for validations

    
   
430
        Object newConfigurationObject = ClassUtils.instantiate(connector.getConnectionConfigurationClass());

    
   
431
        FormUtils.fromForms(newConnection.getConnectorPart().getForms(), newConfigurationObject);

    
   
432

   

    
   
433
        Validation validation = validator.validateConnection(newConfigurationObject);
435
        if (validation.getStatus().canProceed()) {
434
        if (validation.getStatus().canProceed()) {
436
          updateConnection(newConnection, tx);
435
          updateConnection(newConnection, tx);
437
        } else {
436
        } else {
438
          invalidConnections.add(newConnection);
437
          invalidConnections.add(newConnection);
439
        }
438
        }
[+20] [20] 7 lines
[+20] public final void upgradeConnector(MConnector oldConnector, MConnector newConnector) {
447
        upgrader.upgrade(job.getConnectorPart(), newJobForms);
446
        upgrader.upgrade(job.getConnectorPart(), newJobForms);
448
        MJob newJob = new MJob(connectorID, job.getConnectionId(),
447
        MJob newJob = new MJob(connectorID, job.getConnectionId(),
449
          job.getType(), newJobForms, job.getFrameworkPart());
448
          job.getType(), newJobForms, job.getFrameworkPart());
450
        newJob.setPersistenceId(job.getPersistenceId());
449
        newJob.setPersistenceId(job.getPersistenceId());
451

    
   
450

   
452
        Validation validation = validator.validateJob(newJob.getType(), newJob);
451
        // Transform form structures to objects for validations

    
   
452
        Object newConfigurationObject = ClassUtils.instantiate(connector.getJobConfigurationClass(job.getType()));

    
   
453
        FormUtils.fromForms(newJob.getConnectorPart().getForms(), newConfigurationObject);

    
   
454

   

    
   
455
        Validation validation = validator.validateJob(newJob.getType(), newConfigurationObject);
453
        if (validation.getStatus().canProceed()) {
456
        if (validation.getStatus().canProceed()) {
454
          updateJob(newJob, tx);
457
          updateJob(newJob, tx);
455
        } else {
458
        } else {
456
          invalidJobs.add(newJob);
459
          invalidJobs.add(newJob);
457
        }
460
        }
[+20] [20] 70 lines
[+20] [+] public final void upgradeFramework(MFramework framework) {
528
        upgrader.upgrade(connection.getFrameworkPart(), newConnectionForms);
531
        upgrader.upgrade(connection.getFrameworkPart(), newConnectionForms);
529
        MConnection newConnection = new MConnection(connection.getConnectorId(),
532
        MConnection newConnection = new MConnection(connection.getConnectorId(),
530
          connection.getConnectorPart(), newConnectionForms);
533
          connection.getConnectorPart(), newConnectionForms);
531
        newConnection.setPersistenceId(connectionID);
534
        newConnection.setPersistenceId(connectionID);
532

    
   
535

   
533
        Validation validation = validator.validateConnection(newConnection);
536
        // Transform form structures to objects for validations

    
   
537
        Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getConnectionConfigurationClass());

    
   
538
        FormUtils.fromForms(newConnection.getFrameworkPart().getForms(), newConfigurationObject);

    
   
539

   

    
   
540
        Validation validation = validator.validateConnection(newConfigurationObject);
534
        if (validation.getStatus().canProceed()) {
541
        if (validation.getStatus().canProceed()) {
535
          updateConnection(newConnection, tx);
542
          updateConnection(newConnection, tx);
536
        } else {
543
        } else {
537
          invalidConnections.add(newConnection);
544
          invalidConnections.add(newConnection);
538
        }
545
        }
[+20] [20] 7 lines
[+20] public final void upgradeFramework(MFramework framework) {
546
        upgrader.upgrade(job.getFrameworkPart(), newJobForms);
553
        upgrader.upgrade(job.getFrameworkPart(), newJobForms);
547
        MJob newJob = new MJob(job.getConnectorId(), job.getConnectionId(),
554
        MJob newJob = new MJob(job.getConnectorId(), job.getConnectionId(),
548
          job.getType(), job.getConnectorPart(), newJobForms);
555
          job.getType(), job.getConnectorPart(), newJobForms);
549
        newJob.setPersistenceId(job.getPersistenceId());
556
        newJob.setPersistenceId(job.getPersistenceId());
550

    
   
557

   
551
        Validation validation = validator.validateJob(newJob.getType(), newJob);
558
        // Transform form structures to objects for validations

    
   
559
        Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getJobConfigurationClass(job.getType()));

    
   
560
        FormUtils.fromForms(newJob.getFrameworkPart().getForms(), newConfigurationObject);

    
   
561

   

    
   
562
        Validation validation = validator.validateJob(newJob.getType(), newConfigurationObject);
552
        if (validation.getStatus().canProceed()) {
563
        if (validation.getStatus().canProceed()) {
553
          updateJob(newJob, tx);
564
          updateJob(newJob, tx);
554
        } else {
565
        } else {
555
          invalidJobs.add(newJob);
566
          invalidJobs.add(newJob);
556
        }
567
        }
[+20] [20] 43 lines
core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
Revision 40a6ecad351682cf6a582dfa46f31b156195949a New Change
 
  1. core/src/main/java/org/apache/sqoop/repository/Repository.java: Loading...
  2. core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java: Loading...