Example #1
0
        /// <exception cref="System.IO.IOException"/>
        internal static void DoMerge(CheckpointSignature sig, RemoteEditLogManifest manifest
                                     , bool loadImage, FSImage dstImage, FSNamesystem dstNamesystem)
        {
            NNStorage dstStorage = dstImage.GetStorage();

            dstStorage.SetStorageInfo(sig);
            if (loadImage)
            {
                FilePath file = dstStorage.FindImageFile(NNStorage.NameNodeFile.Image, sig.mostRecentCheckpointTxId
                                                         );
                if (file == null)
                {
                    throw new IOException("Couldn't find image file at txid " + sig.mostRecentCheckpointTxId
                                          + " even though it should have " + "just been downloaded");
                }
                dstNamesystem.WriteLock();
                try
                {
                    dstImage.ReloadFromImageFile(file, dstNamesystem);
                }
                finally
                {
                    dstNamesystem.WriteUnlock();
                }
                dstNamesystem.ImageLoadComplete();
            }
            // error simulation code for junit test
            CheckpointFaultInjector.GetInstance().DuringMerge();
            Checkpointer.RollForwardByApplyingLogs(manifest, dstImage, dstNamesystem);
            // The following has the side effect of purging old fsimages/edit logs.
            dstImage.SaveFSImageInAllDirs(dstNamesystem, dstImage.GetLastAppliedTxId());
            dstStorage.WriteAll();
        }
Example #2
0
 public override void Stop()
 {
     // NameNode
     if (checkpointManager != null)
     {
         // Prevent from starting a new checkpoint.
         // Checkpoints that has already been started may proceed until
         // the error reporting to the name-node is complete.
         // Checkpoint manager should not be interrupted yet because it will
         // close storage file channels and the checkpoint may fail with
         // ClosedByInterruptException.
         checkpointManager.shouldRun = false;
     }
     if (namenode != null && GetRegistration() != null)
     {
         // Exclude this node from the list of backup streams on the name-node
         try
         {
             namenode.ErrorReport(GetRegistration(), NamenodeProtocol.Fatal, "Shutting down.");
         }
         catch (IOException e)
         {
             Log.Error("Failed to report to name-node.", e);
         }
     }
     // Stop the RPC client
     if (namenode != null)
     {
         RPC.StopProxy(namenode);
     }
     namenode = null;
     // Stop the checkpoint manager
     if (checkpointManager != null)
     {
         checkpointManager.Interrupt();
         checkpointManager = null;
     }
     // Abort current log segment - otherwise the NN shutdown code
     // will close it gracefully, which is incorrect.
     GetFSImage().GetEditLog().AbortCurrentLogSegment();
     // Stop name-node threads
     base.Stop();
 }
Example #3
0
 /// <summary>Start a backup node daemon.</summary>
 /// <exception cref="System.IO.IOException"/>
 private void RunCheckpointDaemon(Configuration conf)
 {
     checkpointManager = new Checkpointer(conf, this);
     checkpointManager.Start();
 }