mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 07:21:58 +08:00
'conf' directory added to classpath
bin/configure-sqoop now puts the 'conf' directory on the classpath. Users can override this by setting $SQOOP_CONF_DIR. Added src/perftest/ExtConnFactoryTest and ExtFactory, that demonstrates the configuration is being correctly read. From: Aaron Kimball <aaron@cloudera.com> git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1149921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ca0dec83e7
commit
359d424475
@ -58,6 +58,9 @@ if [ -d "$SQOOP_HOME/lib" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
SQOOP_CONF_DIR=${SQOOP_CONF_DIR:-${SQOOP_HOME}/conf}
|
||||
SQOOP_CLASSPATH=${SQOOP_CONF_DIR}:${SQOOP_CLASSPATH}
|
||||
|
||||
# If there's a build subdir, use Ivy-retrieved dependencies too.
|
||||
if [ -d "$SQOOP_HOME/build/ivy/lib/sqoop" ]; then
|
||||
for f in $SQOOP_HOME/build/ivy/lib/sqoop/*/*.jar; do
|
||||
|
92
src/perftest/ExtConnFactoryTest.java
Normal file
92
src/perftest/ExtConnFactoryTest.java
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Licensed to Cloudera, Inc. under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Cloudera, Inc. 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.
|
||||
*/
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.cloudera.sqoop.Sqoop;
|
||||
import com.cloudera.sqoop.SqoopOptions;
|
||||
import com.cloudera.sqoop.manager.ExportJobContext;
|
||||
import com.cloudera.sqoop.manager.ImportJobContext;
|
||||
import com.cloudera.sqoop.manager.SqlManager;
|
||||
import com.cloudera.sqoop.util.ExportException;
|
||||
import com.cloudera.sqoop.util.ImportException;
|
||||
|
||||
/**
|
||||
* Test external connection factory classes on the classpath.
|
||||
* This adds a connection factory that will accept all connect strings,
|
||||
* but then promptly throws an error message if you try to import or
|
||||
* export a table.
|
||||
*
|
||||
* You'll need to specify the sqoop.connection.factories property
|
||||
* (either in conf/sqoop-default.xml) or on the command line with -D;
|
||||
* this should include the 'ExtConnFactoryTest.ExtFactory' class.
|
||||
*
|
||||
* Run with: src/scripts/run-perftest.sh ExtConnFactoryTest \
|
||||
* (normal sqoop arguments)
|
||||
*/
|
||||
public final class ExtConnFactoryTest {
|
||||
private ExtConnFactoryTest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* A ConnManager that cannot satisfy any connection requests;
|
||||
* all operations fail with an error message.
|
||||
*/
|
||||
public static class FailingManager extends SqlManager {
|
||||
|
||||
public FailingManager(SqoopOptions options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
throw new SQLException("This manager cannot create a connection");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importTable(ImportJobContext context)
|
||||
throws ImportException {
|
||||
throw new ImportException("This manager cannot read tables.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResultSet execute(String stmt, Object... args)
|
||||
throws SQLException {
|
||||
throw new SQLException("This manager cannot execute SQL statements");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportTable(ExportJobContext context) throws ExportException {
|
||||
throw new ExportException("This manager cannot write tables.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the connection factory test.
|
||||
*/
|
||||
public static void main(String [] args) throws Exception {
|
||||
Sqoop.main(args);
|
||||
}
|
||||
}
|
42
src/perftest/ExtFactory.java
Normal file
42
src/perftest/ExtFactory.java
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Licensed to Cloudera, Inc. under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Cloudera, Inc. 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.
|
||||
*/
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.cloudera.sqoop.SqoopOptions;
|
||||
import com.cloudera.sqoop.manager.ConnManager;
|
||||
import com.cloudera.sqoop.manager.ManagerFactory;
|
||||
|
||||
/**
|
||||
* An external ConnFactory used by ExtConnFactoryTest.
|
||||
*/
|
||||
public class ExtFactory extends ManagerFactory {
|
||||
public static final Log LOG =
|
||||
LogFactory.getLog(ExtFactory.class.getName());
|
||||
|
||||
public ExtFactory() {
|
||||
LOG.info("Instantiating ExtFactory");
|
||||
}
|
||||
|
||||
public ConnManager accept(SqoopOptions options) {
|
||||
LOG.info("ExtFactory accepting manager for: "
|
||||
+ options.getConnectString());
|
||||
return new ExtConnFactoryTest.FailingManager(options);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user