FileSystem fs = mounts.getMountPoint(name);
private String getFirstMountPoint() throws SigarException { @SuppressWarnings("unchecked") final Set<Map.Entry<String, FileSystem>> entries = (Set<Map.Entry<String, FileSystem>>) sigar.getFileSystemMap().entrySet(); for (Map.Entry<String, FileSystem> e : entries) { if (e.getValue().getType() == FileSystem.TYPE_LOCAL_DISK) { return e.getKey(); } } throw new IllegalStateException("No mount point found"); }
private void getAllDiskFilesystems(SigarProxy aSigar, LinkedList list) { try { FileSystemMap map = aSigar.getFileSystemMap(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); FileSystem fs = (FileSystem) map.get(key); if (fs.getType() == FileSystem.TYPE_LOCAL_DISK) { list.add(key); } } } catch (SigarException e) { log.warn("Can't get filesystems map", e); } }
public List<FileSystemInfo> getFileSystems() { List<String> mountPoints = new ArrayList<String>(); try { FileSystemMap map = sigar.getFileSystemMap(); mountPoints.addAll(map.keySet()); } catch (Exception e) { log.warn("Cannot obtain native file system information", e); // ignore native error otherwise } List<FileSystemInfo> infos = new ArrayList<FileSystemInfo>(); for (String mountPoint : mountPoints) { infos.add(new FileSystemInfo(mountPoint)); } return infos; }
private void createFileSystemObject(SigarProxy sigar) { try { // this only needs to be loaded once - it will never change during the lifetime of the file system if (this.fs == null) { this.fs = sigar.getFileSystemMap().getFileSystem(this.mountPoint); } } catch (Exception e) { throw new SystemInfoException("Cannot refresh file system mounted at [" + this.mountPoint + "]", e); } }
private void getAllDiskFilesystems(SigarProxy aSigar, LinkedList list) { try { FileSystemMap map = aSigar.getFileSystemMap(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); FileSystem fs = (FileSystem) map.get(key); if (fs.getType() == FileSystem.TYPE_LOCAL_DISK) { list.add(key); } } } catch (SigarException e) { log.warn("Can't get filesystems map", e); } }
private List<FileSystemInfo> getFileSystems(boolean deferredUsageInfo) { List<String> mountPoints = new ArrayList<String>(); try { FileSystemMap map = sigar.getFileSystemMap(); mountPoints.addAll(map.keySet()); } catch (Exception e) { log.warn("Cannot obtain native file system information", e); // ignore native error otherwise } List<FileSystemInfo> infos = new ArrayList<FileSystemInfo>(); for (String mountPoint : mountPoints) { infos.add(new FileSystemInfo(mountPoint, deferredUsageInfo)); } return infos; }
public void refresh() { SigarProxy sigar = SigarAccess.getSigar(); try { // this only needs to be loaded once - it will never change during the lifetime of the file system if (this.fs == null) { this.fs = sigar.getFileSystemMap().getFileSystem(this.mountPoint); } } catch (Exception e) { throw new SystemInfoException("Cannot refresh file system mounted at [" + this.mountPoint + "]", e); } try { // this is the usage data and therefore should be refreshed this.fsUsage = sigar.getMountedFileSystemUsage(this.mountPoint); } catch (SigarException e) { // this happens when the file system is not available (e.g. if it's a CD-ROM without a CD loaded in it) or // if we don't have permission to access the filesystem. we can ignore it and set the usage data to null. this.fsUsage = null; if (LOG.isTraceEnabled()) { LOG.trace("Cannot refresh the usage data for file system mounted at [" + this.mountPoint + "].", e); } else if (LOG.isDebugEnabled()) { LOG.debug("Cannot refresh the usage data for file system mounted at [" + this.mountPoint + "]: " + e); } } catch (RuntimeException e) { this.fsUsage = null; LOG.error("An error occurred while refreshing the usage data for file system mounted at [" + this.mountPoint + "].", e); } }
public void outputFileSystem(String arg) throws SigarException { FileSystemMap mounts = this.proxy.getFileSystemMap(); String name = FileCompleter.expand(arg); FileSystem fs = mounts.getMountPoint(name); if (fs != null) { printHeader(); output(fs); return; } throw new SigarException(arg + " No such file or directory"); }
public static void logAvailableFilesystems(SigarProxy aSigar) { log.info("*** Logging available filesystems ***"); try { FileSystemMap map = aSigar.getFileSystemMap(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); FileSystem fs = (FileSystem) map.get(key); log.info("Filesystem: fs=" + fs.toString() + " type=" + fs.getSysTypeName()); } } catch (SigarException e) { log.warn("Can't get filesystems map", e); } }
final Set<Map.Entry<String, FileSystem>> entries = (Set<Map.Entry<String, FileSystem>>) sigar.getFileSystemMap().entrySet(); for (Map.Entry<String, FileSystem> e : entries) { final FileSystem fs = e.getValue();
private FileSystemUsage getMountedFileSystemUsage(SigarProxy sigar, String name) throws SigarException, NfsUnreachableException { FileSystem fs = sigar.getFileSystemMap().getFileSystem(name); if (fs == null) { throw new SigarException(name + " is not a mounted filesystem"); } if (fs instanceof NfsFileSystem) { NfsFileSystem nfs = (NfsFileSystem)fs; if (!nfsPing(nfs.getHostname())) { throw nfs.getUnreachableException(); } } return sigar.getFileSystemUsage(name); }
FileSystemMap fileSystemMap = sigar.getFileSystemMap(); if (fileSystemMap != null) { fileSystem = fileSystemMap.getMountPoint(path); sigarFileSystems.put(location, fileSystem);
public static void logAvailableFilesystems(SigarProxy aSigar) { log.info("*** Logging available filesystems ***"); try { FileSystemMap map = aSigar.getFileSystemMap(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); FileSystem fs = (FileSystem) map.get(key); log.info("Filesystem: fs=" + fs.toString() + " type=" + fs.getSysTypeName()); } } catch (SigarException e) { log.warn("Can't get filesystems map", e); } }
final Set<Map.Entry<String, FileSystem>> entries = (Set<Map.Entry<String, FileSystem>>) sigar.getFileSystemMap().entrySet(); for (Map.Entry<String, FileSystem> e : entries) { final FileSystem fs = e.getValue();
public FileSystemInfo getFileSystem(String path) { String mountPoint = null; try { FileSystem mountPointForPath = sigar.getFileSystemMap().getMountPoint(path); if (mountPointForPath != null) mountPoint = mountPointForPath.getDirName(); } catch (Throwable e) { log.warn("Cannot obtain native file system information for [" + path + "]", e); // ignore native error otherwise } FileSystemInfo fileSystem = new FileSystemInfo(mountPoint); return fileSystem; }
public FileSystemInfo getFileSystem(String path) { String mountPoint = null; try { FileSystem mountPointForPath = sigar.getFileSystemMap().getMountPoint(path); if (mountPointForPath != null) mountPoint = mountPointForPath.getDirName(); } catch (Throwable e) { log.warn("Cannot obtain native file system information for [" + path + "]", e); // ignore native error otherwise } FileSystemInfo fileSystem = new FileSystemInfo(mountPoint); return fileSystem; }
FileSystemMap fileSystemMap = sigar.getFileSystemMap(); if (fileSystemMap != null) { fileSystem = fileSystemMap.getMountPoint(location.getPath()); sigarFileSystems.put(location, fileSystem);
FileSystemMap fileSystemMap = sigar.getFileSystemMap(); if (fileSystemMap != null) { fileSystem = fileSystemMap.getMountPoint(location.getPath()); sigarFileSystems.put(location, fileSystem);