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


Java ToolRunner.confirmPrompt方法代码示例

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


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

示例1: confirmFormat

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
private boolean confirmFormat() {
  String parentZnode = getParentZnode();
  System.err.println(
      "===============================================\n" +
      "The configured parent znode " + parentZnode + " already exists.\n" +
      "Are you sure you want to clear all failover information from\n" +
      "ZooKeeper?\n" +
      "WARNING: Before proceeding, ensure that all HDFS services and\n" +
      "failover controllers are stopped!\n" +
      "===============================================");
  try {
    return ToolRunner.confirmPrompt("Proceed formatting " + parentZnode + "?");
  } catch (IOException e) {
    LOG.debug("Failed to confirm", e);
    return false;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:ZKFailoverController.java

示例2: canBeSafelyDeleted

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
private boolean canBeSafelyDeleted(PathData item)
    throws IOException {
  boolean shouldDelete = true;
  if (safeDelete) {
    final long deleteLimit = getConf().getLong(
        HADOOP_SHELL_SAFELY_DELETE_LIMIT_NUM_FILES,
        HADOOP_SHELL_SAFELY_DELETE_LIMIT_NUM_FILES_DEFAULT);
    if (deleteLimit > 0) {
      ContentSummary cs = item.fs.getContentSummary(item.path);
      final long numFiles = cs.getFileCount();
      if (numFiles > deleteLimit) {
        if (!ToolRunner.confirmPrompt("Proceed deleting " + numFiles +
            " files?")) {
          System.err.println("Delete aborted at user request.\n");
          shouldDelete = false;
        }
      }
    }
  }
  return shouldDelete;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:22,代码来源:Delete.java

示例3: confirmFormat

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
/**
 * Iterate over each of the {@link FormatConfirmable} objects,
 * potentially checking with the user whether it should be formatted.
 * 
 * If running in interactive mode, will prompt the user for each
 * directory to allow them to format anyway. Otherwise, returns
 * false, unless 'force' is specified.
 * 
 * @param force format regardless of whether dirs exist
 * @param interactive prompt the user when a dir exists
 * @return true if formatting should proceed
 * @throws IOException if some storage cannot be accessed
 */
public static boolean confirmFormat(
    Iterable<? extends FormatConfirmable> items,
    boolean force, boolean interactive) throws IOException {
  for (FormatConfirmable item : items) {
    if (!item.hasSomeData())
      continue;
    if (force) { // Don't confirm, always format.
      System.err.println(
          "Data exists in " + item + ". Formatting anyway.");
      continue;
    }
    if (!interactive) { // Don't ask - always don't format
      System.err.println(
          "Running in non-interactive mode, and data appears to exist in " +
          item + ". Not formatting.");
      return false;
    }
    if (!ToolRunner.confirmPrompt("Re-format filesystem in " + item + " ?")) {
      System.err.println("Format aborted in " + item);
      return false;
    }
  }
  
  return true;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:39,代码来源:Storage.java

示例4: validate

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
@Override
public boolean validate() {
  provider = getCredentialProvider();
  if (provider == null) {
    out.println("There are no valid CredentialProviders configured.\n"
        + "Nothing will be deleted.\n"
        + "Consider using the -provider option to indicate the provider"
        + " to use.");
    return false;
  }
  if (alias == null) {
    out.println("There is no alias specified. Please provide the" +
        "mandatory <alias>. See the usage description with -help.");
    return false;
  }
  if (interactive) {
    try {
      cont = ToolRunner
          .confirmPrompt("You are about to DELETE the credential " +
              alias + " from CredentialProvider " + provider.toString() +
              ". Continue? ");
      if (!cont) {
        out.println("Nothing has been deleted.");
      }
      return cont;
    } catch (IOException e) {
      out.println(alias + " will not be deleted.");
      e.printStackTrace(err);
    }
  }
  return true;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:CredentialShell.java

示例5: confirmForceManual

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
private boolean confirmForceManual() throws IOException {
   return ToolRunner.confirmPrompt(
      "You have specified the --" + FORCEMANUAL + " flag. This flag is " +
      "dangerous, as it can induce a split-brain scenario that WILL " +
      "CORRUPT your HDFS namespace, possibly irrecoverably.\n" +
      "\n" +
      "It is recommended not to use this flag, but instead to shut down the " +
      "cluster and disable automatic failover if you prefer to manually " +
      "manage your HA state.\n" +
      "\n" +
      "You may abort safely by answering 'n' or hitting ^C now.\n" +
      "\n" +
      "Are you sure you want to continue?");
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:HAAdmin.java

示例6: validate

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
@Override
public boolean validate() {
  provider = getKeyProvider();
  if (provider == null) {
    out.println("There are no valid KeyProviders configured. Nothing\n"
      + "was deleted. Use the -provider option to specify a provider.");
    return false;
  }
  if (keyName == null) {
    out.println("There is no keyName specified. Please specify a " +
        "<keyname>. See the usage description with -help.");
    return false;
  }
  if (interactive) {
    try {
      cont = ToolRunner
          .confirmPrompt("You are about to DELETE all versions of "
              + " key " + keyName + " from KeyProvider "
              + provider + ". Continue? ");
      if (!cont) {
        out.println(keyName + " has not been deleted.");
      }
      return cont;
    } catch (IOException e) {
      out.println(keyName + " will not be deleted.");
      e.printStackTrace(err);
    }
  }
  return true;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:31,代码来源:KeyShell.java

示例7: validate

import org.apache.hadoop.util.ToolRunner; //导入方法依赖的package包/类
@Override
public boolean validate() {
  provider = getCredentialProvider();
  if (provider == null) {
    out.println("There are no valid CredentialProviders configured.\n"
        + "Nothing will be deleted.\n"
        + "Consider using the -provider option to indicate the provider"
        + " to use.");
    return false;
  }
  if (alias == null) {
    out.println("There is no alias specified. Please provide the" +
        "mandatory <alias>. See the usage description with -help.");
    return false;
  }
  if (interactive) {
    try {
      cont = ToolRunner
          .confirmPrompt("You are about to DELETE the credential " +
              alias + " from CredentialProvider " + provider.toString() +
              ". Continue? ");
      if (!cont) {
        out.println("Nothing has been be deleted.");
      }
      return cont;
    } catch (IOException e) {
      out.println(alias + " will not be deleted.");
      e.printStackTrace(err);
    }
  }
  return true;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:CredentialShell.java


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