public long updateMinFreeDiskSpaceFromSrcFSGroup() throws Exception { String mfd = (String) server.getAttribute( new ObjectName(getFileSystemMgtServiceNamePrefix() + srcFsGroup), "MinimumFreeDiskSpace"); log.info("getMinFreeDiskSpaceFromSrcFS group:" + srcFsGroup + " minFree:" + mfd); if (mfd.equalsIgnoreCase(NONE)) return 0; if (mfd.endsWith("%")) { float ratio = Float.parseFloat(mfd.substring(0, mfd.length() - 1)); FileSystemDTO[] fsDTOs = fileSystemMgt().getFileSystemsOfGroup(srcFsGroup); long total = 0L; for (FileSystemDTO fsDTO : fsDTOs) { int status = fsDTO.getStatus(); if (status == FileSystemStatus.RW || status == FileSystemStatus.DEF_RW) { File dir = FileUtils.toFile(fsDTO.getDirectoryPath()); if (dir.isDirectory()) { total += FileSystemUtils.totalSpace(dir.getPath()); } } } minFree = (long) (total * ratio / 100); } else { minFree = FileUtils.parseSize(mfd, MIN_FREE_DISK_SPACE); } return minFree; }
private long calcFreeDiskSpace(FileSystemDTO fs) { if (fs == null) { return -1; } File dir = checkFS(fs, " - can not calculate minimum free disc space!"); if (dir == null) { return -1; } long total = FileSystemUtils.totalSpace(dir.getAbsolutePath()); log.info("Total space of " + fs.getDirectoryPath() + " :" + FileUtils.formatSize(total)); return (long) (total * minFreeDiskSpaceRatio / 100); }
private boolean checkFreeDiskSpace(FileSystemDTO fsDTO) throws IOException { File dir = checkFS(fsDTO, " - try to switch to next configured storage directory"); if (dir == null) return false; if (getMinFreeDiskSpaceBytes() == 0) { return true; } final long freeSpace = FileSystemUtils.freeSpace(dir.getPath()); log.info("Free disk space on " + dir + ": " + FileUtils.formatSize(freeSpace)); if (freeSpace < getMinFreeDiskSpaceBytes()) { log.info( "High Water Mark reached on current storage directory " + dir + " - try to switch to next configured storage directory"); return false; } checkFreeDiskSpaceTime = System.currentTimeMillis() + Math.min( freeSpace * checkFreeDiskSpaceMinInterval / getMinFreeDiskSpaceBytes(), checkFreeDiskSpaceMaxInterval); return true; }
public long getUsableDiskSpaceOnDest() { try { if (destFsGroup == null) return -1; if (destFsGroup.indexOf('@') == -1) return (Long) server.getAttribute( new ObjectName(getFileSystemMgtServiceNamePrefix() + destFsGroup), "UsableDiskSpace"); FileSystemDTO fsDTO = getDestinationFilesystem(fileSystemMgt()); if (fsDTO == null) return -2; String dirPath = fsDTO.getDirectoryPath(); if (dirPath.startsWith("tar:")) dirPath = dirPath.substring(4); File dir = FileUtils.toFile(dirPath); return dir.isDirectory() ? FileSystemUtils.freeSpace(dir.getPath()) - getMinFreeDiskSpaceOnDestFS() : hsmModuleServicename == null ? -1 : Long.MAX_VALUE; } catch (Exception x) { log.error("Failed to get UsableDiskSpaceOnDest!", x); return -3; } }
public String getUsableDiskSpaceStringOnDest() { try { if (destFsGroup == null) return NOT_APPLICABLE; if (destFsGroup.indexOf('@') == -1) return (String) server.getAttribute( new ObjectName(getFileSystemMgtServiceNamePrefix() + destFsGroup), "UsableDiskSpaceString"); FileSystemDTO fsDTO = getDestinationFilesystem(fileSystemMgt()); if (fsDTO == null) return "Dest FS not found!"; String dirPath = fsDTO.getDirectoryPath(); if (dirPath.startsWith("tar:")) dirPath = dirPath.substring(4); File dir = FileUtils.toFile(dirPath); return dir.isDirectory() ? FileUtils.formatSize( FileSystemUtils.freeSpace(dir.getPath()) - getMinFreeDiskSpaceOnDestFS()) : hsmModuleServicename == null ? "UNKNOWN (destination path not found)" : "n.a. (HSM)"; } catch (Exception x) { log.error("Failed to get UsableDiskSpaceStringOnDest!", x); return ERROR; } }
public long getFreeDiskSpaceOnCurFS() throws IOException { if (storageFileSystem == null) return -1L; File dir = FileUtils.toFile(storageFileSystem.getDirectoryPath()); return dir.isDirectory() ? FileSystemUtils.freeSpace(dir.getPath()) : -1L; }