Review Board 1.7.22


SQOOP-842 Sqoop2: Put partition to template in Extractor as well

Review Request #9068 - Created Jan. 23, 2013 and submitted

Jarek Cecho
SQOOP-842
Reviewers
Sqoop
sqoop-sqoop2
I've put the partition to template as proposed on jira.
Unit tests seems to be passing and I've also tried import on real cluster.
connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportExtractor.java
Revision f4389a3a39c41398fc6d30a0f8282321f3a8ed5c New Change
[20] 27 lines
[+20]
28
import org.apache.sqoop.connector.jdbc.configuration.ImportJobConfiguration;
28
import org.apache.sqoop.connector.jdbc.configuration.ImportJobConfiguration;
29
import org.apache.sqoop.job.etl.Partition;
29
import org.apache.sqoop.job.etl.Partition;
30
import org.apache.sqoop.job.etl.Extractor;
30
import org.apache.sqoop.job.etl.Extractor;
31
import org.apache.sqoop.job.io.DataWriter;
31
import org.apache.sqoop.job.io.DataWriter;
32

    
   
32

   
33
public class GenericJdbcImportExtractor extends Extractor<ConnectionConfiguration, ImportJobConfiguration> {
33
public class GenericJdbcImportExtractor extends Extractor<ConnectionConfiguration, ImportJobConfiguration, GenericJdbcImportPartition> {
34

    
   
34

   
35
 public static final Logger LOG = Logger.getLogger(GenericJdbcImportExtractor.class);
35
 public static final Logger LOG = Logger.getLogger(GenericJdbcImportExtractor.class);
36

    
   
36

   
37
 private long rowsRead = 0;
37
 private long rowsRead = 0;
38
  @Override
38
  @Override
39
  public void run(ImmutableContext context, ConnectionConfiguration connection, ImportJobConfiguration job, Partition partition, DataWriter writer) {
39
  public void run(ImmutableContext context, ConnectionConfiguration connection, ImportJobConfiguration job, GenericJdbcImportPartition partition, DataWriter writer) {
40
    String driver = connection.connection.jdbcDriver;
40
    String driver = connection.connection.jdbcDriver;
41
    String url = connection.connection.connectionString;
41
    String url = connection.connection.connectionString;
42
    String username = connection.connection.username;
42
    String username = connection.connection.username;
43
    String password = connection.connection.password;
43
    String password = connection.connection.password;
44
    GenericJdbcExecutor executor = new GenericJdbcExecutor(driver, url, username, password);
44
    GenericJdbcExecutor executor = new GenericJdbcExecutor(driver, url, username, password);
45

    
   
45

   
46
    String query = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL);
46
    String query = context.getString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL);
47
    String conditions = ((GenericJdbcImportPartition)partition).getConditions();
47
    String conditions = partition.getConditions();
48
    query = query.replace(GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN, conditions);
48
    query = query.replace(GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN, conditions);
49
    LOG.info("Using query: " + query);
49
    LOG.info("Using query: " + query);
50

    
   
50

   
51
    rowsRead = 0;
51
    rowsRead = 0;
52
    ResultSet resultSet = executor.executeQuery(query);
52
    ResultSet resultSet = executor.executeQuery(query);
[+20] [20] 27 lines
execution/mapreduce/src/main/java/org/apache/sqoop/job/etl/HdfsSequenceExportExtractor.java
Revision 3a04e59dcc3723e16fadf6cfced8c9134c253339 New Change
 
execution/mapreduce/src/main/java/org/apache/sqoop/job/etl/HdfsTextExportExtractor.java
Revision e00d4287eadf5c93ad9e44930efeea76221d7071 New Change
 
execution/mapreduce/src/test/java/org/apache/sqoop/job/TestHdfsLoad.java
Revision 4e6209d73475bcae078e03c222ffc0bcf6d87beb New Change
 
execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java
Revision 85900650051d1e6f90725f872968ad623df32636 New Change
 
spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java
Revision fac6f052bdf2a328839508d2f81a3dada3b0aeea New Change
 
  1. connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportExtractor.java: Loading...
  2. execution/mapreduce/src/main/java/org/apache/sqoop/job/etl/HdfsSequenceExportExtractor.java: Loading...
  3. execution/mapreduce/src/main/java/org/apache/sqoop/job/etl/HdfsTextExportExtractor.java: Loading...
  4. execution/mapreduce/src/test/java/org/apache/sqoop/job/TestHdfsLoad.java: Loading...
  5. execution/mapreduce/src/test/java/org/apache/sqoop/job/TestMapReduce.java: Loading...
  6. spi/src/main/java/org/apache/sqoop/job/etl/Extractor.java: Loading...