Ejemplo n.º 1
0
            /// <exception cref="System.Exception"/>
            public Void Run()
            {
                string       path = ServletUtil.GetDecodedPath(request, "/contentSummary");
                PrintWriter  @out = response.GetWriter();
                XMLOutputter xml  = new XMLOutputter(@out, "UTF-8");

                xml.Declaration();
                try
                {
                    ClientProtocol nnproxy = this._enclosing.CreateNameNodeProxy();
                    ContentSummary cs      = nnproxy.GetContentSummary(path);
                    xml.StartTag(typeof(ContentSummary).FullName);
                    if (cs != null)
                    {
                        xml.Attribute("length", string.Empty + cs.GetLength());
                        xml.Attribute("fileCount", string.Empty + cs.GetFileCount());
                        xml.Attribute("directoryCount", string.Empty + cs.GetDirectoryCount());
                        xml.Attribute("quota", string.Empty + cs.GetQuota());
                        xml.Attribute("spaceConsumed", string.Empty + cs.GetSpaceConsumed());
                        xml.Attribute("spaceQuota", string.Empty + cs.GetSpaceQuota());
                    }
                    xml.EndTag();
                }
                catch (IOException ioe)
                {
                    this._enclosing.WriteXml(ioe, path, xml);
                }
                xml.EndDocument();
                return(null);
            }
Ejemplo n.º 2
0
        /// <exception cref="System.Exception"/>
        private void TestContentSummary()
        {
            FileSystem   fs   = FileSystem.Get(GetProxiedFSConf());
            Path         path = new Path(GetProxiedFSTestDir(), "foo.txt");
            OutputStream os   = fs.Create(path);

            os.Write(1);
            os.Close();
            ContentSummary hdfsContentSummary = fs.GetContentSummary(path);

            fs.Close();
            fs = GetHttpFSFileSystem();
            ContentSummary httpContentSummary = fs.GetContentSummary(path);

            fs.Close();
            NUnit.Framework.Assert.AreEqual(httpContentSummary.GetDirectoryCount(), hdfsContentSummary
                                            .GetDirectoryCount());
            NUnit.Framework.Assert.AreEqual(httpContentSummary.GetFileCount(), hdfsContentSummary
                                            .GetFileCount());
            NUnit.Framework.Assert.AreEqual(httpContentSummary.GetLength(), hdfsContentSummary
                                            .GetLength());
            NUnit.Framework.Assert.AreEqual(httpContentSummary.GetQuota(), hdfsContentSummary
                                            .GetQuota());
            NUnit.Framework.Assert.AreEqual(httpContentSummary.GetSpaceConsumed(), hdfsContentSummary
                                            .GetSpaceConsumed());
            NUnit.Framework.Assert.AreEqual(httpContentSummary.GetSpaceQuota(), hdfsContentSummary
                                            .GetSpaceQuota());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Test that quotas are properly tracked by the standby through
        /// create, append, delete.
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestQuotasTrackedOnStandby()
        {
            fs.Mkdirs(TestDir);
            DistributedFileSystem dfs = (DistributedFileSystem)fs;

            dfs.SetQuota(TestDir, NsQuota, DsQuota);
            long expectedSize = 3 * BlockSize + BlockSize / 2;

            DFSTestUtil.CreateFile(fs, TestFile, expectedSize, (short)1, 1L);
            HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
            ContentSummary cs = nn1.GetRpcServer().GetContentSummary(TestDirStr);

            NUnit.Framework.Assert.AreEqual(NsQuota, cs.GetQuota());
            NUnit.Framework.Assert.AreEqual(DsQuota, cs.GetSpaceQuota());
            NUnit.Framework.Assert.AreEqual(expectedSize, cs.GetSpaceConsumed());
            NUnit.Framework.Assert.AreEqual(1, cs.GetDirectoryCount());
            NUnit.Framework.Assert.AreEqual(1, cs.GetFileCount());
            // Append to the file and make sure quota is updated correctly.
            FSDataOutputStream stm = fs.Append(TestFile);

            try
            {
                byte[] data = new byte[(int)(BlockSize * 3 / 2)];
                stm.Write(data);
                expectedSize += data.Length;
            }
            finally
            {
                IOUtils.CloseStream(stm);
            }
            HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
            cs = nn1.GetRpcServer().GetContentSummary(TestDirStr);
            NUnit.Framework.Assert.AreEqual(NsQuota, cs.GetQuota());
            NUnit.Framework.Assert.AreEqual(DsQuota, cs.GetSpaceQuota());
            NUnit.Framework.Assert.AreEqual(expectedSize, cs.GetSpaceConsumed());
            NUnit.Framework.Assert.AreEqual(1, cs.GetDirectoryCount());
            NUnit.Framework.Assert.AreEqual(1, cs.GetFileCount());
            fs.Delete(TestFile, true);
            expectedSize = 0;
            HATestUtil.WaitForStandbyToCatchUp(nn0, nn1);
            cs = nn1.GetRpcServer().GetContentSummary(TestDirStr);
            NUnit.Framework.Assert.AreEqual(NsQuota, cs.GetQuota());
            NUnit.Framework.Assert.AreEqual(DsQuota, cs.GetSpaceQuota());
            NUnit.Framework.Assert.AreEqual(expectedSize, cs.GetSpaceConsumed());
            NUnit.Framework.Assert.AreEqual(1, cs.GetDirectoryCount());
            NUnit.Framework.Assert.AreEqual(0, cs.GetFileCount());
        }
Ejemplo n.º 4
0
        public virtual void TestGetContentSummary()
        {
            // GetContentSummary of a dir
            fSys.Mkdirs(new Path("/newDir/dirFoo"));
            ContentSummary cs = fSys.GetContentSummary(new Path("/newDir/dirFoo"));

            Assert.Equal(-1L, cs.GetQuota());
            Assert.Equal(-1L, cs.GetSpaceQuota());
        }
Ejemplo n.º 5
0
        /// <summary>Convert a ContentSummary to a Json string.</summary>
        public static string ToJsonString(ContentSummary contentsummary)
        {
            if (contentsummary == null)
            {
                return(null);
            }
            IDictionary <string, object> m = new SortedDictionary <string, object>();

            m["length"]         = contentsummary.GetLength();
            m["fileCount"]      = contentsummary.GetFileCount();
            m["directoryCount"] = contentsummary.GetDirectoryCount();
            m["quota"]          = contentsummary.GetQuota();
            m["spaceConsumed"]  = contentsummary.GetSpaceConsumed();
            m["spaceQuota"]     = contentsummary.GetSpaceQuota();
            return(ToJsonString(typeof(ContentSummary), m));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Converts a <code>ContentSummary</code> object into a JSON array
        /// object.
        /// </summary>
        /// <param name="contentSummary">the content summary</param>
        /// <returns>The JSON representation of the content summary.</returns>
        private static IDictionary ContentSummaryToJSON(ContentSummary contentSummary)
        {
            IDictionary json = new LinkedHashMap();

            json[HttpFSFileSystem.ContentSummaryDirectoryCountJson] = contentSummary.GetDirectoryCount
                                                                          ();
            json[HttpFSFileSystem.ContentSummaryFileCountJson] = contentSummary.GetFileCount(
                );
            json[HttpFSFileSystem.ContentSummaryLengthJson]        = contentSummary.GetLength();
            json[HttpFSFileSystem.ContentSummaryQuotaJson]         = contentSummary.GetQuota();
            json[HttpFSFileSystem.ContentSummarySpaceConsumedJson] = contentSummary.GetSpaceConsumed
                                                                         ();
            json[HttpFSFileSystem.ContentSummarySpaceQuotaJson] = contentSummary.GetSpaceQuota
                                                                      ();
            IDictionary response = new LinkedHashMap();

            response[HttpFSFileSystem.ContentSummaryJson] = json;
            return(response);
        }
Ejemplo n.º 7
0
        public virtual void TestQuotaCommands()
        {
            Configuration conf = new HdfsConfiguration();
            // set a smaller block size so that we can test with smaller
            // Space quotas
            int DefaultBlockSize = 512;

            conf.SetLong(DFSConfigKeys.DfsBlockSizeKey, DefaultBlockSize);
            // Make it relinquish locks. When run serially, the result should
            // be identical.
            conf.SetInt(DFSConfigKeys.DfsContentSummaryLimitKey, 2);
            MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(2).Build();
            FileSystem     fs      = cluster.GetFileSystem();

            NUnit.Framework.Assert.IsTrue("Not a HDFS: " + fs.GetUri(), fs is DistributedFileSystem
                                          );
            DistributedFileSystem dfs = (DistributedFileSystem)fs;
            DFSAdmin admin            = new DFSAdmin(conf);

            try
            {
                int   fileLen     = 1024;
                short replication = 5;
                long  spaceQuota  = fileLen * replication * 15 / 8;
                // 1: create a directory /test and set its quota to be 3
                Path parent = new Path("/test");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(parent));
                string[] args = new string[] { "-setQuota", "3", parent.ToString() };
                RunCommand(admin, args, false);
                //try setting space quota with a 'binary prefix'
                RunCommand(admin, false, "-setSpaceQuota", "2t", parent.ToString());
                NUnit.Framework.Assert.AreEqual(2L << 40, dfs.GetContentSummary(parent).GetSpaceQuota
                                                    ());
                // set diskspace quota to 10000
                RunCommand(admin, false, "-setSpaceQuota", System.Convert.ToString(spaceQuota), parent
                           .ToString());
                // 2: create directory /test/data0
                Path childDir0 = new Path(parent, "data0");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(childDir0));
                // 3: create a file /test/datafile0
                Path childFile0 = new Path(parent, "datafile0");
                DFSTestUtil.CreateFile(fs, childFile0, fileLen, replication, 0);
                // 4: count -q /test
                ContentSummary c = dfs.GetContentSummary(parent);
                NUnit.Framework.Assert.AreEqual(c.GetFileCount() + c.GetDirectoryCount(), 3);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 3);
                NUnit.Framework.Assert.AreEqual(c.GetSpaceConsumed(), fileLen * replication);
                NUnit.Framework.Assert.AreEqual(c.GetSpaceQuota(), spaceQuota);
                // 5: count -q /test/data0
                c = dfs.GetContentSummary(childDir0);
                NUnit.Framework.Assert.AreEqual(c.GetFileCount() + c.GetDirectoryCount(), 1);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), -1);
                // check disk space consumed
                c = dfs.GetContentSummary(parent);
                NUnit.Framework.Assert.AreEqual(c.GetSpaceConsumed(), fileLen * replication);
                // 6: create a directory /test/data1
                Path childDir1    = new Path(parent, "data1");
                bool hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Mkdirs(childDir1));
                }
                catch (QuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                OutputStream fout;
                // 7: create a file /test/datafile1
                Path childFile1 = new Path(parent, "datafile1");
                hasException = false;
                try
                {
                    fout = dfs.Create(childFile1);
                }
                catch (QuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                // 8: clear quota /test
                RunCommand(admin, new string[] { "-clrQuota", parent.ToString() }, false);
                c = dfs.GetContentSummary(parent);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), -1);
                NUnit.Framework.Assert.AreEqual(c.GetSpaceQuota(), spaceQuota);
                // 9: clear quota /test/data0
                RunCommand(admin, new string[] { "-clrQuota", childDir0.ToString() }, false);
                c = dfs.GetContentSummary(childDir0);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), -1);
                // 10: create a file /test/datafile1
                fout = dfs.Create(childFile1, replication);
                // 10.s: but writing fileLen bytes should result in an quota exception
                try
                {
                    fout.Write(new byte[fileLen]);
                    fout.Close();
                    NUnit.Framework.Assert.Fail();
                }
                catch (QuotaExceededException)
                {
                    IOUtils.CloseStream(fout);
                }
                //delete the file
                dfs.Delete(childFile1, false);
                // 9.s: clear diskspace quota
                RunCommand(admin, false, "-clrSpaceQuota", parent.ToString());
                c = dfs.GetContentSummary(parent);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), -1);
                NUnit.Framework.Assert.AreEqual(c.GetSpaceQuota(), -1);
                // now creating childFile1 should succeed
                DFSTestUtil.CreateFile(dfs, childFile1, fileLen, replication, 0);
                // 11: set the quota of /test to be 1
                // HADOOP-5872 - we can set quota even if it is immediately violated
                args = new string[] { "-setQuota", "1", parent.ToString() };
                RunCommand(admin, args, false);
                RunCommand(admin, false, "-setSpaceQuota", Sharpen.Extensions.ToString(fileLen),
                           args[2]);
                // for space quota
                // 12: set the quota of /test/data0 to be 1
                args = new string[] { "-setQuota", "1", childDir0.ToString() };
                RunCommand(admin, args, false);
                // 13: not able create a directory under data0
                hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Mkdirs(new Path(childDir0, "in")));
                }
                catch (QuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                c = dfs.GetContentSummary(childDir0);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount() + c.GetFileCount(), 1);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 1);
                // 14a: set quota on a non-existent directory
                Path nonExistentPath = new Path("/test1");
                NUnit.Framework.Assert.IsFalse(dfs.Exists(nonExistentPath));
                args = new string[] { "-setQuota", "1", nonExistentPath.ToString() };
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-setSpaceQuota", "1g", nonExistentPath.ToString());
                // for space quota
                // 14b: set quota on a file
                NUnit.Framework.Assert.IsTrue(dfs.IsFile(childFile0));
                args[1] = childFile0.ToString();
                RunCommand(admin, args, true);
                // same for space quota
                RunCommand(admin, true, "-setSpaceQuota", "1t", args[1]);
                // 15a: clear quota on a file
                args[0] = "-clrQuota";
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-clrSpaceQuota", args[1]);
                // 15b: clear quota on a non-existent directory
                args[1] = nonExistentPath.ToString();
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-clrSpaceQuota", args[1]);
                // 16a: set the quota of /test to be 0
                args = new string[] { "-setQuota", "0", parent.ToString() };
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-setSpaceQuota", "0", args[2]);
                // 16b: set the quota of /test to be -1
                args[1] = "-1";
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-setSpaceQuota", args[1], args[2]);
                // 16c: set the quota of /test to be Long.MAX_VALUE+1
                args[1] = (long.MaxValue + 1L).ToString();
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-setSpaceQuota", args[1], args[2]);
                // 16d: set the quota of /test to be a non integer
                args[1] = "33aa1.5";
                RunCommand(admin, args, true);
                RunCommand(admin, true, "-setSpaceQuota", args[1], args[2]);
                // 16e: set space quota with a value larger than Long.MAX_VALUE
                RunCommand(admin, true, "-setSpaceQuota", (long.MaxValue / 1024 / 1024 + 1024) +
                           "m", args[2]);
                // 17:  setQuota by a non-administrator
                string username          = "******";
                UserGroupInformation ugi = UserGroupInformation.CreateUserForTesting(username, new
                                                                                     string[] { "groupyy" });
                string[] args2 = args.MemberwiseClone();
                // need final ref for doAs block
                ugi.DoAs(new _PrivilegedExceptionAction_275(this, username, conf, args2, parent));
                // 18: clrQuota by a non-administrator
                // 19: clrQuota on the root directory ("/") should fail
                RunCommand(admin, true, "-clrQuota", "/");
                // 20: setQuota on the root directory ("/") should succeed
                RunCommand(admin, false, "-setQuota", "1000000", "/");
                RunCommand(admin, true, "-clrQuota", "/");
                RunCommand(admin, false, "-clrSpaceQuota", "/");
                RunCommand(admin, new string[] { "-clrQuota", parent.ToString() }, false);
                RunCommand(admin, false, "-clrSpaceQuota", parent.ToString());
                // 2: create directory /test/data2
                Path childDir2 = new Path(parent, "data2");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(childDir2));
                Path childFile2  = new Path(childDir2, "datafile2");
                Path childFile3  = new Path(childDir2, "datafile3");
                long spaceQuota2 = DefaultBlockSize * replication;
                long fileLen2    = DefaultBlockSize;
                // set space quota to a real low value
                RunCommand(admin, false, "-setSpaceQuota", System.Convert.ToString(spaceQuota2),
                           childDir2.ToString());
                // clear space quota
                RunCommand(admin, false, "-clrSpaceQuota", childDir2.ToString());
                // create a file that is greater than the size of space quota
                DFSTestUtil.CreateFile(fs, childFile2, fileLen2, replication, 0);
                // now set space quota again. This should succeed
                RunCommand(admin, false, "-setSpaceQuota", System.Convert.ToString(spaceQuota2),
                           childDir2.ToString());
                hasException = false;
                try
                {
                    DFSTestUtil.CreateFile(fs, childFile3, fileLen2, replication, 0);
                }
                catch (DSQuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                // now test the same for root
                Path childFile4 = new Path("/", "datafile2");
                Path childFile5 = new Path("/", "datafile3");
                RunCommand(admin, true, "-clrQuota", "/");
                RunCommand(admin, false, "-clrSpaceQuota", "/");
                // set space quota to a real low value
                RunCommand(admin, false, "-setSpaceQuota", System.Convert.ToString(spaceQuota2),
                           "/");
                RunCommand(admin, false, "-clrSpaceQuota", "/");
                DFSTestUtil.CreateFile(fs, childFile4, fileLen2, replication, 0);
                RunCommand(admin, false, "-setSpaceQuota", System.Convert.ToString(spaceQuota2),
                           "/");
                hasException = false;
                try
                {
                    DFSTestUtil.CreateFile(fs, childFile5, fileLen2, replication, 0);
                }
                catch (DSQuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                NUnit.Framework.Assert.AreEqual(4, cluster.GetNamesystem().GetFSDirectory().GetYieldCount
                                                    ());
            }
            finally
            {
                cluster.Shutdown();
            }
        }
Ejemplo n.º 8
0
        public virtual void TestNamespaceCommands()
        {
            Configuration conf = new HdfsConfiguration();

            // Make it relinquish locks. When run serially, the result should
            // be identical.
            conf.SetInt(DFSConfigKeys.DfsContentSummaryLimitKey, 2);
            MiniDFSCluster        cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(2).Build();
            DistributedFileSystem dfs     = cluster.GetFileSystem();

            try
            {
                // 1: create directory /nqdir0/qdir1/qdir20/nqdir30
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(new Path("/nqdir0/qdir1/qdir20/nqdir30")
                                                         ));
                // 2: set the quota of /nqdir0/qdir1 to be 6
                Path quotaDir1 = new Path("/nqdir0/qdir1");
                dfs.SetQuota(quotaDir1, 6, HdfsConstants.QuotaDontSet);
                ContentSummary c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 3);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                // 3: set the quota of /nqdir0/qdir1/qdir20 to be 7
                Path quotaDir2 = new Path("/nqdir0/qdir1/qdir20");
                dfs.SetQuota(quotaDir2, 7, HdfsConstants.QuotaDontSet);
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 2);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                // 4: Create directory /nqdir0/qdir1/qdir21 and set its quota to 2
                Path quotaDir3 = new Path("/nqdir0/qdir1/qdir21");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(quotaDir3));
                dfs.SetQuota(quotaDir3, 2, HdfsConstants.QuotaDontSet);
                c = dfs.GetContentSummary(quotaDir3);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 1);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 2);
                // 5: Create directory /nqdir0/qdir1/qdir21/nqdir32
                Path tempPath = new Path(quotaDir3, "nqdir32");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(tempPath));
                c = dfs.GetContentSummary(quotaDir3);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 2);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 2);
                // 6: Create directory /nqdir0/qdir1/qdir21/nqdir33
                tempPath = new Path(quotaDir3, "nqdir33");
                bool hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Mkdirs(tempPath));
                }
                catch (NSQuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                c = dfs.GetContentSummary(quotaDir3);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 2);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 2);
                // 7: Create directory /nqdir0/qdir1/qdir20/nqdir31
                tempPath = new Path(quotaDir2, "nqdir31");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(tempPath));
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 3);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 6);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                // 8: Create directory /nqdir0/qdir1/qdir20/nqdir33
                tempPath     = new Path(quotaDir2, "nqdir33");
                hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Mkdirs(tempPath));
                }
                catch (NSQuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                // 9: Move /nqdir0/qdir1/qdir21/nqdir32 /nqdir0/qdir1/qdir20/nqdir30
                tempPath = new Path(quotaDir2, "nqdir30");
                dfs.Rename(new Path(quotaDir3, "nqdir32"), tempPath);
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 4);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 6);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                // 10: Move /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0/qdir1/qdir21
                hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Rename(tempPath, quotaDir3));
                }
                catch (NSQuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                NUnit.Framework.Assert.IsTrue(dfs.Exists(tempPath));
                NUnit.Framework.Assert.IsFalse(dfs.Exists(new Path(quotaDir3, "nqdir30")));
                // 10.a: Rename /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0/qdir1/qdir21/nqdir32
                hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Rename(tempPath, new Path(quotaDir3, "nqdir32"
                                                                                 )));
                }
                catch (QuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                NUnit.Framework.Assert.IsTrue(dfs.Exists(tempPath));
                NUnit.Framework.Assert.IsFalse(dfs.Exists(new Path(quotaDir3, "nqdir32")));
                // 11: Move /nqdir0/qdir1/qdir20/nqdir30 to /nqdir0
                NUnit.Framework.Assert.IsTrue(dfs.Rename(tempPath, new Path("/nqdir0")));
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 2);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 4);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                // 12: Create directory /nqdir0/nqdir30/nqdir33
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(new Path("/nqdir0/nqdir30/nqdir33")));
                // 13: Move /nqdir0/nqdir30 /nqdir0/qdir1/qdir20/qdir30
                hasException = false;
                try
                {
                    NUnit.Framework.Assert.IsFalse(dfs.Rename(new Path("/nqdir0/nqdir30"), tempPath));
                }
                catch (NSQuotaExceededException)
                {
                    hasException = true;
                }
                NUnit.Framework.Assert.IsTrue(hasException);
                // 14: Move /nqdir0/qdir1/qdir21 /nqdir0/qdir1/qdir20
                NUnit.Framework.Assert.IsTrue(dfs.Rename(quotaDir3, quotaDir2));
                c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 4);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 3);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                tempPath = new Path(quotaDir2, "qdir21");
                c        = dfs.GetContentSummary(tempPath);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 1);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 2);
                // 15: Delete /nqdir0/qdir1/qdir20/qdir21
                dfs.Delete(tempPath, true);
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 2);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 3);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                // 16: Move /nqdir0/qdir30 /nqdir0/qdir1/qdir20
                NUnit.Framework.Assert.IsTrue(dfs.Rename(new Path("/nqdir0/nqdir30"), quotaDir2));
                c = dfs.GetContentSummary(quotaDir2);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 5);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 7);
                c = dfs.GetContentSummary(quotaDir1);
                NUnit.Framework.Assert.AreEqual(c.GetDirectoryCount(), 6);
                NUnit.Framework.Assert.AreEqual(c.GetQuota(), 6);
                NUnit.Framework.Assert.AreEqual(14, cluster.GetNamesystem().GetFSDirectory().GetYieldCount
                                                    ());
            }
            finally
            {
                cluster.Shutdown();
            }
        }