Пример #1
0
        public virtual void TestConcatWithQuotaDecrease()
        {
            short srcRepl = 3;
            // note this is different with REPL_FACTOR
            int  srcNum = 10;
            Path foo    = new Path("/foo");

            Path[] srcs   = new Path[srcNum];
            Path   target = new Path(foo, "target");

            DFSTestUtil.CreateFile(dfs, target, blockSize, ReplFactor, 0L);
            dfs.SetQuota(foo, long.MaxValue - 1, long.MaxValue - 1);
            for (int i = 0; i < srcNum; i++)
            {
                srcs[i] = new Path(foo, "src" + i);
                DFSTestUtil.CreateFile(dfs, srcs[i], blockSize * 2, srcRepl, 0L);
            }
            ContentSummary summary = dfs.GetContentSummary(foo);

            NUnit.Framework.Assert.AreEqual(11, summary.GetFileCount());
            NUnit.Framework.Assert.AreEqual(blockSize * ReplFactor + blockSize * 2 * srcRepl
                                            * srcNum, summary.GetSpaceConsumed());
            dfs.Concat(target, srcs);
            summary = dfs.GetContentSummary(foo);
            NUnit.Framework.Assert.AreEqual(1, summary.GetFileCount());
            NUnit.Framework.Assert.AreEqual(blockSize * ReplFactor + blockSize * 2 * ReplFactor
                                            * srcNum, summary.GetSpaceConsumed());
        }
Пример #2
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);
            }
Пример #3
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());
        }
Пример #4
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());
        }
Пример #5
0
        public virtual void TestConcatWithQuotaIncrease()
        {
            short repl   = 3;
            int   srcNum = 10;
            Path  foo    = new Path("/foo");
            Path  bar    = new Path(foo, "bar");

            Path[] srcs   = new Path[srcNum];
            Path   target = new Path(bar, "target");

            DFSTestUtil.CreateFile(dfs, target, blockSize, repl, 0L);
            long dsQuota = blockSize * repl + blockSize * srcNum * ReplFactor;

            dfs.SetQuota(foo, long.MaxValue - 1, dsQuota);
            for (int i = 0; i < srcNum; i++)
            {
                srcs[i] = new Path(bar, "src" + i);
                DFSTestUtil.CreateFile(dfs, srcs[i], blockSize, ReplFactor, 0L);
            }
            ContentSummary summary = dfs.GetContentSummary(bar);

            NUnit.Framework.Assert.AreEqual(11, summary.GetFileCount());
            NUnit.Framework.Assert.AreEqual(dsQuota, summary.GetSpaceConsumed());
            try
            {
                dfs.Concat(target, srcs);
                NUnit.Framework.Assert.Fail("QuotaExceededException expected");
            }
            catch (RemoteException e)
            {
                NUnit.Framework.Assert.IsTrue(e.UnwrapRemoteException() is QuotaExceededException
                                              );
            }
            dfs.SetQuota(foo, long.MaxValue - 1, long.MaxValue - 1);
            dfs.Concat(target, srcs);
            summary = dfs.GetContentSummary(bar);
            NUnit.Framework.Assert.AreEqual(1, summary.GetFileCount());
            NUnit.Framework.Assert.AreEqual(blockSize * repl * (srcNum + 1), summary.GetSpaceConsumed
                                                ());
        }
Пример #6
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));
        }
Пример #7
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);
        }
Пример #8
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();
            }
        }
Пример #9
0
        public virtual void TestConcat()
        {
            int               numFiles = 10;
            long              fileLen  = blockSize * 3;
            HdfsFileStatus    fStatus;
            FSDataInputStream stm;
            string            trg     = "/trg";
            Path              trgPath = new Path(trg);

            DFSTestUtil.CreateFile(dfs, trgPath, fileLen, ReplFactor, 1);
            fStatus = nn.GetFileInfo(trg);
            long trgLen    = fStatus.GetLen();
            long trgBlocks = nn.GetBlockLocations(trg, 0, trgLen).LocatedBlockCount();

            Path[]   files = new Path[numFiles];
            byte[][] bytes = new byte[][] { new byte[(int)fileLen], new byte[(int)fileLen], new
                                            byte[(int)fileLen], new byte[(int)fileLen], new byte[(int)fileLen], new byte[(int
                                                                                                                          )fileLen], new byte[(int)fileLen], new byte[(int)fileLen], new byte[(int)fileLen
                                            ], new byte[(int)fileLen], new byte[(int)fileLen] };
            LocatedBlocks[] lblocks = new LocatedBlocks[numFiles];
            long[]          lens    = new long[numFiles];
            stm = dfs.Open(trgPath);
            stm.ReadFully(0, bytes[0]);
            stm.Close();
            int i;

            for (i = 0; i < files.Length; i++)
            {
                files[i] = new Path("/file" + i);
                Path path = files[i];
                System.Console.Out.WriteLine("Creating file " + path);
                // make files with different content
                DFSTestUtil.CreateFile(dfs, path, fileLen, ReplFactor, i);
                fStatus = nn.GetFileInfo(path.ToUri().GetPath());
                lens[i] = fStatus.GetLen();
                NUnit.Framework.Assert.AreEqual(trgLen, lens[i]);
                // file of the same length.
                lblocks[i] = nn.GetBlockLocations(path.ToUri().GetPath(), 0, lens[i]);
                //read the file
                stm = dfs.Open(path);
                stm.ReadFully(0, bytes[i + 1]);
                //bytes[i][10] = 10;
                stm.Close();
            }
            // check permissions -try the operation with the "wrong" user
            UserGroupInformation user1 = UserGroupInformation.CreateUserForTesting("theDoctor"
                                                                                   , new string[] { "tardis" });
            DistributedFileSystem hdfs = (DistributedFileSystem)DFSTestUtil.GetFileSystemAs(user1
                                                                                            , conf);

            try
            {
                hdfs.Concat(trgPath, files);
                NUnit.Framework.Assert.Fail("Permission exception expected");
            }
            catch (IOException ie)
            {
                System.Console.Out.WriteLine("Got expected exception for permissions:" + ie.GetLocalizedMessage
                                                 ());
            }
            // expected
            // check count update
            ContentSummary cBefore = dfs.GetContentSummary(trgPath.GetParent());

            // resort file array, make INode id not sorted.
            for (int j = 0; j < files.Length / 2; j++)
            {
                Path tempPath = files[j];
                files[j] = files[files.Length - 1 - j];
                files[files.Length - 1 - j] = tempPath;
                byte[] tempBytes = bytes[1 + j];
                bytes[1 + j] = bytes[files.Length - 1 - j + 1];
                bytes[files.Length - 1 - j + 1] = tempBytes;
            }
            // now concatenate
            dfs.Concat(trgPath, files);
            // verify  count
            ContentSummary cAfter = dfs.GetContentSummary(trgPath.GetParent());

            NUnit.Framework.Assert.AreEqual(cBefore.GetFileCount(), cAfter.GetFileCount() + files
                                            .Length);
            // verify other stuff
            long totalLen    = trgLen;
            long totalBlocks = trgBlocks;

            for (i = 0; i < files.Length; i++)
            {
                totalLen    += lens[i];
                totalBlocks += lblocks[i].LocatedBlockCount();
            }
            System.Console.Out.WriteLine("total len=" + totalLen + "; totalBlocks=" + totalBlocks
                                         );
            fStatus = nn.GetFileInfo(trg);
            trgLen  = fStatus.GetLen();
            // new length
            // read the resulting file
            stm = dfs.Open(trgPath);
            byte[] byteFileConcat = new byte[(int)trgLen];
            stm.ReadFully(0, byteFileConcat);
            stm.Close();
            trgBlocks = nn.GetBlockLocations(trg, 0, trgLen).LocatedBlockCount();
            //verifications
            // 1. number of blocks
            NUnit.Framework.Assert.AreEqual(trgBlocks, totalBlocks);
            // 2. file lengths
            NUnit.Framework.Assert.AreEqual(trgLen, totalLen);
            // 3. removal of the src file
            foreach (Path p in files)
            {
                fStatus = nn.GetFileInfo(p.ToUri().GetPath());
                NUnit.Framework.Assert.IsNull("File " + p + " still exists", fStatus);
                // file shouldn't exist
                // try to create fie with the same name
                DFSTestUtil.CreateFile(dfs, p, fileLen, ReplFactor, 1);
            }
            // 4. content
            CheckFileContent(byteFileConcat, bytes);
            // add a small file (less then a block)
            Path smallFile = new Path("/sfile");
            int  sFileLen  = 10;

            DFSTestUtil.CreateFile(dfs, smallFile, sFileLen, ReplFactor, 1);
            dfs.Concat(trgPath, new Path[] { smallFile });
            fStatus = nn.GetFileInfo(trg);
            trgLen  = fStatus.GetLen();
            // new length
            // check number of blocks
            trgBlocks = nn.GetBlockLocations(trg, 0, trgLen).LocatedBlockCount();
            NUnit.Framework.Assert.AreEqual(trgBlocks, totalBlocks + 1);
            // and length
            NUnit.Framework.Assert.AreEqual(trgLen, totalLen + sFileLen);
        }