Пример #1
0
 /// <summary>Load the fsimage from a temp file</summary>
 /// <exception cref="System.IO.IOException"/>
 private void LoadFSImageFromTempFile(FilePath imageFile)
 {
     FSImageFormat.LoaderDelegator loader = FSImageFormat.NewLoader(conf, fsn);
     fsn.WriteLock();
     fsn.GetFSDirectory().WriteLock();
     try
     {
         loader.Load(imageFile, false);
         FSImage.UpdateCountForQuota(fsn.GetBlockManager().GetStoragePolicySuite(), INodeDirectory
                                     .ValueOf(fsn.GetFSDirectory().GetINode("/"), "/"));
     }
     finally
     {
         fsn.GetFSDirectory().WriteUnlock();
         fsn.WriteUnlock();
     }
 }
Пример #2
0
 /// <summary>Apply the batch of edits to the local namespace.</summary>
 /// <exception cref="System.IO.IOException"/>
 private void ApplyEdits(long firstTxId, int numTxns, byte[] data)
 {
     lock (this)
     {
         Preconditions.CheckArgument(firstTxId == lastAppliedTxId + 1, "Received txn batch starting at %s but expected %s"
                                     , firstTxId, lastAppliedTxId + 1);
         System.Diagnostics.Debug.Assert(backupInputStream.Length() == 0, "backup input stream is not empty"
                                         );
         try
         {
             if (Log.IsTraceEnabled())
             {
                 Log.Debug("data:" + StringUtils.ByteToHexString(data));
             }
             FSEditLogLoader logLoader  = new FSEditLogLoader(GetNamesystem(), lastAppliedTxId);
             int             logVersion = storage.GetLayoutVersion();
             backupInputStream.SetBytes(data, logVersion);
             long numTxnsAdvanced = logLoader.LoadEditRecords(backupInputStream, true, lastAppliedTxId
                                                              + 1, null, null);
             if (numTxnsAdvanced != numTxns)
             {
                 throw new IOException("Batch of txns starting at txnid " + firstTxId + " was supposed to contain "
                                       + numTxns + " transactions, but we were only able to advance by " + numTxnsAdvanced
                                       );
             }
             lastAppliedTxId = logLoader.GetLastAppliedTxId();
             FSImage.UpdateCountForQuota(GetNamesystem().dir.GetBlockStoragePolicySuite(), GetNamesystem
                                             ().dir.rootDir);
         }
         finally
         {
             // inefficient!
             backupInputStream.Clear();
         }
     }
 }