本文整理汇总了Java中com.cloudera.sqoop.ConnFactory类的典型用法代码示例。如果您正苦于以下问题:Java ConnFactory类的具体用法?Java ConnFactory怎么用?Java ConnFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnFactory类属于com.cloudera.sqoop包,在下文中一共展示了ConnFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
/**
* Should be called at the beginning of the run() method to initialize
* the connection manager, etc. If this succeeds (returns true), it should
* be paired with a call to destroy().
* @return true on success, false on failure.
*/
protected boolean init(SqoopOptions sqoopOpts) {
// Get the connection to the database.
try {
JobData data = new JobData(sqoopOpts, this);
this.manager = new ConnFactory(sqoopOpts.getConf()).getManager(data);
return true;
} catch (Exception e) {
LOG.error("Got error creating database manager: "
+ StringUtils.stringifyException(e));
if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
throw new RuntimeException(e);
}
}
return false;
}
示例2: setUp
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
@Before
public void setUp() {
Configuration conf = getConf();
opts = getSqoopOptions(conf);
opts.setConnectString("dummy.server");
opts.setTableName("dummy.pds");
opts.setConnManagerClassName("org.apache.sqoop.manager.MainframeManager");
context = new ImportJobContext(getTableName(), null, opts, null);
ConnFactory f = new ConnFactory(conf);
try {
this.manager = f.getManager(new JobData(opts, new MainframeImportTool()));
} catch (IOException ioe) {
fail("IOException instantiating manager: "
+ StringUtils.stringifyException(ioe));
}
}
示例3: setUp
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
@Before
public void setUp() {
super.setUp();
SqoopOptions options = new SqoopOptions(CONNECT_STRING,
DBO_TABLE_NAME);
options.setUsername(DATABASE_USER);
options.setPassword(DATABASE_PASSWORD);
manager = new SQLServerManager(options);
createTableAndPopulateData(SCHEMA_DBO, DBO_TABLE_NAME);
createTableAndPopulateData(SCHEMA_SCH, SCH_TABLE_NAME);
// To test with Microsoft SQL server connector, copy the connector jar to
// sqoop.thirdparty.lib.dir and set sqoop.test.msserver.connector.factory
// to com.microsoft.sqoop.SqlServer.MSSQLServerManagerFactory. By default,
// the built-in SQL server connector is used.
conf.setStrings(ConnFactory.FACTORY_CLASS_NAMES_KEY, CONNECTOR_FACTORY);
}
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:21,代码来源:SQLServerManagerExportManualTest.java
示例4: setUp
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
@Before
public void setUp() {
MSSQLTestUtils utils = new MSSQLTestUtils();
try {
utils.createTableFromSQL(MSSQLTestUtils.CREATE_TALBE_LINEITEM);
utils.populateLineItem();
} catch (SQLException e) {
LOG.error("Setup fail with SQLException: " + StringUtils.stringifyException(e));
fail("Setup fail with SQLException: " + e.toString());
}
Configuration conf = getConf();
SqoopOptions opts = getSqoopOptions(conf);
String username = MSSQLTestUtils.getDBUserName();
String password = MSSQLTestUtils.getDBPassWord();
opts.setUsername(username);
opts.setPassword(password);
opts.setConnectString(getConnectString());
ConnFactory f = new ConnFactory(conf);
try {
this.manager = f.getManager(new JobData(opts, new ImportTool()));
System.out.println("Manger : " + this.manager);
} catch (IOException ioe) {
LOG.error("Setup fail with IOException: " + StringUtils.stringifyException(ioe));
fail("IOException instantiating manager: "
+ StringUtils.stringifyException(ioe));
}
}
示例5: testFailedImportDueToJobFail
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
public void testFailedImportDueToJobFail() throws IOException {
// Test that if the job returns 'false' it still fails and informs
// the user.
// Create a table to attempt to import.
createTableForColType("VARCHAR(32)", "'meep2'");
Configuration conf = new Configuration();
// Use the dependency-injection manager.
conf.setClass(ConnFactory.FACTORY_CLASS_NAMES_KEY,
InjectableManagerFactory.class, ManagerFactory.class);
String[] argv = getArgv(true, new String[] { "DATA_COL0" }, conf);
// Use dependency injection to specify a mapper that we know
// will fail.
conf.setClass(InjectableConnManager.MAPPER_KEY,
NullDereferenceMapper.class, Mapper.class);
conf.setClass(InjectableConnManager.IMPORT_JOB_KEY, DummyImportJob.class,
ImportJobBase.class);
Sqoop importer = new Sqoop(new ImportTool(), conf);
try {
int ret = Sqoop.runSqoop(importer, argv);
assertTrue("Expected ImportException running this job.", 1==ret);
} catch (Exception e) {
// In debug mode, ImportException is wrapped in RuntimeException.
LOG.info("Got exceptional return (expected: ok). msg is: " + e);
}
}
示例6: init
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
/**
* Should be called at the beginning of the run() method to initialize
* the connection manager, etc. If this succeeds (returns true), it should
* be paired with a call to destroy().
* @return true on success, false on failure.
*/
protected boolean init(SqoopOptions sqoopOpts) {
// Get the connection to the database.
try {
String connectString = sqoopOpts.getConnectString();
if( connectString.contains("infinidb") ) {
sqoopOpts.setInfiniDBMode(true);
connectString = connectString.replace("infinidb", "mysql");
LOG.info("Found an InfiniDB connect string, using a mysql connection "+
"string for compatibility");
// set InfiniDB delimiter set
LOG.info("Using InfiniDB-specific delimiters for output if not explicitly specified");
sqoopOpts.setOutputDelimiters(DelimiterSet.INFINIDB_DELIMITERS);
}
sqoopOpts.setConnectString(connectString);
JobData data = new JobData(sqoopOpts, this);
this.manager = new ConnFactory(sqoopOpts.getConf()).getManager(data);
return true;
} catch (Exception e) {
LOG.error("Got error creating database manager: "
+ StringUtils.stringifyException(e));
if (System.getProperty(Sqoop.SQOOP_RETHROW_PROPERTY) != null) {
throw new RuntimeException(e);
}
}
return false;
}
示例7: setUp
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
@Before
public void setUp() {
// The assumption is that correct HADOOP configuration will have it set to
// hdfs://namenode
setOnPhysicalCluster(
!CommonArgs.LOCAL_FS.equals(System.getProperty(
CommonArgs.FS_DEFAULT_NAME)));
incrementTableNum();
if (!isLog4jConfigured) {
BasicConfigurator.configure();
isLog4jConfigured = true;
LOG.info("Configured log4j with console appender.");
}
if (useHsqldbTestServer()) {
testServer = new HsqldbTestServer();
try {
testServer.resetServer();
} catch (SQLException sqlE) {
LOG.error("Got SQLException: " + StringUtils.stringifyException(sqlE));
fail("Got SQLException: " + StringUtils.stringifyException(sqlE));
} catch (ClassNotFoundException cnfe) {
LOG.error("Could not find class for db driver: "
+ StringUtils.stringifyException(cnfe));
fail("Could not find class for db driver: "
+ StringUtils.stringifyException(cnfe));
}
manager = testServer.getManager();
} else {
Configuration conf = getConf();
//Need to disable OraOop for existing tests
conf.set("oraoop.disabled", "true");
SqoopOptions opts = getSqoopOptions(conf);
opts.setConnectString(getConnectString());
opts.setTableName(getTableName());
ConnFactory f = new ConnFactory(conf);
try {
this.manager = f.getManager(new JobData(opts, new ImportTool()));
} catch (IOException ioe) {
fail("IOException instantiating manager: "
+ StringUtils.stringifyException(ioe));
}
}
}
示例8: setUp
import com.cloudera.sqoop.ConnFactory; //导入依赖的package包/类
@Before
public void setUp() {
// The assumption is that correct HADOOP configuration will have it set to
// hdfs://namenode
setOnPhysicalCluster(
!CommonArgs.LOCAL_FS.equals(System.getProperty(
CommonArgs.FS_DEFAULT_NAME)));
incrementTableNum();
if (!isLog4jConfigured) {
BasicConfigurator.configure();
isLog4jConfigured = true;
LOG.info("Configured log4j with console appender.");
}
if (useHsqldbTestServer()) {
testServer = new HsqldbTestServer();
try {
testServer.resetServer();
} catch (SQLException sqlE) {
LOG.error("Got SQLException: " + StringUtils.stringifyException(sqlE));
fail("Got SQLException: " + StringUtils.stringifyException(sqlE));
} catch (ClassNotFoundException cnfe) {
LOG.error("Could not find class for db driver: "
+ StringUtils.stringifyException(cnfe));
fail("Could not find class for db driver: "
+ StringUtils.stringifyException(cnfe));
}
manager = testServer.getManager();
} else {
Configuration conf = getConf();
SqoopOptions opts = getSqoopOptions(conf);
opts.setConnectString(getConnectString());
opts.setTableName(getTableName());
ConnFactory f = new ConnFactory(conf);
try {
this.manager = f.getManager(new JobData(opts, new ImportTool()));
} catch (IOException ioe) {
fail("IOException instantiating manager: "
+ StringUtils.stringifyException(ioe));
}
}
}