예제 #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="Com.Google.Protobuf.ServiceException"/>
        public virtual NamenodeProtocolProtos.GetMostRecentCheckpointTxIdResponseProto GetMostRecentCheckpointTxId
            (RpcController unused, NamenodeProtocolProtos.GetMostRecentCheckpointTxIdRequestProto
            request)
        {
            long txid;

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