/// <exception cref="System.IO.IOException"/>
        private void CheckRecovery(MiniJournalCluster cluster, long segmentTxId, long expectedEndTxId
                                   )
        {
            int numFinalized = 0;

            for (int i = 0; i < cluster.GetNumNodes(); i++)
            {
                FilePath logDir = cluster.GetCurrentDir(i, QJMTestUtil.Jid);
                FileJournalManager.EditLogFile elf = FileJournalManager.GetLogFile(logDir, segmentTxId
                                                                                   );
                if (elf == null)
                {
                    continue;
                }
                if (!elf.IsInProgress())
                {
                    numFinalized++;
                    if (elf.GetLastTxId() != expectedEndTxId)
                    {
                        NUnit.Framework.Assert.Fail("File " + elf + " finalized to wrong txid, expected "
                                                    + expectedEndTxId);
                    }
                }
            }
            if (numFinalized < cluster.GetQuorumSize())
            {
                NUnit.Framework.Assert.Fail("Did not find a quorum of finalized logs starting at "
                                            + segmentTxId);
            }
        }
Пример #2
0
        /// <exception cref="Javax.Servlet.ServletException"/>
        /// <exception cref="System.IO.IOException"/>
        protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                                      )
        {
            FileInputStream editFileIn = null;

            try
            {
                ServletContext context = GetServletContext();
                Configuration  conf    = (Configuration)GetServletContext().GetAttribute(JspHelper.CurrentConf
                                                                                         );
                string journalId = request.GetParameter(JournalIdParam);
                QuorumJournalManager.CheckJournalId(journalId);
                JNStorage storage = JournalNodeHttpServer.GetJournalFromContext(context, journalId
                                                                                ).GetStorage();
                // Check security
                if (!CheckRequestorOrSendError(conf, request, response))
                {
                    return;
                }
                // Check that the namespace info is correct
                if (!CheckStorageInfoOrSendError(storage, request, response))
                {
                    return;
                }
                long segmentTxId       = ServletUtil.ParseLongParam(request, SegmentTxidParam);
                FileJournalManager fjm = storage.GetJournalManager();
                FilePath           editFile;
                lock (fjm)
                {
                    // Synchronize on the FJM so that the file doesn't get finalized
                    // out from underneath us while we're in the process of opening
                    // it up.
                    FileJournalManager.EditLogFile elf = fjm.GetLogFile(segmentTxId);
                    if (elf == null)
                    {
                        response.SendError(HttpServletResponse.ScNotFound, "No edit log found starting at txid "
                                           + segmentTxId);
                        return;
                    }
                    editFile = elf.GetFile();
                    ImageServlet.SetVerificationHeadersForGet(response, editFile);
                    ImageServlet.SetFileNameHeaders(response, editFile);
                    editFileIn = new FileInputStream(editFile);
                }
                DataTransferThrottler throttler = ImageServlet.GetThrottler(conf);
                // send edits
                TransferFsImage.CopyFileToStream(response.GetOutputStream(), editFile, editFileIn
                                                 , throttler);
            }
            catch (Exception t)
            {
                string errMsg = "getedit failed. " + StringUtils.StringifyException(t);
                response.SendError(HttpServletResponse.ScInternalServerError, errMsg);
                throw new IOException(errMsg);
            }
            finally
            {
                IOUtils.CloseStream(editFileIn);
            }
        }
Пример #3
0
 /// <param name="conf">Configuration object</param>
 /// <param name="logDir">the path to the directory in which data will be stored</param>
 /// <param name="errorReporter">a callback to report errors</param>
 /// <exception cref="System.IO.IOException"></exception>
 protected internal JNStorage(Configuration conf, FilePath logDir, HdfsServerConstants.StartupOption
                              startOpt, StorageErrorReporter errorReporter)
     : base(HdfsServerConstants.NodeType.JournalNode)
 {
     sd = new Storage.StorageDirectory(logDir);
     this.AddStorageDir(sd);
     this.fjm = new FileJournalManager(conf, sd, errorReporter);
     AnalyzeAndRecoverStorage(startOpt);
 }