Esempio n. 1
0
        public virtual void TestURIEmptyPath()
        {
            Configuration conf = new Configuration();

            ConfigUtil.AddLink(conf, "/user", new URI("file://foo"));
            FileContext.GetFileContext(FsConstants.ViewfsUri, conf);
        }
Esempio n. 2
0
 private void SetupMountPoints()
 {
     mountOnNn1 = new Path("/mountOnNn1");
     mountOnNn2 = new Path("/mountOnNn2");
     ConfigUtil.AddLink(fsViewConf, mountOnNn1.ToString(), targetTestRoot.ToUri());
     ConfigUtil.AddLink(fsViewConf, mountOnNn2.ToString(), targetTestRoot2.ToUri());
 }
Esempio n. 3
0
 public virtual void SetUp()
 {
     InitializeTargetTestRoot();
     // Make  user and data dirs - we creates links to them in the mount table
     fcTarget.Mkdir(new Path(targetTestRoot, "user"), FileContext.DefaultPerm, true);
     fcTarget.Mkdir(new Path(targetTestRoot, "data"), FileContext.DefaultPerm, true);
     fcTarget.Mkdir(new Path(targetTestRoot, "dir2"), FileContext.DefaultPerm, true);
     fcTarget.Mkdir(new Path(targetTestRoot, "dir3"), FileContext.DefaultPerm, true);
     FileContextTestHelper.CreateFile(fcTarget, new Path(targetTestRoot, "aFile"));
     // Now we use the mount fs to set links to user and dir
     // in the test root
     // Set up the defaultMT in the config with our mount point links
     conf = new Configuration();
     ConfigUtil.AddLink(conf, "/targetRoot", targetTestRoot.ToUri());
     ConfigUtil.AddLink(conf, "/user", new Path(targetTestRoot, "user").ToUri());
     ConfigUtil.AddLink(conf, "/user2", new Path(targetTestRoot, "user").ToUri());
     ConfigUtil.AddLink(conf, "/data", new Path(targetTestRoot, "data").ToUri());
     ConfigUtil.AddLink(conf, "/internalDir/linkToDir2", new Path(targetTestRoot, "dir2"
                                                                  ).ToUri());
     ConfigUtil.AddLink(conf, "/internalDir/internalDir2/linkToDir3", new Path(targetTestRoot
                                                                               , "dir3").ToUri());
     ConfigUtil.AddLink(conf, "/danglingLink", new Path(targetTestRoot, "missingTarget"
                                                        ).ToUri());
     ConfigUtil.AddLink(conf, "/linkToAFile", new Path(targetTestRoot, "aFile").ToUri(
                            ));
     fcView = FileContext.GetFileContext(FsConstants.ViewfsUri, conf);
 }
        public virtual void TestGetCanonicalServiceNameWithDefaultMountTable()
        {
            Configuration conf = new Configuration();

            ConfigUtil.AddLink(conf, "/user", new URI("file:///"));
            FileSystem viewFs      = FileSystem.Get(FsConstants.ViewfsUri, conf);
            string     serviceName = viewFs.GetCanonicalServiceName();

            NUnit.Framework.Assert.IsNull(serviceName);
        }
Esempio n. 5
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="URISyntaxException"/>
        public virtual void TestInvalidConfig()
        {
            Configuration conf = new Configuration();

            ConfigUtil.AddLink(conf, "/internalDir/linkToDir2", new Path("file:///dir2").ToUri
                                   ());
            ConfigUtil.AddLink(conf, "/internalDir/linkToDir2/linkToDir3", new Path("file:///dir3"
                                                                                    ).ToUri());
            new _InodeTree_47(conf, null);
        }
        /// <exception cref="System.Exception"/>
        private static FileSystem SetupMockFileSystem(Configuration conf, URI uri)
        {
            string scheme = uri.GetScheme();

            conf.Set("fs." + scheme + ".impl", typeof(TestChRootedFileSystem.MockFileSystem).
                     FullName);
            FileSystem fs = FileSystem.Get(uri, conf);

            ConfigUtil.AddLink(conf, "/mounts/" + scheme, uri);
            return(((TestChRootedFileSystem.MockFileSystem)fs).GetRawFileSystem());
        }
        /// <exception cref="System.Exception"/>
        internal static TestViewFileSystemDelegationTokenSupport.FakeFileSystem SetupFileSystem
            (URI uri, Type clazz)
        {
            string scheme = uri.GetScheme();

            conf.Set("fs." + scheme + ".impl", clazz.FullName);
            TestViewFileSystemDelegationTokenSupport.FakeFileSystem fs = (TestViewFileSystemDelegationTokenSupport.FakeFileSystem
                                                                          )FileSystem.Get(uri, conf);
            // mount each fs twice, will later ensure 1 token/fs
            ConfigUtil.AddLink(conf, "/mounts/" + scheme + "-one", fs.GetUri());
            ConfigUtil.AddLink(conf, "/mounts/" + scheme + "-two", fs.GetUri());
            return(fs);
        }
        /// <exception cref="System.Exception"/>
        internal static TestViewFileSystemDelegation.FakeFileSystem SetupFileSystem(URI uri
                                                                                    , Type clazz)
        {
            string scheme = uri.GetScheme();

            conf.Set("fs." + scheme + ".impl", clazz.FullName);
            TestViewFileSystemDelegation.FakeFileSystem fs = (TestViewFileSystemDelegation.FakeFileSystem
                                                              )FileSystem.Get(uri, conf);
            Assert.Equal(uri, fs.GetUri());
            Path targetPath = new FileSystemTestHelper().GetAbsoluteTestRootPath(fs);

            ConfigUtil.AddLink(conf, "/mounts/" + scheme, targetPath.ToUri());
            return(fs);
        }
 internal virtual void SetupMountPoints()
 {
     ConfigUtil.AddLink(conf, "/targetRoot", targetTestRoot.ToUri());
     ConfigUtil.AddLink(conf, "/user", new Path(targetTestRoot, "user").ToUri());
     ConfigUtil.AddLink(conf, "/user2", new Path(targetTestRoot, "user").ToUri());
     ConfigUtil.AddLink(conf, "/data", new Path(targetTestRoot, "data").ToUri());
     ConfigUtil.AddLink(conf, "/internalDir/linkToDir2", new Path(targetTestRoot, "dir2"
                                                                  ).ToUri());
     ConfigUtil.AddLink(conf, "/internalDir/internalDir2/linkToDir3", new Path(targetTestRoot
                                                                               , "dir3").ToUri());
     ConfigUtil.AddLink(conf, "/danglingLink", new Path(targetTestRoot, "missingTarget"
                                                        ).ToUri());
     ConfigUtil.AddLink(conf, "/linkToAFile", new Path(targetTestRoot, "aFile").ToUri(
                            ));
 }
Esempio n. 10
0
        /*
         * Set up link in config for first component of path to the same
         * in the target file system.
         */
        internal static void LinkUpFirstComponents(Configuration conf, string path, FileContext
                                                   fsTarget, string info)
        {
            int indexOfEnd = path.IndexOf('/', 1);

            if (Shell.Windows)
            {
                indexOfEnd = path.IndexOf('/', indexOfEnd + 1);
            }
            string firstComponent = Runtime.Substring(path, 0, indexOfEnd);
            URI    linkTarget     = fsTarget.MakeQualified(new Path(firstComponent)).ToUri();

            ConfigUtil.AddLink(conf, firstComponent, linkTarget);
            Org.Mortbay.Log.Log.Info("Added link for " + info + " " + firstComponent + "->" +
                                     linkTarget);
        }
Esempio n. 11
0
        public static void ClusterSetupAtBegining()
        {
            cluster = new MiniDFSCluster.Builder(Conf).NumDataNodes(2).Build();
            cluster.WaitClusterUp();
            fHdfs = cluster.GetFileSystem();
            defaultWorkingDirectory = fHdfs.MakeQualified(new Path("/user/" + UserGroupInformation
                                                                   .GetCurrentUser().GetShortUserName()));
            fHdfs.Mkdirs(defaultWorkingDirectory);
            // Setup the ViewFS to be used for all tests.
            Configuration conf = ViewFileSystemTestSetup.CreateConfig();

            ConfigUtil.AddLink(conf, "/vfstmp", new URI(fHdfs.GetUri() + "/hdfstmp"));
            ConfigUtil.AddLink(conf, "/tmp", new URI(fHdfs.GetUri() + "/tmp"));
            vfs = FileSystem.Get(FsConstants.ViewfsUri, conf);
            NUnit.Framework.Assert.AreEqual(typeof(ViewFileSystem), vfs.GetType());
        }
        public virtual void TestListLocatedFileStatus()
        {
            Path          mockMount = new Path("mockfs://foo/user");
            Path          mockPath  = new Path("/usermock");
            Configuration conf      = new Configuration();

            conf.SetClass("fs.mockfs.impl", typeof(TestChRootedFileSystem.MockFileSystem), typeof(
                              FileSystem));
            ConfigUtil.AddLink(conf, mockPath.ToString(), mockMount.ToUri());
            FileSystem vfs = FileSystem.Get(URI.Create("viewfs:///"), conf);

            vfs.ListLocatedStatus(mockPath);
            FileSystem mockFs = ((TestChRootedFileSystem.MockFileSystem)mockMount.GetFileSystem
                                     (conf)).GetRawFileSystem();

            Org.Mockito.Mockito.Verify(mockFs).ListLocatedStatus(new Path(mockMount.ToUri().GetPath
                                                                              ()));
        }
Esempio n. 13
0
        public virtual void TestFileStatusSerialziation()
        {
            string testfilename = "testFileStatusSerialziation";

            TestDir.Mkdirs();
            FilePath infile = new FilePath(TestDir, testfilename);

            byte[]           content = Runtime.GetBytesForString("dingos");
            FileOutputStream fos     = null;

            try
            {
                fos = new FileOutputStream(infile);
                fos.Write(content);
            }
            finally
            {
                if (fos != null)
                {
                    fos.Close();
                }
            }
            Assert.Equal((long)content.Length, infile.Length());
            Configuration conf = new Configuration();

            ConfigUtil.AddLink(conf, "/foo/bar/baz", TestDir.ToURI());
            FileSystem vfs = FileSystem.Get(FsConstants.ViewfsUri, conf);

            Assert.Equal(typeof(ViewFileSystem), vfs.GetType());
            FileStatus stat = vfs.GetFileStatus(new Path("/foo/bar/baz", testfilename));

            Assert.Equal(content.Length, stat.GetLen());
            // check serialization/deserialization
            DataOutputBuffer dob = new DataOutputBuffer();

            stat.Write(dob);
            DataInputBuffer dib = new DataInputBuffer();

            dib.Reset(dob.GetData(), 0, dob.GetLength());
            FileStatus deSer = new FileStatus();

            deSer.ReadFields(dib);
            Assert.Equal(content.Length, deSer.GetLen());
        }
Esempio n. 14
0
        internal static void SetUpHomeDir(Configuration conf, FileContext fsTarget)
        {
            string homeDir         = fsTarget.GetHomeDirectory().ToUri().GetPath();
            int    indexOf2ndSlash = homeDir.IndexOf('/', 1);

            if (indexOf2ndSlash > 0)
            {
                LinkUpFirstComponents(conf, homeDir, fsTarget, "home dir");
            }
            else
            {
                // home dir is at root. Just link the home dir itse
                URI linkTarget = fsTarget.MakeQualified(new Path(homeDir)).ToUri();
                ConfigUtil.AddLink(conf, homeDir, linkTarget);
                Org.Mortbay.Log.Log.Info("Added link for home dir " + homeDir + "->" + linkTarget
                                         );
            }
            // Now set the root of the home dir for viewfs
            string homeDirRoot = fsTarget.GetHomeDirectory().GetParent().ToUri().GetPath();

            ConfigUtil.SetHomeDirConf(conf, homeDirRoot);
            Org.Mortbay.Log.Log.Info("Home dir base for viewfs" + homeDirRoot);
        }
 internal override void SetupMountPoints()
 {
     base.SetupMountPoints();
     ConfigUtil.AddLink(conf, "/mountOnNn2", new Path(targetTestRoot2, "mountOnNn2").ToUri
                            ());
 }