Пример #1
0
 internal Statistics(VolumeScanner.Statistics other)
 {
     this.bytesScannedInPastHour       = other.bytesScannedInPastHour;
     this.blocksScannedInCurrentPeriod = other.blocksScannedInCurrentPeriod;
     this.blocksScannedSinceRestart    = other.blocksScannedSinceRestart;
     this.scansSinceRestart            = other.scansSinceRestart;
     this.scanErrorsSinceRestart       = other.scanErrorsSinceRestart;
     this.nextBlockPoolScanStartMs     = other.nextBlockPoolScanStartMs;
     this.blockPoolPeriodEndsMs        = other.blockPoolPeriodEndsMs;
     this.lastBlockScanned             = other.lastBlockScanned;
     this.eof = other.eof;
 }
Пример #2
0
        /// <exception cref="System.Exception"/>
        private void TestScanAllBlocksImpl(bool rescan)
        {
            Configuration conf = new Configuration();

            conf.SetLong(DFSConfigKeys.DfsBlockScannerVolumeBytesPerSecond, 1048576L);
            if (rescan)
            {
                conf.SetLong(BlockScanner.Conf.InternalDfsDatanodeScanPeriodMs, 100L);
            }
            else
            {
                conf.SetLong(DFSConfigKeys.DfsDatanodeScanPeriodHoursKey, 100L);
            }
            conf.Set(BlockScanner.Conf.InternalVolumeScannerScanResultHandler, typeof(TestBlockScanner.TestScanResultHandler
                                                                                      ).FullName);
            TestBlockScanner.TestContext ctx = new TestBlockScanner.TestContext(conf, 1);
            int NumExpectedBlocks            = 10;

            ctx.CreateFiles(0, NumExpectedBlocks, 1);
            ICollection <ExtendedBlock> expectedBlocks = new HashSet <ExtendedBlock>();

            for (int i = 0; i < NumExpectedBlocks; i++)
            {
                expectedBlocks.AddItem(ctx.GetFileBlock(0, i));
            }
            TestBlockScanner.TestScanResultHandler.Info info = TestBlockScanner.TestScanResultHandler
                                                               .GetInfo(ctx.volumes[0]);
            lock (info)
            {
                info.shouldRun = true;
                Sharpen.Runtime.Notify(info);
            }
            GenericTestUtils.WaitFor(new _Supplier_367(ctx, expectedBlocks, rescan, NumExpectedBlocks
                                                       ), 10, 60000);
            if (!rescan)
            {
                lock (info)
                {
                    NUnit.Framework.Assert.AreEqual(NumExpectedBlocks, info.blocksScanned);
                }
                VolumeScanner.Statistics stats = ctx.blockScanner.GetVolumeStats(ctx.volumes[0].GetStorageID
                                                                                     ());
                NUnit.Framework.Assert.AreEqual(5 * NumExpectedBlocks, stats.bytesScannedInPastHour
                                                );
                NUnit.Framework.Assert.AreEqual(NumExpectedBlocks, stats.blocksScannedSinceRestart
                                                );
                NUnit.Framework.Assert.AreEqual(NumExpectedBlocks, stats.blocksScannedInCurrentPeriod
                                                );
                NUnit.Framework.Assert.AreEqual(0, stats.scanErrorsSinceRestart);
                NUnit.Framework.Assert.AreEqual(1, stats.scansSinceRestart);
            }
            ctx.Close();
        }
Пример #3
0
 public bool Get()
 {
     lock (info)
     {
         VolumeScanner.Statistics stats = ctx.blockScanner.GetVolumeStats(ctx.volumes[0].GetStorageID
                                                                              ());
         if (stats.scansSinceRestart < 3)
         {
             TestBlockScanner.Log.Info("Waiting for scansSinceRestart to reach 3 (it is {})",
                                       stats.scansSinceRestart);
             return(false);
         }
         if (!stats.eof)
         {
             TestBlockScanner.Log.Info("Waiting for eof.");
             return(false);
         }
         return(true);
     }
 }
Пример #4
0
        /// <exception cref="System.Exception"/>
        public virtual void TestMultipleBlockPoolScanning()
        {
            Configuration conf = new Configuration();

            conf.SetLong(DFSConfigKeys.DfsDatanodeScanPeriodHoursKey, 100L);
            conf.Set(BlockScanner.Conf.InternalVolumeScannerScanResultHandler, typeof(TestBlockScanner.TestScanResultHandler
                                                                                      ).FullName);
            TestBlockScanner.TestContext ctx = new TestBlockScanner.TestContext(conf, 3);
            // We scan 5 bytes per file (1 byte in file, 4 bytes of checksum)
            int BytesScannedPerFile = 5;

            int[] NumFiles   = new int[] { 1, 5, 10 };
            int   TotalFiles = 0;

            for (int i = 0; i < NumFiles.Length; i++)
            {
                TotalFiles += NumFiles[i];
            }
            ctx.CreateFiles(0, NumFiles[0], 1);
            ctx.CreateFiles(0, NumFiles[1], 1);
            ctx.CreateFiles(0, NumFiles[2], 1);
            // start scanning
            TestBlockScanner.TestScanResultHandler.Info info = TestBlockScanner.TestScanResultHandler
                                                               .GetInfo(ctx.volumes[0]);
            lock (info)
            {
                info.shouldRun = true;
                Sharpen.Runtime.Notify(info);
            }
            // Wait for all the block pools to be scanned.
            GenericTestUtils.WaitFor(new _Supplier_632(info, ctx), 3, 30000);
            VolumeScanner.Statistics stats = ctx.blockScanner.GetVolumeStats(ctx.volumes[0].GetStorageID
                                                                                 ());
            NUnit.Framework.Assert.AreEqual(TotalFiles, stats.blocksScannedSinceRestart);
            NUnit.Framework.Assert.AreEqual(BytesScannedPerFile * TotalFiles, stats.bytesScannedInPastHour
                                            );
            ctx.Close();
        }