public virtual void TestHttpPolicy() { conf.Set(DFSConfigKeys.DfsHttpPolicyKey, policy.ToString()); conf.Set(DFSConfigKeys.DfsNamenodeHttpsAddressKey, "localhost:0"); IPEndPoint addr = IPEndPoint.CreateUnresolved("localhost", 0); NameNodeHttpServer server = null; try { server = new NameNodeHttpServer(conf, null, addr); server.Start(); NUnit.Framework.Assert.IsTrue(Implies(policy.IsHttpEnabled(), CanAccess("http", server .GetHttpAddress()))); NUnit.Framework.Assert.IsTrue(Implies(!policy.IsHttpEnabled(), server.GetHttpAddress () == null)); NUnit.Framework.Assert.IsTrue(Implies(policy.IsHttpsEnabled(), CanAccess("https", server.GetHttpsAddress()))); NUnit.Framework.Assert.IsTrue(Implies(!policy.IsHttpsEnabled(), server.GetHttpsAddress () == null)); } finally { if (server != null) { server.Stop(); } } }
/// <exception cref="System.IO.IOException"/> public virtual void TestStartLocalizer() { IPEndPoint address = IPEndPoint.CreateUnresolved("localhost", 8040); Path nmPrivateCTokensPath = new Path("file:///bin/nmPrivateCTokensPath"); try { mockExec.StartLocalizer(nmPrivateCTokensPath, address, "test", "application_0", "12345" , dirsHandler); IList <string> result = ReadMockParams(); NUnit.Framework.Assert.AreEqual(result.Count, 17); NUnit.Framework.Assert.AreEqual(result[0], YarnConfiguration.DefaultNmNonsecureModeLocalUser ); NUnit.Framework.Assert.AreEqual(result[1], "test"); NUnit.Framework.Assert.AreEqual(result[2], "0"); NUnit.Framework.Assert.AreEqual(result[3], "application_0"); NUnit.Framework.Assert.AreEqual(result[4], "/bin/nmPrivateCTokensPath"); NUnit.Framework.Assert.AreEqual(result[8], "-classpath"); NUnit.Framework.Assert.AreEqual(result[11], "org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.ContainerLocalizer" ); NUnit.Framework.Assert.AreEqual(result[12], "test"); NUnit.Framework.Assert.AreEqual(result[13], "application_0"); NUnit.Framework.Assert.AreEqual(result[14], "12345"); NUnit.Framework.Assert.AreEqual(result[15], "localhost"); NUnit.Framework.Assert.AreEqual(result[16], "8040"); } catch (Exception e) { Log.Error("Error:" + e.Message, e); NUnit.Framework.Assert.Fail(); } }
/// <summary> /// Set the proxy of this socket factory as described in the string /// parameter /// </summary> /// <param name="proxyStr">the proxy address using the format "host:port"</param> private void SetProxy(string proxyStr) { string[] strs = proxyStr.Split(":", 2); if (strs.Length != 2) { throw new RuntimeException("Bad SOCKS proxy parameter: " + proxyStr); } string host = strs[0]; int port = System.Convert.ToInt32(strs[1]); this.proxy = new Proxy(Proxy.Type.Socks, IPEndPoint.CreateUnresolved(host, port)); }
/// <summary>Create a socket address with the given host and port.</summary> /// <remarks> /// Create a socket address with the given host and port. The hostname /// might be replaced with another host that was set via /// <see cref="AddStaticResolution(string, string)"/> /// . The value of /// hadoop.security.token.service.use_ip will determine whether the /// standard java host resolver is used, or if the fully qualified resolver /// is used. /// </remarks> /// <param name="host">the hostname or IP use to instantiate the object</param> /// <param name="port">the port number</param> /// <returns>InetSocketAddress</returns> public static IPEndPoint CreateSocketAddrForHost(string host, int port) { string staticHost = GetStaticResolution(host); string resolveHost = (staticHost != null) ? staticHost : host; IPEndPoint addr; try { IPAddress iaddr = SecurityUtil.GetByName(resolveHost); // if there is a static entry for the host, make the returned // address look like the original given host if (staticHost != null) { iaddr = IPAddress.GetByAddress(host, iaddr.GetAddressBytes()); } addr = new IPEndPoint(iaddr, port); } catch (UnknownHostException) { addr = IPEndPoint.CreateUnresolved(host, port); } return(addr); }