コード例 #1
0
  /**
   * Command to request current distributed upgrade status, a detailed status, or to force the
   * upgrade to proceed.
   *
   * <p>Usage: java DFSAdmin -upgradeProgress [status | details | force]
   *
   * @exception IOException
   */
  public int upgradeProgress(String[] argv, int idx) throws IOException {
    if (!(fs instanceof DistributedFileSystem)) {
      System.out.println("FileSystem is " + fs.getUri());
      return -1;
    }
    if (idx != argv.length - 1) {
      printUsage("-upgradeProgress");
      return -1;
    }

    UpgradeAction action;
    if ("status".equalsIgnoreCase(argv[idx])) {
      action = UpgradeAction.GET_STATUS;
    } else if ("details".equalsIgnoreCase(argv[idx])) {
      action = UpgradeAction.DETAILED_STATUS;
    } else if ("force".equalsIgnoreCase(argv[idx])) {
      action = UpgradeAction.FORCE_PROCEED;
    } else {
      printUsage("-upgradeProgress");
      return -1;
    }

    DistributedFileSystem dfs = (DistributedFileSystem) fs;
    UpgradeStatusReport status = dfs.distributedUpgradeProgress(action);
    String statusText =
        (status == null
            ? "There are no upgrades in progress."
            : status.getStatusText(action == UpgradeAction.DETAILED_STATUS));
    System.out.println(statusText);
    return 0;
  }
コード例 #2
0
ファイル: JspHelper.java プロジェクト: baggioss/hadoop-cdh3u5
 public String getUpgradeStatusText() {
   String statusText = "";
   try {
     UpgradeStatusReport status = fsn.distributedUpgradeProgress(UpgradeAction.GET_STATUS);
     statusText =
         (status == null ? "There are no upgrades in progress." : status.getStatusText(false));
   } catch (IOException e) {
     statusText = "Upgrade status unknown.";
   }
   return statusText;
 }
コード例 #3
0
  /**
   * Gives a report on how the FileSystem is doing.
   *
   * @exception IOException if the filesystem does not exist.
   */
  public void report() throws IOException {
    if (fs instanceof DistributedFileSystem) {
      DistributedFileSystem dfs = (DistributedFileSystem) fs;
      DiskStatus ds = dfs.getDiskStatus();
      long capacity = ds.getCapacity();
      long used = ds.getDfsUsed();
      long remaining = ds.getRemaining();
      long presentCapacity = used + remaining;
      boolean mode = dfs.setSafeMode(FSConstants.SafeModeAction.SAFEMODE_GET);
      UpgradeStatusReport status = dfs.distributedUpgradeProgress(UpgradeAction.GET_STATUS);

      if (mode) {
        System.out.println("Safe mode is ON");
      }
      if (status != null) {
        System.out.println(status.getStatusText(false));
      }
      System.out.println(
          "Configured Capacity: " + capacity + " (" + StringUtils.byteDesc(capacity) + ")");
      System.out.println(
          "Present Capacity: "
              + presentCapacity
              + " ("
              + StringUtils.byteDesc(presentCapacity)
              + ")");
      System.out.println(
          "DFS Remaining: " + remaining + " (" + StringUtils.byteDesc(remaining) + ")");
      System.out.println("DFS Used: " + used + " (" + StringUtils.byteDesc(used) + ")");
      System.out.println(
          "DFS Used%: "
              + StringUtils.limitDecimalTo2(((1.0 * used) / presentCapacity) * 100)
              + "%");

      /* These counts are not always upto date. They are updated after
       * iteration of an internal list. Should be updated in a few seconds to
       * minutes. Use "-metaSave" to list of all such blocks and accurate
       * counts.
       */
      System.out.println("Under replicated blocks: " + dfs.getUnderReplicatedBlocksCount());
      System.out.println("Blocks with corrupt replicas: " + dfs.getCorruptBlocksCount());
      System.out.println("Missing blocks: " + dfs.getMissingBlocksCount());

      System.out.println();

      System.out.println("-------------------------------------------------");

      DatanodeInfo[] live = dfs.getClient().datanodeReport(DatanodeReportType.LIVE);
      DatanodeInfo[] dead = dfs.getClient().datanodeReport(DatanodeReportType.DEAD);
      System.out.println(
          "Datanodes available: "
              + live.length
              + " ("
              + (live.length + dead.length)
              + " total, "
              + dead.length
              + " dead)\n");

      for (DatanodeInfo dn : live) {
        System.out.println(dn.getDatanodeReport());
        System.out.println();
      }
      for (DatanodeInfo dn : dead) {
        System.out.println(dn.getDatanodeReport());
        System.out.println();
      }
    }
  }