Beispiel #1
0
        public virtual void TestMetasaveAfterDelete()
        {
            for (int i = 0; i < 2; i++)
            {
                Path file = new Path("/filestatus" + i);
                CreateFile(fileSys, file);
            }
            cluster.StopDataNode(1);
            // wait for namenode to discover that a datanode is dead
            Sharpen.Thread.Sleep(15000);
            nnRpc.SetReplication("/filestatus0", (short)4);
            nnRpc.Delete("/filestatus0", true);
            nnRpc.Delete("/filestatus1", true);
            nnRpc.MetaSave("metasaveAfterDelete.out.txt");
            // Verification
            BufferedReader reader = null;

            try
            {
                FileInputStream fstream = new FileInputStream(GetLogFile("metasaveAfterDelete.out.txt"
                                                                         ));
                DataInputStream @in = new DataInputStream(fstream);
                reader = new BufferedReader(new InputStreamReader(@in));
                reader.ReadLine();
                string line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Live Datanodes: 1"));
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Dead Datanodes: 1"));
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Metasave: Blocks waiting for replication: 0"
                                                          ));
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Mis-replicated blocks that have been postponed:"
                                                          ));
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Metasave: Blocks being replicated: 0")
                                              );
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Metasave: Blocks 2 waiting deletion from 1 datanodes."
                                                          ));
                //skip 2 lines to reach HDFS-9033 scenario.
                line = reader.ReadLine();
                line = reader.ReadLine();
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsTrue(line.Equals("Metasave: Number of datanodes: 2"));
                line = reader.ReadLine();
                NUnit.Framework.Assert.IsFalse(line.Contains("NaN"));
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
        public virtual void TestDelete()
        {
            string dir = "/testNamenodeRetryCache/testDelete";

            // Two retried calls to create a non existent file
            NewCall();
            nnRpc.Mkdirs(dir, perm, true);
            NewCall();
            NUnit.Framework.Assert.IsTrue(nnRpc.Delete(dir, false));
            NUnit.Framework.Assert.IsTrue(nnRpc.Delete(dir, false));
            NUnit.Framework.Assert.IsTrue(nnRpc.Delete(dir, false));
            // non-retried call fails and gets false as return
            NewCall();
            NUnit.Framework.Assert.IsFalse(nnRpc.Delete(dir, false));
        }
Beispiel #3
0
            // add a bunch of transactions.
            public virtual void Run()
            {
                thr = Sharpen.Thread.CurrentThread();
                FsPermission p = new FsPermission((short)0x1ff);
                int          i = 0;

                while (!stopped)
                {
                    try
                    {
                        string dirname = "/thr-" + thr.GetId() + "-dir-" + i;
                        nn.Mkdirs(dirname, p, true);
                        nn.Delete(dirname, true);
                    }
                    catch (SafeModeException)
                    {
                    }
                    catch (Exception e)
                    {
                        // This is OK - the tests will bring NN in and out of safemode
                        Log.Warn("Got error in transaction thread", e);
                        caught.CompareAndSet(null, e);
                        break;
                    }
                    i++;
                }
            }