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


Java ImportTool.parseArguments方法代码示例

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


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

示例1: testPasswordFileDoesNotExist

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordFileDoesNotExist() throws Exception {
  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--password-file");
    extraArgs.add(TEMP_BASE_DIR + "unknown");
    String[] argv = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions opts = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    importTool.parseArguments(argv, conf, opts, true);
    fail("The password file does not exist!");
  } catch (Exception e) {
    assertTrue(e.getMessage().matches(".*The provided password file "
      + ".* does not exist!"));
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:18,代码来源:TestPassingSecurePassword.java

示例2: testPasswordFileIsADirectory

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordFileIsADirectory() throws Exception {
  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--password-file");
    extraArgs.add(TEMP_BASE_DIR);
    String[] argv = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions opts = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    importTool.parseArguments(argv, conf, opts, true);
    fail("The password file cannot be a directory!");
  } catch (Exception e) {
    assertTrue(e.getMessage().matches(".*The provided password file .*"
      + " is a directory!"));
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:18,代码来源:TestPassingSecurePassword.java

示例3: testPasswordFilePath

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordFilePath() throws Exception {
  String passwordFilePath = TEMP_BASE_DIR + ".pwd";
  createTempFile(passwordFilePath);
  writeToFile(passwordFilePath, "password");

  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--username");
    extraArgs.add("username");
    extraArgs.add("--password-file");
    extraArgs.add(passwordFilePath);
    String[] commonArgs = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions in = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    SqoopOptions out = importTool.parseArguments(commonArgs, conf, in, true);
    assertNotNull(out.getPasswordFilePath());
    assertNotNull(out.getPassword());
    assertEquals("password", out.getPassword());
  } catch (Exception e) {
    fail("passwordPath option is missing.");
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:25,代码来源:TestPassingSecurePassword.java

示例4: testPasswordFileDoesNotExist

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordFileDoesNotExist() throws Exception {
  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--password-file");
    extraArgs.add(TEMP_BASE_DIR + "unknown");
    String[] argv = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions opts = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    importTool.parseArguments(argv, conf, opts, true);
    fail("The password file does not exist! ");
  } catch (Exception e) {
    assertTrue(e.getMessage().contains("The password file does not exist!"));
  }
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:17,代码来源:TestPassingSecurePassword.java

示例5: testPasswordFileIsADirectory

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordFileIsADirectory() throws Exception {
  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--password-file");
    extraArgs.add(TEMP_BASE_DIR);
    String[] argv = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions opts = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    importTool.parseArguments(argv, conf, opts, true);
    fail("The password file cannot be a directory! ");
  } catch (Exception e) {
    assertTrue(e.getMessage().contains("The password file cannot "
      + "be a directory!"));
  }
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:18,代码来源:TestPassingSecurePassword.java

示例6: testBothPasswordOptions

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testBothPasswordOptions() throws Exception {
  String passwordFilePath = TEMP_BASE_DIR + ".pwd";
  createTempFile(passwordFilePath);

  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--username");
    extraArgs.add("username");
    extraArgs.add("--password");
    extraArgs.add("password");
    extraArgs.add("--password-file");
    extraArgs.add(passwordFilePath);
    String[] argv = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions in = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    SqoopOptions out = importTool.parseArguments(argv, conf, in, true);
    assertNotNull(out.getPassword());
    importTool.validateOptions(out);
    fail("Either password or passwordPath must be specified but not both.");
  } catch (Exception e) {
    assertTrue(e.getMessage().contains("Either password or path to a "
      + "password file must be specified but not both"));
  }
}
 
开发者ID:unicredit,项目名称:zSqoop,代码行数:27,代码来源:TestPassingSecurePassword.java

示例7: testBothPasswordOptions

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testBothPasswordOptions() throws Exception {
  String passwordFilePath = TEMP_BASE_DIR + ".pwd";
  createTempFile(passwordFilePath);

  try {
    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--username");
    extraArgs.add("username");
    extraArgs.add("--password");
    extraArgs.add("password");
    extraArgs.add("--password-file");
    extraArgs.add(passwordFilePath);
    String[] argv = getCommonArgs(false, extraArgs);

    Configuration conf = getConf();
    SqoopOptions in = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();
    SqoopOptions out = importTool.parseArguments(argv, conf, in, true);
    assertNotNull(out.getPassword());
    importTool.validateOptions(out);
    fail("Only one of password, password "
        + "alias or path to a password file must be specified.");
  } catch (Exception e) {
    assertTrue(e.getMessage().contains("Only one of password, password "
        + "alias or path to a password file must be specified."));
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:28,代码来源:TestPassingSecurePassword.java

示例8: testPasswordInMetastoreWithRecordEnabledAndSecureOption

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordInMetastoreWithRecordEnabledAndSecureOption()
  throws Exception {
  String passwordFilePath = TEMP_BASE_DIR + ".pwd";
  createTempFile(passwordFilePath);

  ArrayList<String> extraArgs = new ArrayList<String>();
  extraArgs.add("--username");
  extraArgs.add("username");
  extraArgs.add("--password-file");
  extraArgs.add(passwordFilePath);
  String[] argv = getCommonArgs(false, extraArgs);

  Configuration conf = getConf();
  SqoopOptions in = getSqoopOptions(conf);
  ImportTool importTool = new ImportTool();
  SqoopOptions out = importTool.parseArguments(argv, conf, in, true);
  assertNotNull(out.getPassword());

  // Enable storing passwords in the metastore
  conf.set(SqoopOptions.METASTORE_PASSWORD_KEY, "true");

  // this is what is used to record password into the metastore
  Properties propertiesIntoMetastore = out.writeProperties();

  assertNull(propertiesIntoMetastore.getProperty("db.password"));
  // password-file should NOT be null as it'll be sued to retrieve password
  assertNotNull(propertiesIntoMetastore.getProperty("db.password.file"));

  // load the saved properties and verify
  SqoopOptions optionsFromMetastore = new SqoopOptions();
  optionsFromMetastore.loadProperties(propertiesIntoMetastore);
  assertNotNull(optionsFromMetastore.getPassword());
  assertNotNull(optionsFromMetastore.getPasswordFilePath());
  assertEquals(passwordFilePath, optionsFromMetastore.getPasswordFilePath());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:36,代码来源:TestPassingSecurePassword.java

示例9: testPasswordInMetastoreWithRecordDisabledAndSecureOption

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordInMetastoreWithRecordDisabledAndSecureOption()
  throws Exception {
  String passwordFilePath = TEMP_BASE_DIR + ".pwd";
  createTempFile(passwordFilePath);

  ArrayList<String> extraArgs = new ArrayList<String>();
  extraArgs.add("--username");
  extraArgs.add("username");
  extraArgs.add("--password-file");
  extraArgs.add(passwordFilePath);
  String[] argv = getCommonArgs(false, extraArgs);

  Configuration conf = getConf();
  SqoopOptions in = getSqoopOptions(conf);
  ImportTool importTool = new ImportTool();
  SqoopOptions out = importTool.parseArguments(argv, conf, in, true);
  assertNotNull(out.getPassword());

  // Enable storing passwords in the metastore
  conf.set(SqoopOptions.METASTORE_PASSWORD_KEY, "false");

  // this is what is used to record password into the metastore
  Properties propertiesIntoMetastore = out.writeProperties();

  assertNull(propertiesIntoMetastore.getProperty("db.password"));
  assertNotNull(propertiesIntoMetastore.getProperty("db.password.file"));

  // load the saved properties and verify
  SqoopOptions optionsFromMetastore = new SqoopOptions();
  optionsFromMetastore.loadProperties(propertiesIntoMetastore);
  assertNotNull(optionsFromMetastore.getPassword());
  assertNotNull(optionsFromMetastore.getPasswordFilePath());
  assertEquals(passwordFilePath, optionsFromMetastore.getPasswordFilePath());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:35,代码来源:TestPassingSecurePassword.java

示例10: testPasswordInMetastoreWithRecordEnabledAndNonSecureOption

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordInMetastoreWithRecordEnabledAndNonSecureOption()
  throws Exception {
  ArrayList<String> extraArgs = new ArrayList<String>();
  extraArgs.add("--username");
  extraArgs.add("username");
  extraArgs.add("--password");
  extraArgs.add("password");
  String[] argv = getCommonArgs(false, extraArgs);

  Configuration conf = getConf();
  SqoopOptions in = getSqoopOptions(conf);
  ImportTool importTool = new ImportTool();
  SqoopOptions out = importTool.parseArguments(argv, conf, in, true);
  assertNotNull(out.getPassword());

  // Enable storing passwords in the metastore
  conf.set(SqoopOptions.METASTORE_PASSWORD_KEY, "true");

  // this is what is used to record password into the metastore
  Properties propertiesIntoMetastore = out.writeProperties();

  assertNotNull(propertiesIntoMetastore.getProperty("db.password"));
  assertNull(propertiesIntoMetastore.getProperty("db.password.file"));

  // load the saved properties and verify
  SqoopOptions optionsFromMetastore = new SqoopOptions();
  optionsFromMetastore.loadProperties(propertiesIntoMetastore);
  assertNotNull(optionsFromMetastore.getPassword());
  assertNull(optionsFromMetastore.getPasswordFilePath());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:31,代码来源:TestPassingSecurePassword.java

示例11: testPasswordAliasOption

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testPasswordAliasOption() throws Exception {
  CredentialProviderPasswordLoader pl =
      new CredentialProviderPasswordLoader();

  if (!CredentialProviderHelper.isProviderAvailable()) {
    LOG.info("CredentialProvider facility not available "
      + "in the hadoop environment used");
  } else {
    String alias = "super.secret.alias";
    String pw = "super.secret.password";
    String jksFile = "creds.jks";
    File credDir = new File(".");

    Configuration conf = getConf();
    String ourUrl =  CredentialProviderHelper.SCHEME_NAME +
      "://file/" + credDir.getAbsolutePath() + "/" + jksFile;
    File file = new File(credDir, jksFile);
    file.delete();
    conf.set(CredentialProviderHelper.CREDENTIAL_PROVIDER_PATH,
      ourUrl);
    CredentialProviderHelper.createCredentialEntry(conf, alias, pw);

    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--username");
    extraArgs.add("username");
    extraArgs.add("--password-alias");
    extraArgs.add(alias);
    String[] commonArgs = getCommonArgs(false, extraArgs);

    SqoopOptions in = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();

    SqoopOptions out = importTool.parseArguments(commonArgs, conf, in, true);
    assertEquals(pw, out.getPassword());
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:37,代码来源:TestPassingSecurePassword.java

示例12: executeCipherTest

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void executeCipherTest(String password, String passphrase, String cipher, int keySize) throws Exception {
  LOG.info("Using cipher: " + cipher + " with keySize " + keySize + " and passphrase " + passphrase );
  String passwordFilePath = TEMP_BASE_DIR + ".pwd";
  createTempFile(passwordFilePath);
  writeToFile(passwordFilePath, encryptPassword(password, passphrase, cipher, 10000, keySize));
  LOG.info("Generated encrypted password file in: " + passwordFilePath);

  ArrayList<String> extraArgs = new ArrayList<String>();
  extraArgs.add("--username");
  extraArgs.add("username");
  extraArgs.add("--password-file");
  extraArgs.add(passwordFilePath);
  String[] commonArgs = getCommonArgs(false, extraArgs);

  Configuration conf = getConf();
  conf.set("org.apache.sqoop.credentials.loader.class", CryptoFileLoader.class.getCanonicalName());
  conf.set("org.apache.sqoop.credentials.loader.crypto.alg", cipher);
  conf.set("org.apache.sqoop.credentials.loader.crypto.passphrase", passphrase);
  conf.setInt("org.apache.sqoop.credentials.loader.crypto.salt.key.len", keySize);

  SqoopOptions in = getSqoopOptions(conf);
  ImportTool importTool = new ImportTool();

  SqoopOptions out = importTool.parseArguments(commonArgs, conf, in, true);
  assertNotNull(out.getPasswordFilePath());
  assertNotNull(out.getPassword());
  assertEquals(passphrase, out.getPassword());
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:29,代码来源:TestPassingSecurePassword.java

示例13: testCredentialProviderLoader

import org.apache.sqoop.tool.ImportTool; //导入方法依赖的package包/类
public void testCredentialProviderLoader() throws Exception {
  CredentialProviderPasswordLoader pl =
      new CredentialProviderPasswordLoader();

  if (!CredentialProviderHelper.isProviderAvailable()) {
    LOG.info("CredentialProvider facility not available "
      + "in the hadoop environment used");
  } else {
    String alias = "super.secret.alias";
    String pw = "super.secret.password";

    String passwordFilePath = TEMP_BASE_DIR + ".pwd";
    String jksFile = "creds.jks";
    createTempFile(passwordFilePath);
    writeToFile(passwordFilePath, alias.getBytes());
    File credDir = new File(".");

    Configuration conf = getConf();
    String ourUrl =  CredentialProviderHelper.SCHEME_NAME +
      "://file/" + credDir.getAbsolutePath() + "/" + jksFile;
    File file = new File(credDir, jksFile);
    file.delete();
    conf.set(CredentialProviderHelper.CREDENTIAL_PROVIDER_PATH,
      ourUrl);
    CredentialProviderHelper.createCredentialEntry(conf, alias, pw);

    conf.set("org.apache.sqoop.credentials.loader.class",
      CredentialProviderPasswordLoader.class.getCanonicalName());

    ArrayList<String> extraArgs = new ArrayList<String>();
    extraArgs.add("--username");
    extraArgs.add("username");
    extraArgs.add("--password-file");
    extraArgs.add(passwordFilePath);
    String[] commonArgs = getCommonArgs(false, extraArgs);

    SqoopOptions in = getSqoopOptions(conf);
    ImportTool importTool = new ImportTool();

    SqoopOptions out = importTool.parseArguments(commonArgs, conf, in, true);
    assertEquals(pw, pl.loadPassword(passwordFilePath, conf));
    assertEquals(pw, out.getPassword());
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:45,代码来源:TestPassingSecurePassword.java


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