/** * return total size in bytes from a list of WALs */ private long getTotalWALSize(FileSystem fs, List<String> wals, ServerName server) throws IOException { long size = 0; FileStatus fileStatus; for (String wal : wals) { try { fileStatus = (new WALLink(getConf(), server.getServerName(), wal)).getFileStatus(fs); } catch (IOException e) { if (e instanceof FileNotFoundException) { numWalsNotFound++; LOG.warn("WAL " + wal + " couldn't be found, skipping", e); } else { LOG.warn("Can't get file status of WAL " + wal + ", skipping", e); } continue; } size += fileStatus.getLen(); } totalSizeOfWALs += size; return size; }
/** * Add the specified log file to the stats * @param server server name * @param logfile log file name * @return the log information */ FileInfo addLogFile(final String server, final String logfile) throws IOException { WALLink logLink = new WALLink(conf, server, logfile); long size = -1; try { size = logLink.getFileStatus(fs).getLen(); logSize.addAndGet(size); logsCount.incrementAndGet(); } catch (FileNotFoundException e) { logsMissing.incrementAndGet(); } return new FileInfo(false, size, false); }