コード例 #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestCopyFileUnbuffered()
        {
            string   MethodName = GenericTestUtils.GetMethodName();
            FilePath srcFile    = new FilePath(TestDir, MethodName + ".src.dat");
            FilePath dstFile    = new FilePath(TestDir, MethodName + ".dst.dat");
            int      fileSize   = unchecked ((int)(0x8000000));
            // 128 MB
            int              Seed       = unchecked ((int)(0xBEEF));
            int              batchSize  = 4096;
            int              numBatches = fileSize / batchSize;
            Random           rb         = new Random(Seed);
            FileChannel      channel    = null;
            RandomAccessFile raSrcFile  = null;

            try
            {
                raSrcFile = new RandomAccessFile(srcFile, "rw");
                channel   = raSrcFile.GetChannel();
                byte[]           bytesToWrite = new byte[batchSize];
                MappedByteBuffer mapBuf;
                mapBuf = channel.Map(FileChannel.MapMode.ReadWrite, 0, fileSize);
                for (int i = 0; i < numBatches; i++)
                {
                    rb.NextBytes(bytesToWrite);
                    mapBuf.Put(bytesToWrite);
                }
                NativeIO.CopyFileUnbuffered(srcFile, dstFile);
                Assert.Equal(srcFile.Length(), dstFile.Length());
            }
            finally
            {
                IOUtils.Cleanup(Log, channel);
                IOUtils.Cleanup(Log, raSrcFile);
                FileUtils.DeleteQuietly(TestDir);
            }
        }
コード例 #2
0
 public virtual bool VerifyCanMlock()
 {
     return(NativeIO.IsAvailable());
 }
コード例 #3
0
 public virtual long GetOperatingSystemPageSize()
 {
     return(NativeIO.GetOperatingSystemPageSize());
 }
コード例 #4
0
 public virtual long GetMemlockLimit()
 {
     return(NativeIO.GetMemlockLimit());
 }
コード例 #5
0
 /// <exception cref="System.Exception"/>
 public virtual void TestGetMemlockLimit()
 {
     Assume.AssumeTrue(NativeIO.IsAvailable());
     NativeIO.GetMemlockLimit();
 }