use InetAddress lookup cache
This commit is contained in:
parent
ebaa725d7b
commit
7cf08bd006
|
@ -1,5 +1,8 @@
|
|||
package net.hyperic.sigar;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class NfsFileSystem extends FileSystem {
|
||||
|
||||
private static native boolean ping(String hostname);
|
||||
|
@ -11,7 +14,16 @@ public class NfsFileSystem extends FileSystem {
|
|||
String dev = getDevName();
|
||||
int ix = dev.indexOf(":");
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue