public static void AddUserConf(Configuration conf) { conf.Set("hadoop.security.authentication", "simple"); conf.Set("hadoop.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".hosts" , HadoopUsersConfTestHelper.GetHadoopProxyUserHosts()); conf.Set("hadoop.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".groups" , HadoopUsersConfTestHelper.GetHadoopProxyUserGroups()); foreach (string user in HadoopUsersConfTestHelper.GetHadoopUsers()) { string[] groups = HadoopUsersConfTestHelper.GetHadoopUserGroups(user); UserGroupInformation.CreateUserForTesting(user, groups); } }
/// <exception cref="System.Exception"/> public override void Evaluate() { MiniDFSCluster miniHdfs = null; Configuration conf = HadoopUsersConfTestHelper.GetBaseConf(); if (System.Boolean.Parse(Runtime.GetProperty(HadoopMiniHdfs, "true"))) { miniHdfs = StartMiniHdfs(conf); conf = miniHdfs.GetConfiguration(0); } try { HdfsConfTl.Set(conf); HdfsTestDirTl.Set(ResetHdfsTestDir(conf)); statement.Evaluate(); } finally { HdfsConfTl.Remove(); HdfsTestDirTl.Remove(); } }
/// <exception cref="System.Exception"/> private static MiniDFSCluster StartMiniHdfs(Configuration conf) { lock (typeof(TestHdfsHelper)) { if (MiniDfs == null) { if (Runtime.GetProperty("hadoop.log.dir") == null) { Runtime.SetProperty("hadoop.log.dir", new FilePath(TestDirRoot, "hadoop-log").GetAbsolutePath ()); } if (Runtime.GetProperty("test.build.data") == null) { Runtime.SetProperty("test.build.data", new FilePath(TestDirRoot, "hadoop-data").GetAbsolutePath ()); } conf = new Configuration(conf); HadoopUsersConfTestHelper.AddUserConf(conf); conf.Set("fs.hdfs.impl.disable.cache", "true"); conf.Set("dfs.block.access.token.enable", "false"); conf.Set("dfs.permissions", "true"); conf.Set("hadoop.security.authentication", "simple"); conf.SetBoolean(DFSConfigKeys.DfsNamenodeAclsEnabledKey, true); conf.SetBoolean(DFSConfigKeys.DfsNamenodeXattrsEnabledKey, true); MiniDFSCluster.Builder builder = new MiniDFSCluster.Builder(conf); builder.NumDataNodes(2); MiniDFSCluster miniHdfs = builder.Build(); FileSystem fileSystem = miniHdfs.GetFileSystem(); fileSystem.Mkdirs(new Path("/tmp")); fileSystem.Mkdirs(new Path("/user")); fileSystem.SetPermission(new Path("/tmp"), FsPermission.ValueOf("-rwxrwxrwx")); fileSystem.SetPermission(new Path("/user"), FsPermission.ValueOf("-rwxrwxrwx")); MiniDfs = miniHdfs; } return(MiniDfs); } }