/** * Constructor for {@link NativeSystemInfo} with package scope so only the {@link SystemInfoFactory} can instantiate * this object. */ public NativeSystemInfo() { this.sigar = SigarAccess.getSigar(); }
/** * Constructor for {@link NativeSystemInfo} with package scope so only the {@link SystemInfoFactory} can instantiate * this object. */ public NativeSystemInfo() { this.sigar = SigarAccess.getSigar(); }
public ProcessInfo(long pid) throws SystemInfoException { this(pid, SigarAccess.getSigar()); }
public ProcessInfo(long pid) throws SystemInfoException { this(pid, SigarAccess.getSigar()); }
@Nullable SigarProxy getSigar() { if (this.sigar == null) { if (SigarAccess.isSigarAvailable()) { this.sigar = SigarAccess.getSigar(); } } return this.sigar; }
public void refresh() { SigarProxy sigar = SigarAccess.getSigar(); createFileSystemObject(sigar); try { // this is the usage data and therefore should be refreshed this.fsUsage = getMountedFileSystemUsage(sigar, this.mountPoint); this.fetchedInfo = true; } 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; this.fetchedInfo = true; 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; this.fetchedInfo = true; LOG.error("An error occurred while refreshing the usage data for file system mounted at [" + this.mountPoint + "].", e); } }
public FileSystemInfo(String mountPoint, boolean deferedFetchInfo) { this.mountPoint = mountPoint; this.fetchedInfo = false; if (!deferedFetchInfo) { refresh(); } else { SigarProxy sigar = SigarAccess.getSigar(); createFileSystemObject(sigar); } }
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); } }