/// <summary>Create an HttpFS Server to talk to the MiniDFSCluster we created.</summary> /// <exception cref="System.Exception"/> private void CreateHttpFSServer() { FilePath homeDir = TestDirHelper.GetTestDir(); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "conf").Mkdir()); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "log").Mkdir()); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "temp").Mkdir()); HttpFSServerWebApp.SetHomeDirForCurrentThread(homeDir.GetAbsolutePath()); FilePath secretFile = new FilePath(new FilePath(homeDir, "conf"), "secret"); TextWriter w = new FileWriter(secretFile); w.Write("secret"); w.Close(); // HDFS configuration FilePath hadoopConfDir = new FilePath(new FilePath(homeDir, "conf"), "hadoop-conf" ); if (!hadoopConfDir.Mkdirs()) { throw new IOException(); } string fsDefaultName = nnConf.Get(CommonConfigurationKeysPublic.FsDefaultNameKey); Configuration conf = new Configuration(false); conf.Set(CommonConfigurationKeysPublic.FsDefaultNameKey, fsDefaultName); // Explicitly turn off XAttr support conf.SetBoolean(DFSConfigKeys.DfsNamenodeXattrsEnabledKey, false); FilePath hdfsSite = new FilePath(hadoopConfDir, "hdfs-site.xml"); OutputStream os = new FileOutputStream(hdfsSite); conf.WriteXml(os); os.Close(); // HTTPFS configuration conf = new Configuration(false); conf.Set("httpfs.hadoop.config.dir", hadoopConfDir.ToString()); conf.Set("httpfs.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".groups" , HadoopUsersConfTestHelper.GetHadoopProxyUserGroups()); conf.Set("httpfs.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".hosts" , HadoopUsersConfTestHelper.GetHadoopProxyUserHosts()); conf.Set("httpfs.authentication.signature.secret.file", secretFile.GetAbsolutePath ()); FilePath httpfsSite = new FilePath(new FilePath(homeDir, "conf"), "httpfs-site.xml" ); os = new FileOutputStream(httpfsSite); conf.WriteXml(os); os.Close(); ClassLoader cl = Sharpen.Thread.CurrentThread().GetContextClassLoader(); Uri url = cl.GetResource("webapp"); if (url == null) { throw new IOException(); } WebAppContext context = new WebAppContext(url.AbsolutePath, "/webhdfs"); Org.Mortbay.Jetty.Server server = TestJettyHelper.GetJettyServer(); server.AddHandler(context); server.Start(); }
/// <exception cref="System.Exception"/> private void CreateHttpFSServer() { FilePath homeDir = TestDirHelper.GetTestDir(); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "conf").Mkdir()); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "log").Mkdir()); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "temp").Mkdir()); HttpFSServerWebApp.SetHomeDirForCurrentThread(homeDir.GetAbsolutePath()); FilePath secretFile = new FilePath(new FilePath(homeDir, "conf"), "secret"); TextWriter w = new FileWriter(secretFile); w.Write("secret"); w.Close(); //HDFS configuration FilePath hadoopConfDir = new FilePath(new FilePath(homeDir, "conf"), "hadoop-conf" ); hadoopConfDir.Mkdirs(); string fsDefaultName = TestHdfsHelper.GetHdfsConf().Get(CommonConfigurationKeysPublic .FsDefaultNameKey); Configuration conf = new Configuration(false); conf.Set(CommonConfigurationKeysPublic.FsDefaultNameKey, fsDefaultName); FilePath hdfsSite = new FilePath(hadoopConfDir, "hdfs-site.xml"); OutputStream os = new FileOutputStream(hdfsSite); conf.WriteXml(os); os.Close(); conf = new Configuration(false); conf.Set("httpfs.proxyuser.client.hosts", "*"); conf.Set("httpfs.proxyuser.client.groups", "*"); conf.Set("httpfs.authentication.type", "kerberos"); conf.Set("httpfs.authentication.signature.secret.file", secretFile.GetAbsolutePath ()); FilePath httpfsSite = new FilePath(new FilePath(homeDir, "conf"), "httpfs-site.xml" ); os = new FileOutputStream(httpfsSite); conf.WriteXml(os); os.Close(); ClassLoader cl = Sharpen.Thread.CurrentThread().GetContextClassLoader(); Uri url = cl.GetResource("webapp"); WebAppContext context = new WebAppContext(url.AbsolutePath, "/webhdfs"); Org.Mortbay.Jetty.Server server = TestJettyHelper.GetJettyServer(); server.AddHandler(context); server.Start(); HttpFSServerWebApp.Get().SetAuthority(TestJettyHelper.GetAuthority()); }
/// <exception cref="System.Exception"/> private void CreateHttpFSServer(bool addDelegationTokenAuthHandler) { FilePath homeDir = TestDirHelper.GetTestDir(); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "conf").Mkdir()); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "log").Mkdir()); NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "temp").Mkdir()); HttpFSServerWebApp.SetHomeDirForCurrentThread(homeDir.GetAbsolutePath()); FilePath secretFile = new FilePath(new FilePath(homeDir, "conf"), "secret"); TextWriter w = new FileWriter(secretFile); w.Write("secret"); w.Close(); //HDFS configuration FilePath hadoopConfDir = new FilePath(new FilePath(homeDir, "conf"), "hadoop-conf" ); hadoopConfDir.Mkdirs(); string fsDefaultName = TestHdfsHelper.GetHdfsConf().Get(CommonConfigurationKeysPublic .FsDefaultNameKey); Configuration conf = new Configuration(false); conf.Set(CommonConfigurationKeysPublic.FsDefaultNameKey, fsDefaultName); conf.SetBoolean(DFSConfigKeys.DfsNamenodeAclsEnabledKey, true); conf.SetBoolean(DFSConfigKeys.DfsNamenodeXattrsEnabledKey, true); FilePath hdfsSite = new FilePath(hadoopConfDir, "hdfs-site.xml"); OutputStream os = new FileOutputStream(hdfsSite); conf.WriteXml(os); os.Close(); //HTTPFS configuration conf = new Configuration(false); if (addDelegationTokenAuthHandler) { conf.Set("httpfs.authentication.type", typeof(HttpFSKerberosAuthenticationHandlerForTesting ).FullName); } conf.Set("httpfs.services.ext", typeof(TestHttpFSServer.MockGroups).FullName); conf.Set("httpfs.admin.group", HadoopUsersConfTestHelper.GetHadoopUserGroups(HadoopUsersConfTestHelper .GetHadoopUsers()[0])[0]); conf.Set("httpfs.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".groups" , HadoopUsersConfTestHelper.GetHadoopProxyUserGroups()); conf.Set("httpfs.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".hosts" , HadoopUsersConfTestHelper.GetHadoopProxyUserHosts()); conf.Set("httpfs.authentication.signature.secret.file", secretFile.GetAbsolutePath ()); conf.Set("httpfs.hadoop.config.dir", hadoopConfDir.ToString()); FilePath httpfsSite = new FilePath(new FilePath(homeDir, "conf"), "httpfs-site.xml" ); os = new FileOutputStream(httpfsSite); conf.WriteXml(os); os.Close(); ClassLoader cl = Sharpen.Thread.CurrentThread().GetContextClassLoader(); Uri url = cl.GetResource("webapp"); WebAppContext context = new WebAppContext(url.AbsolutePath, "/webhdfs"); Org.Mortbay.Jetty.Server server = TestJettyHelper.GetJettyServer(); server.AddHandler(context); server.Start(); if (addDelegationTokenAuthHandler) { HttpFSServerWebApp.Get().SetAuthority(TestJettyHelper.GetAuthority()); } }