Exemplo n.º 1
0
        public virtual void TestRetryCacheRebuild()
        {
            DFSTestUtil.RunOperations(cluster, filesystem, conf, BlockSize, 0);
            FSNamesystem namesystem = cluster.GetNamesystem();
            LightWeightCache <RetryCache.CacheEntry, RetryCache.CacheEntry> cacheSet = (LightWeightCache
                                                                                        <RetryCache.CacheEntry, RetryCache.CacheEntry>)namesystem.GetRetryCache().GetCacheSet
                                                                                           ();

            NUnit.Framework.Assert.AreEqual(25, cacheSet.Size());
            IDictionary <RetryCache.CacheEntry, RetryCache.CacheEntry> oldEntries = new Dictionary
                                                                                    <RetryCache.CacheEntry, RetryCache.CacheEntry>();
            IEnumerator <RetryCache.CacheEntry> iter = cacheSet.GetEnumerator();

            while (iter.HasNext())
            {
                RetryCache.CacheEntry entry = iter.Next();
                oldEntries[entry] = entry;
            }
            // restart NameNode
            cluster.RestartNameNode();
            cluster.WaitActive();
            namesystem = cluster.GetNamesystem();
            // check retry cache
            NUnit.Framework.Assert.IsTrue(namesystem.HasRetryCache());
            cacheSet = (LightWeightCache <RetryCache.CacheEntry, RetryCache.CacheEntry>)namesystem
                       .GetRetryCache().GetCacheSet();
            NUnit.Framework.Assert.AreEqual(25, cacheSet.Size());
            iter = cacheSet.GetEnumerator();
            while (iter.HasNext())
            {
                RetryCache.CacheEntry entry = iter.Next();
                NUnit.Framework.Assert.IsTrue(oldEntries.Contains(entry));
            }
        }
        /// <summary>
        /// Run file operations to create edits for all op codes
        /// to be tested.
        /// </summary>
        /// <remarks>
        /// Run file operations to create edits for all op codes
        /// to be tested.
        /// the following op codes are deprecated and therefore not tested:
        /// OP_DATANODE_ADD    ( 5)
        /// OP_DATANODE_REMOVE ( 6)
        /// OP_SET_NS_QUOTA    (11)
        /// OP_CLEAR_NS_QUOTA  (12)
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        private CheckpointSignature RunOperations()
        {
            Log.Info("Creating edits by performing fs operations");
            // no check, if it's not it throws an exception which is what we want
            DistributedFileSystem dfs = cluster.GetFileSystem();

            DFSTestUtil.RunOperations(cluster, dfs, cluster.GetConfiguration(0), dfs.GetDefaultBlockSize
                                          (), 0);
            // OP_ROLLING_UPGRADE_START
            cluster.GetNamesystem().GetEditLog().LogStartRollingUpgrade(Time.Now());
            // OP_ROLLING_UPGRADE_FINALIZE
            cluster.GetNamesystem().GetEditLog().LogFinalizeRollingUpgrade(Time.Now());
            // Force a roll so we get an OP_END_LOG_SEGMENT txn
            return(cluster.GetNameNodeRpc().RollEditLog());
        }