Example #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestDatanodeReRegistration()
        {
            // Create a test file
            DistributedFileSystem dfs = cluster.GetFileSystem();
            Path path = new Path("/testRR");

            // Create a file and shutdown the DNs, which populates InvalidateBlocks
            DFSTestUtil.CreateFile(dfs, path, dfs.GetDefaultBlockSize(), (short)NumOfDatanodes
                                   , unchecked ((int)(0xED0ED0)));
            foreach (DataNode dn in cluster.GetDataNodes())
            {
                dn.Shutdown();
            }
            dfs.Delete(path, false);
            namesystem.WriteLock();
            InvalidateBlocks invalidateBlocks;
            int expected = NumOfDatanodes;

            try
            {
                invalidateBlocks = (InvalidateBlocks)Whitebox.GetInternalState(cluster.GetNamesystem
                                                                                   ().GetBlockManager(), "invalidateBlocks");
                NUnit.Framework.Assert.AreEqual("Expected invalidate blocks to be the number of DNs"
                                                , (long)expected, invalidateBlocks.NumBlocks());
            }
            finally
            {
                namesystem.WriteUnlock();
            }
            // Re-register each DN and see that it wipes the invalidation work
            foreach (DataNode dn_1 in cluster.GetDataNodes())
            {
                DatanodeID           did = dn_1.GetDatanodeId();
                DatanodeRegistration reg = new DatanodeRegistration(new DatanodeID(UUID.RandomUUID
                                                                                       ().ToString(), did), new StorageInfo(HdfsServerConstants.NodeType.DataNode), new
                                                                    ExportedBlockKeys(), VersionInfo.GetVersion());
                namesystem.WriteLock();
                try
                {
                    bm.GetDatanodeManager().RegisterDatanode(reg);
                    expected--;
                    NUnit.Framework.Assert.AreEqual("Expected number of invalidate blocks to decrease"
                                                    , (long)expected, invalidateBlocks.NumBlocks());
                }
                finally
                {
                    namesystem.WriteUnlock();
                }
            }
        }
        /// <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());
        }
Example #3
0
        public virtual void TestIllegalArg()
        {
            long fileLen   = blockSize * 3;
            Path parentDir = new Path("/parentTrg");

            NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(parentDir));
            Path trg = new Path(parentDir, "trg");

            DFSTestUtil.CreateFile(dfs, trg, fileLen, ReplFactor, 1);
            {
                // must be in the same dir
                // create first file
                Path dir1 = new Path("/dir1");
                NUnit.Framework.Assert.IsTrue(dfs.Mkdirs(dir1));
                Path src = new Path(dir1, "src");
                DFSTestUtil.CreateFile(dfs, src, fileLen, ReplFactor, 1);
                try
                {
                    dfs.Concat(trg, new Path[] { src });
                    NUnit.Framework.Assert.Fail("didn't fail for src and trg in different directories"
                                                );
                }
                catch (Exception)
                {
                }
            }
            // expected
            // non existing file
            try
            {
                dfs.Concat(trg, new Path[] { new Path("test1/a") });
                // non existing file
                NUnit.Framework.Assert.Fail("didn't fail with invalid arguments");
            }
            catch (Exception)
            {
            }
            //expected
            // empty arg list
            try
            {
                dfs.Concat(trg, new Path[] {  });
                // empty array
                NUnit.Framework.Assert.Fail("didn't fail with invalid arguments");
            }
            catch (Exception)
            {
            }
            {
                // exspected
                // the source file's preferred block size cannot be greater than the target
                Path src1 = new Path(parentDir, "src1");
                DFSTestUtil.CreateFile(dfs, src1, fileLen, ReplFactor, 0L);
                Path src2 = new Path(parentDir, "src2");
                // create a file whose preferred block size is greater than the target
                DFSTestUtil.CreateFile(dfs, src2, 1024, fileLen, dfs.GetDefaultBlockSize(trg) * 2
                                       , ReplFactor, 0L);
                try
                {
                    dfs.Concat(trg, new Path[] { src1, src2 });
                    NUnit.Framework.Assert.Fail("didn't fail for src with greater preferred block size"
                                                );
                }
                catch (Exception e)
                {
                    GenericTestUtils.AssertExceptionContains("preferred block size", e);
                }
            }
        }