You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by bl...@apache.org on 2012/11/15 23:57:07 UTC
git commit: SQOOP-681 Split configuration in Generic connector (Jarek
Jarcec Cecho)
Updated Branches:
refs/heads/sqoop2 c39c7c9f1 -> ae23cb26d
SQOOP-681 Split configuration in Generic connector
(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/ae23cb26
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/ae23cb26
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/ae23cb26
Branch: refs/heads/sqoop2
Commit: ae23cb26dc82611dd7e1d52a33c6523331ac2ca2
Parents: c39c7c9
Author: Bilung Lee <bl...@apache.org>
Authored: Thu Nov 15 10:54:23 2012 -0800
Committer: Bilung Lee <bl...@apache.org>
Committed: Thu Nov 15 14:56:43 2012 -0800
----------------------------------------------------------------------
.../jdbc/GenericJdbcConnectorConstants.java | 32 ----------
.../jdbc/GenericJdbcExportInitializer.java | 38 ++----------
.../jdbc/GenericJdbcImportInitializer.java | 49 +++-----------
.../configuration/ConnectionConfiguration.java | 3 -
.../jdbc/configuration/ExportJobConfiguration.java | 6 ++-
.../jdbc/configuration/ExportTableForm.java | 31 +++++++++
.../jdbc/configuration/ImportJobConfiguration.java | 6 ++-
.../jdbc/configuration/ImportTableForm.java | 33 ++++++++++
.../connector/jdbc/configuration/TableForm.java | 35 ----------
.../connector/jdbc/TestExportInitializer.java | 35 ++++------
.../connector/jdbc/TestImportInitializer.java | 42 +++++--------
11 files changed, 122 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorConstants.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorConstants.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorConstants.java
index e991734..09056d3 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorConstants.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcConnectorConstants.java
@@ -26,32 +26,6 @@ public final class GenericJdbcConnectorConstants {
public static final String RESOURCE_BUNDLE_NAME =
"generic-jdbc-connector-resources";
- // Metadata constants
-
- // Connection form
- public static final String FORM_CONNECTION = "form-connection";
-
- // Connection form inputs
- public static final String INPUT_CONN_JDBCDRIVER = "inp-conn-jdbcdriver";
- public static final String INPUT_CONN_CONNECTSTRING =
- "inp-conn-connectstring";
- public static final String INPUT_CONN_USERNAME = "inp-conn-username";
- public static final String INPUT_CONN_PASSWORD = "inp-conn-password";
- public static final String INPUT_CONN_JDBCPROPS = "inp-conn-jdbc-properties";
-
- // Table form
- public static final String FORM_TABLE = "form-table";
-
- // Table form inputs
- public static final String INPUT_TBL_NAME = "inp-tbl-name";
- public static final String INPUT_TBL_SQL = "inp-tbl-sql";
- public static final String INPUT_TBL_COLUMNS = "inp-tbl-columns";
- public static final String INPUT_TBL_WAREHOUSE = "inp-tbl-warehouse";
- public static final String INPUT_TBL_DATADIR = "inp-tbl-datadir";
- public static final String INPUT_TBL_PCOL = "inp-tbl-pcol";
- public static final String INPUT_TBL_BOUNDARY = "inp-tbl-boundary";
-
-
/*
* All jdbc connector related configuration is prefixed with this:
* <tt>org.apache.sqoop.jdbc.</tt>
@@ -80,12 +54,6 @@ public final class GenericJdbcConnectorConstants {
public static final String CONNECTOR_JDBC_DATA_SQL =
PREFIX_CONNECTOR_JDBC_CONFIG + "data.sql";
- public static final String FILE_SEPARATOR = System.getProperty("file.separator");
-
- public static final String DEFAULT_WAREHOUSE = "/tmp/sqoop/warehouse/";
-
- public static final String DEFAULT_DATADIR = "DataStore";
-
public static final String SQL_CONDITIONS_TOKEN = "${CONDITIONS}";
public static final String SQL_PARAMETER_MARKER = "?";
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExportInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExportInitializer.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExportInitializer.java
index 9199e75..b56ca10 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExportInitializer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcExportInitializer.java
@@ -67,7 +67,7 @@ public class GenericJdbcExportInitializer extends Initializer {
if (driver == null) {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0012,
- GenericJdbcConnectorConstants.INPUT_CONN_JDBCDRIVER);
+ "JDBC Driver");
}
context.setString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_DRIVER,
@@ -76,7 +76,7 @@ public class GenericJdbcExportInitializer extends Initializer {
if (url == null) {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0012,
- GenericJdbcConnectorConstants.INPUT_CONN_CONNECTSTRING);
+ "Connection string");
}
context.setString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_URL,
@@ -99,19 +99,10 @@ public class GenericJdbcExportInitializer extends Initializer {
private void configureTableProperties(MutableContext context, ConnectionConfiguration connectionConfig, ExportJobConfiguration jobConfig) {
String dataSql;
- String inputDirectory;
-
- String tableName = connectionConfig.table.tableName;
- String tableSql = connectionConfig.table.sql;
- String tableColumns = connectionConfig.table.columns;
-
- String datadir = connectionConfig.table.dataDirectory;
- String warehouse = connectionConfig.table.warehouse;
- if (warehouse == null) {
- warehouse = GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE;
- } else if (!warehouse.endsWith(GenericJdbcConnectorConstants.FILE_SEPARATOR)) {
- warehouse += GenericJdbcConnectorConstants.FILE_SEPARATOR;
- }
+
+ String tableName = jobConfig.table.tableName;
+ String tableSql = jobConfig.table.sql;
+ String tableColumns = jobConfig.table.columns;
if (tableName != null && tableSql != null) {
// when both table name and table sql are specified:
@@ -148,13 +139,6 @@ public class GenericJdbcExportInitializer extends Initializer {
builder.append(")");
dataSql = builder.toString();
}
-
- if (datadir == null) {
- inputDirectory = warehouse + tableName;
- } else {
- inputDirectory = warehouse + datadir;
- }
-
} else if (tableSql != null) {
// when table sql is specified:
@@ -171,14 +155,6 @@ public class GenericJdbcExportInitializer extends Initializer {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0014);
}
-
- if (datadir == null) {
- inputDirectory =
- warehouse + GenericJdbcConnectorConstants.DEFAULT_DATADIR;
- } else {
- inputDirectory = warehouse + datadir;
- }
-
} else {
// when neither are specified:
throw new SqoopException(
@@ -187,7 +163,5 @@ public class GenericJdbcExportInitializer extends Initializer {
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL,
dataSql.toString());
- context.setString(Constants.JOB_ETL_INPUT_DIRECTORY, inputDirectory);
}
-
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportInitializer.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportInitializer.java
index 39f19f5..3ce6bb9 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportInitializer.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcImportInitializer.java
@@ -77,7 +77,7 @@ public class GenericJdbcImportInitializer extends Initializer {
if (driver == null) {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0012,
- GenericJdbcConnectorConstants.INPUT_CONN_JDBCDRIVER);
+ "JDBC Driver");
}
context.setString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_DRIVER,
@@ -86,7 +86,7 @@ public class GenericJdbcImportInitializer extends Initializer {
if (url == null) {
throw new SqoopException(
GenericJdbcConnectorError.GENERIC_JDBC_CONNECTOR_0012,
- GenericJdbcConnectorConstants.INPUT_CONN_CONNECTSTRING);
+ "Connection string");
}
context.setString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_URL,
@@ -110,12 +110,12 @@ public class GenericJdbcImportInitializer extends Initializer {
private void configurePartitionProperties(MutableContext context, ConnectionConfiguration connectionConfig, ImportJobConfiguration jobConfig) {
// ----- configure column name -----
- String partitionColumnName = connectionConfig.table.partitionColumn;
+ String partitionColumnName = jobConfig.table.partitionColumn;
if (partitionColumnName == null) {
// if column is not specified by the user,
// find the primary key of the table (when there is a table).
- String tableName = connectionConfig.table.tableName;
+ String tableName = jobConfig.table.tableName;
if (tableName != null) {
partitionColumnName = executor.getPrimaryKey(tableName);
}
@@ -133,13 +133,13 @@ public class GenericJdbcImportInitializer extends Initializer {
// ----- configure column type, min value, and max value -----
- String minMaxQuery = connectionConfig.table.boundaryQuery;
+ String minMaxQuery = jobConfig.table.boundaryQuery;
if (minMaxQuery == null) {
StringBuilder builder = new StringBuilder();
- String tableName = connectionConfig.table.tableName;
- String tableSql = connectionConfig.table.sql;
+ String tableName = jobConfig.table.tableName;
+ String tableSql = jobConfig.table.sql;
if (tableName != null && tableSql != null) {
// when both table name and table sql are specified:
@@ -210,20 +210,10 @@ public class GenericJdbcImportInitializer extends Initializer {
private void configureTableProperties(MutableContext context, ConnectionConfiguration connectionConfig, ImportJobConfiguration jobConfig) {
String dataSql;
String fieldNames;
- String outputDirectory;
-
- String tableName = connectionConfig.table.tableName;
- String tableSql = connectionConfig.table.sql;
- String tableColumns = connectionConfig.table.columns;
-
- //TODO(jarcec): Why is connector concerned with data directory? It should not need it at all!
- String datadir = connectionConfig.table.dataDirectory;
- String warehouse = connectionConfig.table.warehouse;
- if (warehouse == null) {
- warehouse = GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE;
- } else if (!warehouse.endsWith(GenericJdbcConnectorConstants.FILE_SEPARATOR)) {
- warehouse += GenericJdbcConnectorConstants.FILE_SEPARATOR;
- }
+
+ String tableName = jobConfig.table.tableName;
+ String tableSql = jobConfig.table.sql;
+ String tableColumns = jobConfig.table.columns;
if (tableName != null && tableSql != null) {
// when both table name and table sql are specified:
@@ -257,13 +247,6 @@ public class GenericJdbcImportInitializer extends Initializer {
fieldNames = tableColumns;
}
-
- if (datadir == null) {
- outputDirectory = warehouse + tableName;
- } else {
- outputDirectory = warehouse + datadir;
- }
-
} else if (tableSql != null) {
// when table sql is specified:
@@ -301,14 +284,6 @@ public class GenericJdbcImportInitializer extends Initializer {
fieldNames = tableColumns;
}
-
- if (datadir == null) {
- outputDirectory =
- warehouse + GenericJdbcConnectorConstants.DEFAULT_DATADIR;
- } else {
- outputDirectory = warehouse + datadir;
- }
-
} else {
// when neither are specified:
throw new SqoopException(
@@ -318,7 +293,5 @@ public class GenericJdbcImportInitializer extends Initializer {
context.setString(GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL,
dataSql.toString());
context.setString(Constants.JOB_ETL_FIELD_NAMES, fieldNames);
- context.setString(Constants.JOB_ETL_OUTPUT_DIRECTORY, outputDirectory);
}
-
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionConfiguration.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionConfiguration.java
index 5057cf5..6061600 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionConfiguration.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ConnectionConfiguration.java
@@ -28,10 +28,7 @@ public class ConnectionConfiguration {
@Form public ConnectionForm connection;
- @Form public TableForm table;
-
public ConnectionConfiguration() {
connection = new ConnectionForm();
- table = new TableForm();
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportJobConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportJobConfiguration.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportJobConfiguration.java
index c32b066..f2b2d65 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportJobConfiguration.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportJobConfiguration.java
@@ -25,5 +25,9 @@ import org.apache.sqoop.model.Form;
*/
@ConfigurationClass
public class ExportJobConfiguration {
- @Form IgnoredForm ignored;
+ @Form public ExportTableForm table;
+
+ public ExportJobConfiguration() {
+ table = new ExportTableForm();
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportTableForm.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportTableForm.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportTableForm.java
new file mode 100644
index 0000000..718d1fb
--- /dev/null
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ExportTableForm.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.connector.jdbc.configuration;
+
+import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.Input;
+
+/**
+ *
+ */
+@FormClass
+public class ExportTableForm {
+ @Input(size = 50) public String tableName;
+ @Input(size = 50) public String sql;
+ @Input(size = 50) public String columns;
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportJobConfiguration.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportJobConfiguration.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportJobConfiguration.java
index 11b1c5f..f3c1d13 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportJobConfiguration.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportJobConfiguration.java
@@ -25,5 +25,9 @@ import org.apache.sqoop.model.Form;
*/
@ConfigurationClass
public class ImportJobConfiguration {
- @Form IgnoredForm ignored;
+ @Form public ImportTableForm table;
+
+ public ImportJobConfiguration() {
+ table = new ImportTableForm();
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportTableForm.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportTableForm.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportTableForm.java
new file mode 100644
index 0000000..d150779
--- /dev/null
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/ImportTableForm.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.connector.jdbc.configuration;
+
+import org.apache.sqoop.model.FormClass;
+import org.apache.sqoop.model.Input;
+
+/**
+ *
+ */
+@FormClass
+public class ImportTableForm {
+ @Input(size = 50) public String tableName;
+ @Input(size = 50) public String sql;
+ @Input(size = 50) public String columns;
+ @Input(size = 50) public String partitionColumn;
+ @Input(size = 50) public String boundaryQuery;
+}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/TableForm.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/TableForm.java b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/TableForm.java
deleted file mode 100644
index 9eb6a01..0000000
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/TableForm.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sqoop.connector.jdbc.configuration;
-
-import org.apache.sqoop.model.FormClass;
-import org.apache.sqoop.model.Input;
-
-/**
- *
- */
-@FormClass
-public class TableForm {
- @Input(size = 50) public String tableName;
- @Input(size = 50) public String sql;
- @Input(size = 50) public String columns;
- @Input(size = 50) public String warehouse;
- @Input(size = 50) public String dataDirectory;
- @Input(size = 50) public String partitionColumn;
- @Input(size = 50) public String boundaryQuery;
-}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExportInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExportInitializer.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExportInitializer.java
index 8dbfb4b..c876780 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExportInitializer.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestExportInitializer.java
@@ -59,11 +59,11 @@ public class TestExportInitializer extends TestCase {
public void testTableName() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ExportJobConfiguration jobConf = new ExportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.tableName = tableName;
-
- ExportJobConfiguration jobConf = new ExportJobConfiguration();
+ jobConf.table.tableName = tableName;
MutableContext context = new MutableMapContext();
@@ -72,18 +72,17 @@ public class TestExportInitializer extends TestCase {
verifyResult(context,
"INSERT INTO " + executor.delimitIdentifier(tableName)
- + " VALUES (?,?,?)",
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE + tableName);
+ + " VALUES (?,?,?)");
}
public void testTableNameWithTableColumns() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ExportJobConfiguration jobConf = new ExportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.tableName = tableName;
- connConf.table.columns = tableColumns;
-
- ExportJobConfiguration jobConf = new ExportJobConfiguration();
+ jobConf.table.tableName = tableName;
+ jobConf.table.columns = tableColumns;
MutableContext context = new MutableMapContext();
@@ -92,17 +91,16 @@ public class TestExportInitializer extends TestCase {
verifyResult(context,
"INSERT INTO " + executor.delimitIdentifier(tableName)
- + " (" + tableColumns + ") VALUES (?,?)",
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE + tableName);
+ + " (" + tableColumns + ") VALUES (?,?)");
}
public void testTableSql() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ExportJobConfiguration jobConf = new ExportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.sql = tableSql;
-
- ExportJobConfiguration jobConf = new ExportJobConfiguration();
+ jobConf.table.sql = tableSql;
MutableContext context = new MutableMapContext();
@@ -111,16 +109,11 @@ public class TestExportInitializer extends TestCase {
verifyResult(context,
"INSERT INTO " + executor.delimitIdentifier(tableName)
- + " VALUES (?,?,?)",
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE
- + GenericJdbcConnectorConstants.DEFAULT_DATADIR);
+ + " VALUES (?,?,?)");
}
- private void verifyResult(MutableContext context,
- String dataSql, String inputDirectory) {
+ private void verifyResult(MutableContext context, String dataSql) {
assertEquals(dataSql, context.getString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL));
- assertEquals(inputDirectory, context.getString(
- Constants.JOB_ETL_INPUT_DIRECTORY));
}
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/ae23cb26/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestImportInitializer.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestImportInitializer.java b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestImportInitializer.java
index 0c7be4b..f3c1d90 100644
--- a/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestImportInitializer.java
+++ b/connector/connector-generic-jdbc/src/test/java/org/apache/sqoop/connector/jdbc/TestImportInitializer.java
@@ -71,11 +71,11 @@ public class TestImportInitializer extends TestCase {
public void testTableName() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ImportJobConfiguration jobConf = new ImportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.tableName = tableName;
-
- ImportJobConfiguration jobConf = new ImportJobConfiguration();
+ jobConf.table.tableName = tableName;
MutableContext context = new MutableMapContext();
@@ -86,7 +86,6 @@ public class TestImportInitializer extends TestCase {
"SELECT * FROM " + executor.delimitIdentifier(tableName)
+ " WHERE ${CONDITIONS}",
"ICOL,DCOL,VCOL",
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE + tableName,
"ICOL",
String.valueOf(Types.INTEGER),
String.valueOf(START),
@@ -95,12 +94,12 @@ public class TestImportInitializer extends TestCase {
public void testTableNameWithTableColumns() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ImportJobConfiguration jobConf = new ImportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.tableName = tableName;
- connConf.table.columns = tableColumns;
-
- ImportJobConfiguration jobConf = new ImportJobConfiguration();
+ jobConf.table.tableName = tableName;
+ jobConf.table.columns = tableColumns;
MutableContext context = new MutableMapContext();
@@ -111,7 +110,6 @@ public class TestImportInitializer extends TestCase {
"SELECT ICOL,VCOL FROM " + executor.delimitIdentifier(tableName)
+ " WHERE ${CONDITIONS}",
tableColumns,
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE + tableName,
"ICOL",
String.valueOf(Types.INTEGER),
String.valueOf(START),
@@ -120,12 +118,12 @@ public class TestImportInitializer extends TestCase {
public void testTableSql() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ImportJobConfiguration jobConf = new ImportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.sql = tableSql;
- connConf.table.partitionColumn = "DCOL";
-
- ImportJobConfiguration jobConf = new ImportJobConfiguration();
+ jobConf.table.sql = tableSql;
+ jobConf.table.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
@@ -136,8 +134,6 @@ public class TestImportInitializer extends TestCase {
"SELECT * FROM " + executor.delimitIdentifier(tableName)
+ " WHERE ${CONDITIONS}",
"ICOL,DCOL,VCOL",
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE
- + GenericJdbcConnectorConstants.DEFAULT_DATADIR,
"DCOL",
String.valueOf(Types.DOUBLE),
String.valueOf((double)START),
@@ -146,13 +142,13 @@ public class TestImportInitializer extends TestCase {
public void testTableSqlWithTableColumns() throws Exception {
ConnectionConfiguration connConf = new ConnectionConfiguration();
+ ImportJobConfiguration jobConf = new ImportJobConfiguration();
+
connConf.connection.jdbcDriver = GenericJdbcTestConstants.DRIVER;
connConf.connection.connectionString = GenericJdbcTestConstants.URL;
- connConf.table.sql = tableSql;
- connConf.table.columns = tableColumns;
- connConf.table.partitionColumn = "DCOL";
-
- ImportJobConfiguration jobConf = new ImportJobConfiguration();
+ jobConf.table.sql = tableSql;
+ jobConf.table.columns = tableColumns;
+ jobConf.table.partitionColumn = "DCOL";
MutableContext context = new MutableMapContext();
@@ -164,8 +160,6 @@ public class TestImportInitializer extends TestCase {
+ "(SELECT * FROM " + executor.delimitIdentifier(tableName)
+ " WHERE ${CONDITIONS}) SQOOP_SUBQUERY_ALIAS",
tableColumns,
- GenericJdbcConnectorConstants.DEFAULT_WAREHOUSE
- + GenericJdbcConnectorConstants.DEFAULT_DATADIR,
"DCOL",
String.valueOf(Types.DOUBLE),
String.valueOf((double)START),
@@ -173,15 +167,13 @@ public class TestImportInitializer extends TestCase {
}
private void verifyResult(MutableContext context,
- String dataSql, String fieldNames, String outputDirectory,
+ String dataSql, String fieldNames,
String partitionColumnName, String partitionColumnType,
String partitionMinValue, String partitionMaxValue) {
assertEquals(dataSql, context.getString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_DATA_SQL));
assertEquals(fieldNames, context.getString(
Constants.JOB_ETL_FIELD_NAMES));
- assertEquals(outputDirectory, context.getString(
- Constants.JOB_ETL_OUTPUT_DIRECTORY));
assertEquals(partitionColumnName, context.getString(
GenericJdbcConnectorConstants.CONNECTOR_JDBC_PARTITION_COLUMNNAME));