Exemplo n.º 1
0
 /// <summary>Closes the stream, also sets it to null.</summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual void CloseStream()
 {
     if (stream == null)
     {
         return;
     }
     stream.Close();
     stream = null;
 }
Exemplo n.º 2
0
 /// <exception cref="System.IO.IOException"/>
 internal static void AddDeleteOpcode(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache
                                      cache, long txId, string path)
 {
     FSEditLogOp.DeleteOp op = FSEditLogOp.DeleteOp.GetInstance(cache);
     op.SetTransactionId(txId);
     op.SetPath(path);
     op.SetTimestamp(0);
     elos.Write(op);
 }
Exemplo n.º 3
0
 /// <summary>Aborts the stream, also sets it to null.</summary>
 public virtual void Abort()
 {
     if (stream == null)
     {
         return;
     }
     try
     {
         stream.Abort();
     }
     catch (IOException ioe)
     {
         Log.Error("Unable to abort stream " + stream, ioe);
     }
     stream = null;
 }
Exemplo n.º 4
0
        /// <exception cref="System.IO.IOException"/>
        internal static void PadEditLog(EditLogOutputStream elos, int paddingLength)
        {
            if (paddingLength <= 0)
            {
                return;
            }
            byte[] buf = new byte[4096];
            for (int i = 0; i < buf.Length; i++)
            {
                buf[i] = unchecked ((byte)unchecked ((byte)(-1)));
            }
            int pad = paddingLength;

            while (pad > 0)
            {
                int toWrite = pad > buf.Length ? buf.Length : pad;
                elos.WriteRaw(buf, 0, toWrite);
                pad -= toWrite;
            }
        }
Exemplo n.º 5
0
 /// <exception cref="System.IO.IOException"/>
 public override void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache
                                           cache)
 {
     for (long txid = 1; txid <= MaxTxid; txid++)
     {
         if (txid == BadTxid)
         {
             byte[] garbage = new byte[] { unchecked ((int)(0x1)), unchecked ((int)(0x2)), unchecked (
                                               (int)(0x3)) };
             elos.WriteRaw(garbage, 0, garbage.Length);
         }
         else
         {
             FSEditLogOp.DeleteOp op;
             op = FSEditLogOp.DeleteOp.GetInstance(cache);
             op.SetTransactionId(txid);
             op.SetPath("/foo." + txid);
             op.SetTimestamp(txid);
             elos.Write(op);
         }
     }
 }
Exemplo n.º 6
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void StartLogSegment(long txId, int layoutVersion)
 {
     Preconditions.CheckState(stream == null);
     disabled = false;
     stream   = journal.StartLogSegment(txId, layoutVersion);
 }
Exemplo n.º 7
0
 internal virtual void SetCurrentStreamForTests(EditLogOutputStream stream)
 {
     this.stream = stream;
 }
Exemplo n.º 8
0
 /// <exception cref="System.IO.IOException"/>
 public override void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache
                                           cache)
 {
     PadEditLog(elos, paddingLength);
     AddDeleteOpcode(elos, cache, 0, "/foo");
 }
Exemplo n.º 9
0
 /// <exception cref="System.IO.IOException"/>
 public override void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache
                                           cache)
 {
     PadEditLog(elos, paddingLength);
 }
Exemplo n.º 10
0
 /// <summary>Set up the edit log.</summary>
 /// <exception cref="System.IO.IOException"/>
 public abstract void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache
                                           cache);