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; }