当前位置: 首页>>代码示例>>Java>>正文


Java ImportTool.parseArguments方法代码示例

本文整理汇总了Java中com.cloudera.sqoop.tool.ImportTool.parseArguments方法的典型用法代码示例。如果您正苦于以下问题:Java ImportTool.parseArguments方法的具体用法?Java ImportTool.parseArguments怎么用?Java ImportTool.parseArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloudera.sqoop.tool.ImportTool的用法示例。


在下文中一共展示了ImportTool.parseArguments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateImportOptions

import com.cloudera.sqoop.tool.ImportTool; //导入方法依赖的package包/类
private void validateImportOptions(String[] extraArgs) throws Exception {
  String [] args = {
    "--connect", HsqldbTestServer.getUrl(),
    "--table", "test",
    "-m", "1",
  };
  ImportTool importTool = new ImportTool();
  SqoopOptions opts = importTool.parseArguments(
      (String []) ArrayUtils.addAll(args, extraArgs), null, null, false);
  importTool.validateOptions(opts);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:12,代码来源:TestSqoopOptions.java

示例2: runMultiMapTest

import com.cloudera.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void runMultiMapTest(String splitByCol, int expectedSum)
    throws IOException {

  String[] columns = MSSQLTestUtils.getColumns();
  ClassLoader prevClassLoader = null;
  SequenceFile.Reader reader = null;

  String[] argv = getArgv(true, columns, splitByCol);
  runImport(argv);
  try {
    ImportTool importTool = new ImportTool();
    SqoopOptions opts = importTool.parseArguments(getArgv(false,
        columns, splitByCol), null, null, true);
    String username = MSSQLTestUtils.getDBUserName();
    String password = MSSQLTestUtils.getDBPassWord();
    opts.setUsername(username);
    opts.setPassword(password);

    CompilationManager compileMgr = new CompilationManager(opts);
    String jarFileName = compileMgr.getJarFilename();

    prevClassLoader = ClassLoaderStack.addJarFile(jarFileName,
        getTableName());

    List<Path> paths = getDataFilePaths();
    Configuration conf = new Configuration();
    int curSum = 0;

    // We expect multiple files. We need to open all the files and sum
    // up the
    // first column across all of them.
    for (Path p : paths) {
      reader = SeqFileReader.getSeqFileReader(p.toString());

      // here we can actually instantiate (k, v) pairs.
      Object key = ReflectionUtils.newInstance(reader.getKeyClass(),
          conf);
      Object val = ReflectionUtils.newInstance(
          reader.getValueClass(), conf);

      // We know that these values are two ints separated by a ','
      // character. Since this is all dynamic, though, we don't want
      // to
      // actually link against the class and use its methods. So we
      // just
      // parse this back into int fields manually. Sum them up and
      // ensure
      // that we get the expected total for the first column, to
      // verify that
      // we got all the results from the db into the file.

      // now sum up everything in the file.
      while (reader.next(key) != null) {
        reader.getCurrentValue(val);
        curSum += getFirstInt(val.toString());
      }

      IOUtils.closeStream(reader);
      reader = null;
    }

    assertEquals("Total sum of first db column mismatch", expectedSum,
        curSum);
  } catch (InvalidOptionsException ioe) {
    LOG.error(StringUtils.stringifyException(ioe));
    fail(ioe.toString());
  } catch (ParseException pe) {
    LOG.error(StringUtils.stringifyException(pe));
    fail(pe.toString());
  } finally {
    IOUtils.closeStream(reader);

    if (null != prevClassLoader) {
      ClassLoaderStack.setCurrentClassLoader(prevClassLoader);
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:78,代码来源:SQLServerMultiMapsManualTest.java

示例3: parse

import com.cloudera.sqoop.tool.ImportTool; //导入方法依赖的package包/类
private SqoopOptions parse(String [] argv) throws Exception {
  ImportTool importTool = new ImportTool();
  return importTool.parseArguments(argv, null, null, false);
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:5,代码来源:TestSqoopOptions.java

示例4: runMultiMapTest

import com.cloudera.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void runMultiMapTest(String splitByCol, int expectedSum)
    throws IOException {

  String [] columns = HsqldbTestServer.getFieldNames();
  ClassLoader prevClassLoader = null;
  SequenceFile.Reader reader = null;

  String [] argv = getArgv(true, columns, splitByCol);
  runImport(argv);
  try {
    ImportTool importTool = new ImportTool();
    SqoopOptions opts = importTool.parseArguments(
        getArgv(false, columns, splitByCol),
        null, null, true);

    CompilationManager compileMgr = new CompilationManager(opts);
    String jarFileName = compileMgr.getJarFilename();

    prevClassLoader = ClassLoaderStack.addJarFile(jarFileName,
        getTableName());

    List<Path> paths = getDataFilePaths();
    Configuration conf = new Configuration();
    int curSum = 0;

    // We expect multiple files. We need to open all the files and sum up the
    // first column across all of them.
    for (Path p : paths) {
      reader = SeqFileReader.getSeqFileReader(p.toString());

      // here we can actually instantiate (k, v) pairs.
      Object key = ReflectionUtils.newInstance(reader.getKeyClass(), conf);
      Object val = ReflectionUtils.newInstance(reader.getValueClass(), conf);

      // We know that these values are two ints separated by a ','
      // character.  Since this is all dynamic, though, we don't want to
      // actually link against the class and use its methods. So we just
      // parse this back into int fields manually.  Sum them up and ensure
      // that we get the expected total for the first column, to verify that
      // we got all the results from the db into the file.

      // now sum up everything in the file.
      while (reader.next(key) != null) {
        reader.getCurrentValue(val);
        curSum += getFirstInt(val.toString());
      }

      IOUtils.closeStream(reader);
      reader = null;
    }

    assertEquals("Total sum of first db column mismatch", expectedSum,
        curSum);
  } catch (InvalidOptionsException ioe) {
    fail(ioe.toString());
  } catch (ParseException pe) {
    fail(pe.toString());
  } finally {
    IOUtils.closeStream(reader);

    if (null != prevClassLoader) {
      ClassLoaderStack.setCurrentClassLoader(prevClassLoader);
    }
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:66,代码来源:TestMultiMaps.java


注:本文中的com.cloudera.sqoop.tool.ImportTool.parseArguments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。