void format(FSNamesystem fsn, String clusterId, boolean force) throws IOException { long fileCount = fsn.getFilesTotal(); // Expect 1 file, which is the root inode Preconditions.checkState(fileCount == 1, "FSImage.format should be called with an uninitialized namesystem, has " + fileCount + " files"); NamespaceInfo ns = NNStorage.newNamespaceInfo(); LOG.info("Allocated new BlockPoolId: " + ns.getBlockPoolID()); ns.clusterID = clusterId; storage.format(ns); editLog.formatNonFileJournals(ns, force); saveFSImageInAllDirs(fsn, 0); }
@Override // NameNodeMXBean public long getTotalFiles() { return getFilesTotal(); }
@Override // NameNodeMXBean @Metric public long getTotalFiles() { return getFilesTotal(); }
@Override // NameNodeMXBean @Metric public long getTotalFiles() { return getFilesTotal(); }
/** * Get a sample of the total files in the FileSystem. The sampling is done * randomly. * * @param percentage * the percentage of files to sample, value should be between (0 - * 1.0] * @return the list of files */ public List<FileStatusExtended> getRandomFilesSample(float percentage) { if (!(percentage > 0 && percentage <= 1.0)) { throw new IllegalArgumentException("Invalid percentage : " + percentage + " value should be between (0 - 1.0]"); } long totalFiles = this.namesystem.getFilesTotal(); long filesToSample = (long) (percentage * totalFiles); if (filesToSample > Integer.MAX_VALUE) { throw new IllegalArgumentException("Too many files to sample : " + filesToSample + " total files : " + totalFiles); } LOG.info("Sampling : " + filesToSample + " out of " + totalFiles + " files"); return getRandomFiles((int) filesToSample); }
synchronized (this) { FSNamesystem fsNameSystem = FSNamesystem.getFSNamesystem(); filesTotal.set((int)fsNameSystem.getFilesTotal()); filesTotal.pushMetric(metricsRecord);