Exemplo n.º 1
0
        public virtual void TestCloseTwice()
        {
            DistributedFileSystem fs  = cluster.GetFileSystem();
            FSDataOutputStream    os  = fs.Create(new Path("/test"));
            DFSOutputStream       dos = (DFSOutputStream)Whitebox.GetInternalState(os, "wrappedStream"
                                                                                   );
            AtomicReference <IOException> ex = (AtomicReference <IOException>)Whitebox.GetInternalState
                                                   (dos, "lastException");

            NUnit.Framework.Assert.AreEqual(null, ex.Get());
            dos.Close();
            IOException dummy = new IOException("dummy");

            ex.Set(dummy);
            try
            {
                dos.Close();
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.AreEqual(e, dummy);
            }
            NUnit.Framework.Assert.AreEqual(null, ex.Get());
            dos.Close();
        }
Exemplo n.º 2
0
        public virtual void TestPipelineRecoveryOnRestartFailure()
        {
            Configuration conf = new HdfsConfiguration();

            conf.Set(DFSConfigKeys.DfsClientDatanodeRestartTimeoutKey, "5");
            MiniDFSCluster cluster = null;

            try
            {
                int numDataNodes = 2;
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(numDataNodes).Build();
                cluster.WaitActive();
                FileSystem fileSys = cluster.GetFileSystem();
                Path       file    = new Path("dataprotocol3.dat");
                DFSTestUtil.CreateFile(fileSys, file, 10240L, (short)2, 0L);
                DFSOutputStream @out = (DFSOutputStream)(fileSys.Append(file).GetWrappedStream());
                @out.Write(1);
                @out.Hflush();
                DFSAdmin dfsadmin = new DFSAdmin(conf);
                DataNode dn       = cluster.GetDataNodes()[0];
                string   dnAddr1  = dn.GetDatanodeId().GetIpcAddr(false);
                // issue shutdown to the datanode.
                string[] args1 = new string[] { "-shutdownDatanode", dnAddr1, "upgrade" };
                NUnit.Framework.Assert.AreEqual(0, dfsadmin.Run(args1));
                Sharpen.Thread.Sleep(4000);
                // This should succeed without restarting the node. The restart will
                // expire and regular pipeline recovery will kick in.
                @out.Close();
                // At this point there is only one node in the cluster.
                @out = (DFSOutputStream)(fileSys.Append(file).GetWrappedStream());
                @out.Write(1);
                @out.Hflush();
                dn = cluster.GetDataNodes()[1];
                string dnAddr2 = dn.GetDatanodeId().GetIpcAddr(false);
                // issue shutdown to the datanode.
                string[] args2 = new string[] { "-shutdownDatanode", dnAddr2, "upgrade" };
                NUnit.Framework.Assert.AreEqual(0, dfsadmin.Run(args2));
                Sharpen.Thread.Sleep(4000);
                try
                {
                    // close should fail
                    @out.Close();
                    System.Diagnostics.Debug.Assert(false);
                }
                catch (IOException)
                {
                }
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }
Exemplo n.º 3
0
 /// <exception cref="System.Exception"/>
 public virtual void TestDatanodePeersXceiver()
 {
     // Test DatanodeXceiver has correct peer-dataxceiver pairs for sending OOB message
     try
     {
         StartCluster();
         // Create files in DFS.
         string          testFile1 = "/" + GenericTestUtils.GetMethodName() + ".01.dat";
         string          testFile2 = "/" + GenericTestUtils.GetMethodName() + ".02.dat";
         string          testFile3 = "/" + GenericTestUtils.GetMethodName() + ".03.dat";
         DFSClient       client1   = new DFSClient(NameNode.GetAddress(conf), conf);
         DFSClient       client2   = new DFSClient(NameNode.GetAddress(conf), conf);
         DFSClient       client3   = new DFSClient(NameNode.GetAddress(conf), conf);
         DFSOutputStream s1        = (DFSOutputStream)client1.Create(testFile1, true);
         DFSOutputStream s2        = (DFSOutputStream)client2.Create(testFile2, true);
         DFSOutputStream s3        = (DFSOutputStream)client3.Create(testFile3, true);
         byte[]          toWrite   = new byte[1024 * 1024 * 8];
         Random          rb        = new Random(1111);
         rb.NextBytes(toWrite);
         s1.Write(toWrite, 0, 1024 * 1024 * 8);
         s1.Flush();
         s2.Write(toWrite, 0, 1024 * 1024 * 8);
         s2.Flush();
         s3.Write(toWrite, 0, 1024 * 1024 * 8);
         s3.Flush();
         NUnit.Framework.Assert.IsTrue(dn0.GetXferServer().GetNumPeersXceiver() == dn0.GetXferServer
                                           ().GetNumPeersXceiver());
         s1.Close();
         s2.Close();
         s3.Close();
         NUnit.Framework.Assert.IsTrue(dn0.GetXferServer().GetNumPeersXceiver() == dn0.GetXferServer
                                           ().GetNumPeersXceiver());
         client1.Close();
         client2.Close();
         client3.Close();
     }
     finally
     {
         ShutdownCluster();
     }
 }
Exemplo n.º 4
0
        public virtual void TestPipelineRecoveryOnOOB()
        {
            Configuration conf = new HdfsConfiguration();

            conf.Set(DFSConfigKeys.DfsClientDatanodeRestartTimeoutKey, "15");
            MiniDFSCluster cluster = null;

            try
            {
                int numDataNodes = 1;
                cluster = new MiniDFSCluster.Builder(conf).NumDataNodes(numDataNodes).Build();
                cluster.WaitActive();
                FileSystem fileSys = cluster.GetFileSystem();
                Path       file    = new Path("dataprotocol2.dat");
                DFSTestUtil.CreateFile(fileSys, file, 10240L, (short)1, 0L);
                DFSOutputStream @out = (DFSOutputStream)(fileSys.Append(file).GetWrappedStream());
                @out.Write(1);
                @out.Hflush();
                DFSAdmin dfsadmin = new DFSAdmin(conf);
                DataNode dn       = cluster.GetDataNodes()[0];
                string   dnAddr   = dn.GetDatanodeId().GetIpcAddr(false);
                // issue shutdown to the datanode.
                string[] args1 = new string[] { "-shutdownDatanode", dnAddr, "upgrade" };
                NUnit.Framework.Assert.AreEqual(0, dfsadmin.Run(args1));
                // Wait long enough to receive an OOB ack before closing the file.
                Sharpen.Thread.Sleep(4000);
                // Retart the datanode
                cluster.RestartDataNode(0, true);
                // The following forces a data packet and end of block packets to be sent.
                @out.Close();
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Shutdown();
                }
            }
        }