@Nullable SigarProxy getSigar() { if (this.sigar == null) { if (SigarAccess.isSigarAvailable()) { this.sigar = SigarAccess.getSigar(); } } return this.sigar; }
/** * Constructor for {@link NativeSystemInfo} with package scope so only the {@link SystemInfoFactory} can instantiate * this object. */ public NativeSystemInfo() { this.sigar = SigarAccess.getSigar(); }
/** * Provides the caller with direct access to the Sigar native API via a proxy to Sigar. * This provides the caller with low-level access to platform functionality. * If the Sigar native layer is not available on the platform we are running on, or if * it has been disabled by the user, an exception will be thrown. * * @return the proxy used to access the native layer * * @throws SystemInfoException if native layer is unavailable or has been disabled */ public synchronized static SigarProxy getSigar() { if (isSigarAvailable()) { if (sigarProxy == null) { invocationHandler = new SigarAccessHandler(); sigarProxy = (SigarProxy) Proxy.newProxyInstance(SigarAccess.class.getClassLoader(), new Class[] { SigarProxy.class }, invocationHandler); } return sigarProxy; } else { throw new SystemInfoException("Native layer is not available or has been disabled"); } }
/** * Constructor for {@link NativeSystemInfo} with package scope so only the {@link SystemInfoFactory} can instantiate * this object. */ public NativeSystemInfo() { this.sigar = SigarAccess.getSigar(); }
/** * Provides the caller with direct access to the Sigar native API via a proxy to Sigar. * This provides the caller with low-level access to platform functionality. * If the Sigar native layer is not available on the platform we are running on, or if * it has been disabled by the user, an exception will be thrown. * * @return the proxy used to access the native layer * * @throws SystemInfoException if native layer is unavailable or has been disabled */ public synchronized static SigarProxy getSigar() { if (isSigarAvailable()) { if (sigarProxy == null) { invocationHandler = new SigarAccessHandler(); sigarProxy = (SigarProxy) Proxy.newProxyInstance(SigarAccess.class.getClassLoader(), new Class[] { SigarProxy.class }, invocationHandler); } return sigarProxy; } else { throw new SystemInfoException("Native layer is not available or has been disabled"); } }
public ProcessInfo(long pid) throws SystemInfoException { this(pid, SigarAccess.getSigar()); }
public ProcessInfo(long pid) throws SystemInfoException { this(pid, SigarAccess.getSigar()); }
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(); 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 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); } }