Gives a report on how the FileSystem is doing.
@exception IOException if the filesystem does not exist.
352688
public void report() throws IOException {
    DistributedFileSystem dfs = getDFS();
    if (dfs != null) {
      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();
      }      
    }
  }
559915
@Override
	public synchronized void createReport() throws IOException {
		if (reportLines.isEmpty()) {
			log.debug("No data to report. Skipping report generation.");
			return;
		}

		File reportFile = new File(archiveDir.get(), createFileName());

		log.debug("Writing report to file: {}", reportFile);

		String header = getHeaderLine();
		if (header != null) {
			reportLines.addFirst(header);
		}
		FileUtils.writeLines(reportFile, charset == null ? defaultCharset.name() : charset.name(), reportLines);

		reportLines.clear();
	}
294901
@Override
    public void checkRepositoryStatus() throws IOException {
        if (!exists(null)) {
            throw new FileNotFoundException("Could not find " + _root);
        }
        if (!hasChildren(null)) {
            throw new IOException("The root (" + _root + " is not a directory ");
        }
    }
758494
public int refreshNodes() throws IOException {
    int exitCode = -1;

    DistributedFileSystem dfs = getDFS();
    if (dfs == null) {
      System.err.println("FileSystem is " + getFS().getUri());
      return exitCode;
    }

    dfs.refreshNodes();
    exitCode = 0;
   
    return exitCode;
  }
23238
public void dump() throws IOException {
    FileWriter out = new FileWriter(outFile, true);
    try {
      dump(out);
    } finally {
      out.close();
    }
  }
369885
public void fsck() throws IOException {
    InjectionHandler.processEvent(InjectionEvent.NAMENODE_FSCK_START);
    
    try {
      FileStatus[] files = nn.namesystem.dir.getListing(path);
      FsckResult res = new FsckResult();
      if (!this.showFiles && !this.showBlocks && !this.showLocations
          && !this.showRacks) {
        res.totalRacks = nn.getNetworkTopology().getNumOfRacks();
        res.totalDatanodes = nn.namesystem
            .getNumberOfDatanodes(DatanodeReportType.LIVE);
      }
      res.setReplication((short) conf.getInt("dfs.replication", 3));
      if (files != null) {
        if (showCorruptFileBlocks && showOpenFiles) {
          listCorruptOpenFiles();
        
          return;
        }

        if (showCorruptFileBlocks) {
          listCorruptFileBlocks();
          return;
        }

        for (int i = 0; i < files.length; i++) {
          check(files[i], res);
        }
        out.println(res);
        // DFSck client scans for the string HEALTHY/CORRUPT to check the status
        // of file system and return appropriate code. Changing the output 
        // string might break testcases. 
        if (res.isHealthy()) {
          out.print("\n\nThe filesystem under path '" + path + "' " + HEALTHY_STATUS);
        } else {
          out.print("\n\nThe filesystem under path '" + path + "' " + CORRUPT_STATUS);
        }
      } else {
        out.print("\n\nPath '" + path + "' " + NONEXISTENT_STATUS);
      }
    } catch (Throwable e) {
      String errMsg = "Fsck on path '" + path + "' " + FAILURE_STATUS;
      LOG.warn(errMsg, e);
      out.println(e.getMessage());
      out.print("\n\n" + errMsg);
    } finally {
      out.close();
    }
  }
1366133
public boolean checkComplete() throws IOException {
     JobID jobID = runningJob.getID();
     if (runningJob.isComplete()) {
       // delete job directory
       final String jobdir = jobconf.get(JOB_DIR_LABEL);
       if (jobdir != null) {
         final Path jobpath = new Path(jobdir);
         jobpath.getFileSystem(jobconf).delete(jobpath, true);
       }
       if (runningJob.isSuccessful()) {
         LOG.info("Job Complete(Succeeded): " + jobID);
       } else {
         LOG.info("Job Complete(Failed): " + jobID);
       }
       raidPolicyPathPairList.clear();
       Counters ctrs = runningJob.getCounters();
       if (ctrs != null) {
         RaidNodeMetrics metrics = RaidNodeMetrics.getInstance(RaidNodeMetrics.DEFAULT_NAMESPACE_ID);
         if (ctrs.findCounter(Counter.FILES_FAILED) != null) {
           long filesFailed = ctrs.findCounter(Counter.FILES_FAILED).getValue();
           metrics.raidFailures.inc(filesFailed);
         }
         long slotSeconds = ctrs.findCounter(
          JobInProgress.Counter.SLOTS_MILLIS_MAPS).getValue() / 1000;
         metrics.raidSlotSeconds.inc(slotSeconds);
       }
       return true;
     } else {
       String report =  (" job " + jobID +
         " map " + StringUtils.formatPercent(runningJob.mapProgress(), 0)+
         " reduce " + StringUtils.formatPercent(runningJob.reduceProgress(), 0));
       if (!report.equals(lastReport)) {
         LOG.info(report);
         lastReport = report;
       }
       TaskCompletionEvent[] events =
         runningJob.getTaskCompletionEvents(jobEventCounter);
       jobEventCounter += events.length;
       for(TaskCompletionEvent event : events) {
         if (event.getTaskStatus() ==  TaskCompletionEvent.Status.FAILED) {
           LOG.info(" Job " + jobID + " " + event.toString());
         }
       }
       return false;
     }
   }
602506
synchronized private void checkEnv() throws IOException {
    if (!initialized) {
      FormatInfoWritable writable = localFormatInfoWritable.get();
      if (metadataManager.readWritableFromZk(formatInfoPath, writable, null) == null) {
        LOG.error("Environment not initialized (format() not called?)");
        throw new IOException(
            "Environment not initialized (format() not called?");
      }
      if (writable.getProtoVersion() != PROTO_VERSION) {
        throw new IllegalStateException("Wrong protocol version! Expected " +
            BKJM_BOOKKEEPER_DIGEST_PW + ", but read " +
            writable.getProtoVersion());
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug("Namespace info read: " + writable.toColonSeparatedString());
      }
    }
    currentInProgressMetadata.init();
    initialized = true;
  }
247990
@Override
    public void checkRepositoryStatus() throws IOException {
        for (File f : assets) {
            if (!f.exists()) {
                throw new FileNotFoundException("Could not find " + f + " in the LooseFileRepository");
            }
        }
    }
1072875
private FileStatus methodBasedGetFileInfo(String src) throws IOException {
    if (namenodeProtocolProxy.isMethodSupported(
        "getHdfsFileInfo", String.class)) {
      return HdfsFileStatus.toFileStatus(namenode.getHdfsFileInfo(src), src);
    } else {
      return namenode.getFileInfo(src);
    }
  }
58703
DistributedFileSystem getDFS() throws IOException {
    if (this.dfs == null) {
      FileSystem fs = location.getDFS();
      if (!(fs instanceof DistributedFileSystem)) {
        ErrorMessageDialog.display("DFS Browser",
            "The DFS Browser cannot browse anything else "
                + "but a Distributed File System!");
        throw new IOException("DFS Browser expects a DistributedFileSystem!");
      }
      this.dfs = (DistributedFileSystem) fs;
    }
    return this.dfs;
  }
1171544
public void reportErrorOnFile(File f) {
    // We use getAbsolutePath here instead of getCanonicalPath since we know
    // that there is some IO problem on that drive.
    // getCanonicalPath may need to call stat() or readlink() and it's likely
    // those calls would fail due to the same underlying IO problem.
    String absPath = f.getAbsolutePath();
    for (StorageDirectory sd : storageDirs) {
      String dirPath = sd.getRoot().getAbsolutePath();
      if (!dirPath.endsWith("/")) {
        dirPath += "/";
      }
      if (absPath.startsWith(dirPath)) {
        reportErrorsOnDirectory(sd, null);
        return;
      }
    }
    
  }
1232108
public function isLink()
    {
        clearstatcache();
        $fs = FileSystem::getFileSystem();
        if ($fs->checkAccess($this) !== true) {
            throw new IOException("No read access to " . $this->path);
        }

        return @is_link($this->path);
    }
283098
public function tell()
	{
		if (!$this->fh)
		{
			throw new FilesystemException('File not open');
		}

		// Capture PHP errors
		$php_errormsg = '';
		$trackErrors  = ini_get('track_errors');
		ini_set('track_errors', true);

		switch ($this->processingmethod)
		{
			case 'gz':
				$res = gztell($this->fh);

				break;

			case 'bz':
			case 'f':
			default:
				$res = ftell($this->fh);

				break;
		}

		// Restore error tracking to what it was before
		ini_set('track_errors', $trackErrors);

		// May return 0 so check if it's really false
		if ($res === false)
		{
			throw new FilesystemException($php_errormsg);
		}

		// Return the result
		return $res;
	}
127691
private void init() throws IOException {
        if (initialized.compareAndSet(false, true)) {
            log.debug("Init: {}", mode);
            // if the path is null, the consumer has been uninitialized
            if (path != null) {
                if (log.isDebugEnabled()) {
                    Path parent = path.getParent();
                    log.debug("Parent abs: {} dir: {}", parent.isAbsolute(), Files.isDirectory(parent));
                }
                if (IClientStream.MODE_APPEND.equals(mode)) {
                    if (Files.notExists(path)) {
                        throw new IOException("File to be appended doesnt exist, verify the record mode");
                    }
                    log.debug("Path: {}\nRead: {} write: {} size: {}", path, Files.isReadable(path), Files.isWritable(path), Files.size(path));
                    writer = new FLVWriter(path, true);
                } else if (IClientStream.MODE_RECORD.equals(mode)) {
                    try {
                        // delete existing file
                        if (Files.deleteIfExists(path)) {
                            log.debug("File deleted");
                        }
                        // ensure parent dirs exist
                        Files.createDirectories(path.getParent());
                        // create the file
                        path = Files.createFile(path);
                    } catch (IOException ioe) {
                        log.error("File creation error: {}", ioe);
                    }
                    if (!Files.isWritable(path)) {
                        throw new IOException("File is not writable");
                    }
                    log.debug("Path: {}\nRead: {} write: {}", path, Files.isReadable(path), Files.isWritable(path));
                    writer = new FLVWriter(path, false);
                } else {
                    try {
                        // delete existing file since we're not recording nor appending
                        if (Files.deleteIfExists(path)) {
                            log.debug("File deleted");
                        }
                    } catch (IOException ioe) {
                        log.error("File creation error: {}", ioe);
                    }
                }
            } else {
                log.warn("Consumer is uninitialized");
            }
            log.debug("Init - complete");
        }
    }
918954
public java.util.List<FileSystemDescription> getFileSystems() {
        if (fileSystems == null) {
            fileSystems = new com.amazonaws.internal.SdkInternalList<FileSystemDescription>();
        }
        return fileSystems;
    }
266579
public boolean exists() throws IOException {
        boolean exists = false;
        try {
            // force lookup again
            setFileHandle(null);
            exists = (getFileHandle() != null);
        } catch (FileNotFoundException e) {
            // do nothing
        }
        return exists;
    }