示例#1
0
        /// <exception cref="System.IO.IOException"/>
        private int DownloadImage(NNStorage storage, NamenodeProtocol proxy)
        {
            // Load the newly formatted image, using all of the directories
            // (including shared edits)
            long    imageTxId = proxy.GetMostRecentCheckpointTxId();
            long    curTxId   = proxy.GetTransactionID();
            FSImage image     = new FSImage(conf);

            try
            {
                image.GetStorage().SetStorageInfo(storage);
                image.InitEditLog(HdfsServerConstants.StartupOption.Regular);
                System.Diagnostics.Debug.Assert(image.GetEditLog().IsOpenForRead(), "Expected edit log to be open for read"
                                                );
                // Ensure that we have enough edits already in the shared directory to
                // start up from the last checkpoint on the active.
                if (!skipSharedEditsCheck && !CheckLogsAvailableForRead(image, imageTxId, curTxId
                                                                        ))
                {
                    return(ErrCodeLogsUnavailable);
                }
                image.GetStorage().WriteTransactionIdFileToStorage(curTxId);
                // Download that checkpoint into our storage directories.
                MD5Hash hash = TransferFsImage.DownloadImageToStorage(otherHttpAddr, imageTxId, storage
                                                                      , true);
                image.SaveDigestAndRenameCheckpointImage(NNStorage.NameNodeFile.Image, imageTxId,
                                                         hash);
            }
            catch (IOException ioe)
            {
                image.Close();
                throw;
            }
            return(0);
        }
示例#2
0
        /// <exception cref="System.IO.IOException"/>
        private long CountUncheckpointedTxns()
        {
            long curTxId            = namenode.GetTransactionID();
            long uncheckpointedTxns = curTxId - checkpointImage.GetStorage().GetMostRecentCheckpointTxId
                                          ();

            System.Diagnostics.Debug.Assert(uncheckpointedTxns >= 0);
            return(uncheckpointedTxns);
        }
示例#3
0
        /// <exception cref="Com.Google.Protobuf.ServiceException"/>
        public virtual NamenodeProtocolProtos.GetTransactionIdResponseProto GetTransactionId
            (RpcController unused, NamenodeProtocolProtos.GetTransactionIdRequestProto request
            )
        {
            long txid;

            try
            {
                txid = impl.GetTransactionID();
            }
            catch (IOException e)
            {
                throw new ServiceException(e);
            }
            return((NamenodeProtocolProtos.GetTransactionIdResponseProto)NamenodeProtocolProtos.GetTransactionIdResponseProto
                   .NewBuilder().SetTxId(txid).Build());
        }