use InetAddress lookup cache

This commit is contained in:
Doug MacEachern 2005-02-21 02:29:14 +00:00
parent ebaa725d7b
commit 7cf08bd006
1 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,8 @@
package net.hyperic.sigar; package net.hyperic.sigar;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class NfsFileSystem extends FileSystem { public class NfsFileSystem extends FileSystem {
private static native boolean ping(String hostname); private static native boolean ping(String hostname);
@ -11,7 +14,16 @@ public class NfsFileSystem extends FileSystem {
String dev = getDevName(); String dev = getDevName();
int ix = dev.indexOf(":"); int ix = dev.indexOf(":");
if (ix != -1) { if (ix != -1) {
this.hostname = dev.substring(0, ix); String host = dev.substring(0, ix);
InetAddress addr;
//try converting to ip in java land to take
//advantage of InetAddress' lookup cache.
try {
addr = InetAddress.getByName(host);
this.hostname = addr.getHostAddress();
} catch (UnknownHostException e) {
this.hostname = host;
}
} }
} }
return this.hostname; return this.hostname;