예제 #1
0
        /// <exception cref="Com.Google.Protobuf.ServiceException"/>
        public virtual NamenodeProtocolProtos.GetEditLogManifestResponseProto GetEditLogManifest
            (RpcController unused, NamenodeProtocolProtos.GetEditLogManifestRequestProto request
            )
        {
            RemoteEditLogManifest manifest;

            try
            {
                manifest = impl.GetEditLogManifest(request.GetSinceTxId());
            }
            catch (IOException e)
            {
                throw new ServiceException(e);
            }
            return((NamenodeProtocolProtos.GetEditLogManifestResponseProto)NamenodeProtocolProtos.GetEditLogManifestResponseProto
                   .NewBuilder().SetManifest(PBHelper.Convert(manifest)).Build());
        }
예제 #2
0
        public virtual bool DoCheckpoint()
        {
            checkpointImage.EnsureCurrentDirExists();
            NNStorage dstStorage = checkpointImage.GetStorage();
            // Tell the namenode to start logging transactions in a new edit file
            // Returns a token that would be used to upload the merged image.
            CheckpointSignature sig  = namenode.RollEditLog();
            bool loadImage           = false;
            bool isFreshCheckpointer = (checkpointImage.GetNamespaceID() == 0);
            bool isSameCluster       = (dstStorage.VersionSupportsFederation(NameNodeLayoutVersion.
                                                                             Features) && sig.IsSameCluster(checkpointImage)) || (!dstStorage.VersionSupportsFederation
                                                                                                                                      (NameNodeLayoutVersion.Features) && sig.NamespaceIdMatches(checkpointImage));

            if (isFreshCheckpointer || (isSameCluster && !sig.StorageVersionMatches(checkpointImage
                                                                                    .GetStorage())))
            {
                // if we're a fresh 2NN, or if we're on the same cluster and our storage
                // needs an upgrade, just take the storage info from the server.
                dstStorage.SetStorageInfo(sig);
                dstStorage.SetClusterID(sig.GetClusterID());
                dstStorage.SetBlockPoolID(sig.GetBlockpoolID());
                loadImage = true;
            }
            sig.ValidateStorageInfo(checkpointImage);
            // error simulation code for junit test
            CheckpointFaultInjector.GetInstance().AfterSecondaryCallsRollEditLog();
            RemoteEditLogManifest manifest = namenode.GetEditLogManifest(sig.mostRecentCheckpointTxId
                                                                         + 1);

            // Fetch fsimage and edits. Reload the image if previous merge failed.
            loadImage |= DownloadCheckpointFiles(fsName, checkpointImage, sig, manifest) | checkpointImage
                         .HasMergeError();
            try
            {
                DoMerge(sig, manifest, loadImage, checkpointImage, namesystem);
            }
            catch (IOException ioe)
            {
                // A merge error occurred. The in-memory file system state may be
                // inconsistent, so the image and edits need to be reloaded.
                checkpointImage.SetMergeError();
                throw;
            }
            // Clear any error since merge was successful.
            checkpointImage.ClearMergeError();
            //
            // Upload the new image into the NameNode. Then tell the Namenode
            // to make this new uploaded image as the most current image.
            //
            long txid = checkpointImage.GetLastAppliedTxId();

            TransferFsImage.UploadImageFromStorage(fsName, conf, dstStorage, NNStorage.NameNodeFile
                                                   .Image, txid);
            // error simulation code for junit test
            CheckpointFaultInjector.GetInstance().AfterSecondaryUploadsNewImage();
            Log.Warn("Checkpoint done. New Image Size: " + dstStorage.GetFsImageName(txid).Length
                         ());
            if (legacyOivImageDir != null && !legacyOivImageDir.IsEmpty())
            {
                try
                {
                    checkpointImage.SaveLegacyOIVImage(namesystem, legacyOivImageDir, new Canceler());
                }
                catch (IOException e)
                {
                    Log.Warn("Failed to write legacy OIV image: ", e);
                }
            }
            return(loadImage);
        }