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