|
@@ -34,6 +34,7 @@ import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
import java.util.StringTokenizer;
|
|
import java.util.StringTokenizer;
|
|
|
|
|
|
|
|
+import com.google.common.net.InetAddresses;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceStability;
|
|
import org.apache.hadoop.classification.InterfaceStability;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
@@ -77,6 +78,9 @@ public class StringUtils {
|
|
* @return the hostname to the first dot
|
|
* @return the hostname to the first dot
|
|
*/
|
|
*/
|
|
public static String simpleHostname(String fullHostname) {
|
|
public static String simpleHostname(String fullHostname) {
|
|
|
|
+ if (InetAddresses.isInetAddress(fullHostname)) {
|
|
|
|
+ return fullHostname;
|
|
|
|
+ }
|
|
int offset = fullHostname.indexOf('.');
|
|
int offset = fullHostname.indexOf('.');
|
|
if (offset != -1) {
|
|
if (offset != -1) {
|
|
return fullHostname.substring(0, offset);
|
|
return fullHostname.substring(0, offset);
|