Ejemplo n.º 1
0
        public virtual void TestQuotaUpdatedWhenBlockAbandoned()
        {
            // Setting diskspace quota to 3MB
            fs.SetQuota(new Path("/"), HdfsConstants.QuotaDontSet, 3 * 1024 * 1024);
            // Start writing a file with 2 replicas to ensure each datanode has one.
            // Block Size is 1MB.
            string             src  = FileNamePrefix + "test_quota1";
            FSDataOutputStream fout = fs.Create(new Path(src), true, 4096, (short)2, 1024 * 1024
                                                );

            for (int i = 0; i < 1024; i++)
            {
                fout.WriteByte(123);
            }
            // Shutdown one datanode, causing the block abandonment.
            cluster.GetDataNodes()[0].Shutdown();
            // Close the file, new block will be allocated with 2MB pending size.
            try
            {
                fout.Close();
            }
            catch (QuotaExceededException)
            {
                NUnit.Framework.Assert.Fail("Unexpected quota exception when closing fout");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a file with the name <code>file</code> and
        /// a length of <code>fileSize</code>.
        /// </summary>
        /// <remarks>
        /// Create a file with the name <code>file</code> and
        /// a length of <code>fileSize</code>. The file is filled with character 'a'.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        private void GenFile(Path file, long fileSize)
        {
            FSDataOutputStream @out = fc.Create(file, EnumSet.Of(CreateFlag.Create, CreateFlag
                                                                 .Overwrite), Options.CreateOpts.CreateParent(), Options.CreateOpts.BufferSize(4096
                                                                                                                                               ), Options.CreateOpts.RepFac((short)3));

            for (long i = 0; i < fileSize; i++)
            {
                @out.WriteByte('a');
            }
            @out.Close();
        }