コード例 #1
0
ファイル: JournalSet.cs プロジェクト: orf53975/hadoop.net
 /// <exception cref="System.IO.IOException"/>
 public void Apply(JournalSet.JournalAndStream jas)
 {
     if (jas.IsActive())
     {
         jas.GetCurrentStream().Flush();
     }
 }
コード例 #2
0
ファイル: JournalSet.cs プロジェクト: orf53975/hadoop.net
 /// <exception cref="System.IO.IOException"/>
 public void Apply(JournalSet.JournalAndStream jas)
 {
     if (jas.IsActive())
     {
         jas.GetCurrentStream().WriteRaw(data, offset, length);
     }
 }
コード例 #3
0
ファイル: JournalSet.cs プロジェクト: orf53975/hadoop.net
 /// <exception cref="System.IO.IOException"/>
 public void Apply(JournalSet.JournalAndStream jas)
 {
     if (jas.IsActive())
     {
         jas.GetCurrentStream().Create(layoutVersion);
     }
 }
コード例 #4
0
        public virtual void TestSaveImageWhileSyncInProgress()
        {
            Configuration conf = GetConf();

            NameNode.InitMetrics(conf, HdfsServerConstants.NamenodeRole.Namenode);
            DFSTestUtil.FormatNameNode(conf);
            FSNamesystem namesystem = FSNamesystem.LoadFromDisk(conf);

            try
            {
                FSImage   fsimage = namesystem.GetFSImage();
                FSEditLog editLog = fsimage.GetEditLog();
                JournalSet.JournalAndStream jas     = editLog.GetJournals()[0];
                EditLogFileOutputStream     spyElos = Org.Mockito.Mockito.Spy((EditLogFileOutputStream
                                                                               )jas.GetCurrentStream());
                jas.SetCurrentStreamForTests(spyElos);
                AtomicReference <Exception> deferredException = new AtomicReference <Exception>();
                CountDownLatch waitToEnterFlush = new CountDownLatch(1);
                Sharpen.Thread doAnEditThread   = new _Thread_371(namesystem, deferredException, waitToEnterFlush
                                                                  );
                Answer <Void> blockingFlush = new _Answer_388(doAnEditThread, waitToEnterFlush);
                // Signal to main thread that the edit thread is in the racy section
                Org.Mockito.Mockito.DoAnswer(blockingFlush).When(spyElos).Flush();
                doAnEditThread.Start();
                // Wait for the edit thread to get to the logsync unsynchronized section
                Log.Info("Main thread: waiting to enter flush...");
                waitToEnterFlush.Await();
                NUnit.Framework.Assert.IsNull(deferredException.Get());
                Log.Info("Main thread: detected that logSync is in unsynchronized section.");
                Log.Info("Trying to enter safe mode.");
                Log.Info("This should block for " + BlockTime + "sec, since flush will sleep that long"
                         );
                long st = Time.Now();
                namesystem.SetSafeMode(HdfsConstants.SafeModeAction.SafemodeEnter);
                long et = Time.Now();
                Log.Info("Entered safe mode");
                // Make sure we really waited for the flush to complete!
                NUnit.Framework.Assert.IsTrue(et - st > (BlockTime - 1) * 1000);
                // Once we're in safe mode, save namespace.
                namesystem.SaveNamespace();
                Log.Info("Joining on edit thread...");
                doAnEditThread.Join();
                NUnit.Framework.Assert.IsNull(deferredException.Get());
                // We did 3 edits: begin, txn, and end
                NUnit.Framework.Assert.AreEqual(3, VerifyEditLogs(namesystem, fsimage, NNStorage.
                                                                  GetFinalizedEditsFileName(1, 3), 1));
                // after the save, just the one "begin"
                NUnit.Framework.Assert.AreEqual(1, VerifyEditLogs(namesystem, fsimage, NNStorage.
                                                                  GetInProgressEditsFileName(4), 4));
            }
            finally
            {
                Log.Info("Closing nn");
                if (namesystem != null)
                {
                    namesystem.Close();
                }
            }
        }
コード例 #5
0
        private EditLogFileOutputStream SpyOnStream(JournalSet.JournalAndStream jas)
        {
            EditLogFileOutputStream elos    = (EditLogFileOutputStream)jas.GetCurrentStream();
            EditLogFileOutputStream spyElos = Org.Mockito.Mockito.Spy(elos);

            jas.SetCurrentStreamForTests(spyElos);
            return(spyElos);
        }