Exemple #1
0
        public virtual void TestFcResolveAfs()
        {
            Configuration conf           = new Configuration();
            FileContext   fcLocal        = FileContext.GetLocalFSFileContext();
            FileContext   fcHdfs         = FileContext.GetFileContext(cluster.GetFileSystem().GetUri());
            string        localTestRoot  = helper.GetAbsoluteTestRootDir(fcLocal);
            Path          alphaLocalPath = new Path(fcLocal.GetDefaultFileSystem().GetUri().ToString()
                                                    , new FilePath(localTestRoot, "alpha").GetAbsolutePath());

            DFSTestUtil.CreateFile(FileSystem.GetLocal(conf), alphaLocalPath, 16, (short)1, 2
                                   );
            Path linkTarget = new Path(fcLocal.GetDefaultFileSystem().GetUri().ToString(), localTestRoot
                                       );
            Path hdfsLink = new Path(fcHdfs.GetDefaultFileSystem().GetUri().ToString(), "/tmp/link"
                                     );

            fcHdfs.CreateSymlink(linkTarget, hdfsLink, true);
            Path alphaHdfsPathViaLink = new Path(fcHdfs.GetDefaultFileSystem().GetUri().ToString
                                                     () + "/tmp/link/alpha");
            ICollection <AbstractFileSystem> afsList = fcHdfs.ResolveAbstractFileSystems(alphaHdfsPathViaLink
                                                                                         );

            NUnit.Framework.Assert.AreEqual(2, afsList.Count);
            foreach (AbstractFileSystem afs in afsList)
            {
                if ((!afs.Equals(fcHdfs.GetDefaultFileSystem())) && (!afs.Equals(fcLocal.GetDefaultFileSystem
                                                                                     ())))
                {
                    NUnit.Framework.Assert.Fail("Failed to resolve AFS correctly");
                }
            }
        }