From 6523175e559b24a2cd67aa3e3b71c5ed88459810 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 15 Mar 2005 18:07:41 +0000 Subject: [PATCH] add nfs ping to getMountedFileSystemUsage method --- bindings/java/src/net/hyperic/sigar/Sigar.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/Sigar.java b/bindings/java/src/net/hyperic/sigar/Sigar.java index a89b292c..cd8a9012 100644 --- a/bindings/java/src/net/hyperic/sigar/Sigar.java +++ b/bindings/java/src/net/hyperic/sigar/Sigar.java @@ -528,17 +528,31 @@ public class Sigar implements SigarProxy { * This method checks that the given directory is mounted. * Unlike getFileSystemUsage() which only requires that the * directory exists within a mounted file system. + * This method will also check that NFS servers are reachable via RPC + * before attempting to get the file system stats to prevent application + * hang when an NFS server is down. * @param name Name of the directory on which filesystem is mounted. - * @exception SigarException If given directory is not mounted. + * @exception SigarException If given directory is not mounted + * or NFS server is unreachable. * @see net.hyperic.sigar.Sigar#getFileSystemUsage */ public FileSystemUsage getMountedFileSystemUsage(String name) throws SigarException { - if (!getFileSystemMap().isMounted(name)) { + FileSystem fs = getFileSystemMap().getMountPoint(name); + + if (fs == null) { throw new SigarException(name + " is not a mounted filesystem"); } + if (fs instanceof NfsFileSystem) { + NfsFileSystem nfs = (NfsFileSystem)fs; + if (!nfs.ping()) { + throw new SigarException(nfs.getHostname() + ":" + name + + " nfs server unreachable"); + } + } + return FileSystemUsage.fetch(this, name); }