public virtual void TestNormalizeHostName() { IList <string> hosts = Arrays.AsList(new string[] { "127.0.0.1", "localhost", "1.kanyezone.appspot.com" , "UnknownHost123" }); IList <string> normalizedHosts = NetUtils.NormalizeHostNames(hosts); // when ipaddress is normalized, same address is expected in return Assert.Equal(normalizedHosts[0], hosts[0]); // for normalizing a resolvable hostname, resolved ipaddress is expected in return NUnit.Framework.Assert.IsFalse(normalizedHosts[1].Equals(hosts[1])); Assert.Equal(normalizedHosts[1], hosts[0]); // this address HADOOP-8372: when normalizing a valid resolvable hostname start with numeric, // its ipaddress is expected to return NUnit.Framework.Assert.IsFalse(normalizedHosts[2].Equals(hosts[2])); // return the same hostname after normalizing a irresolvable hostname. Assert.Equal(normalizedHosts[3], hosts[3]); }
public override IList <string> Resolve(IList <string> names) { // normalize all input names to be in the form of IP addresses names = NetUtils.NormalizeHostNames(names); IList <string> result = new AList <string>(names.Count); if (names.IsEmpty()) { return(result); } IList <string> uncachedHosts = GetUncachedHosts(names); // Resolve the uncached hosts IList <string> resolvedHosts = rawMapping.Resolve(uncachedHosts); //cache them CacheResolvedHosts(uncachedHosts, resolvedHosts); //now look up the entire list in the cache return(GetCachedHosts(names)); }