/// <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; }
/// <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); }
/// <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; }
/// <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; } }
/// <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); } } }
/// <exception cref="System.IO.IOException"/> public virtual void StartLogSegment(long txId, int layoutVersion) { Preconditions.CheckState(stream == null); disabled = false; stream = journal.StartLogSegment(txId, layoutVersion); }
internal virtual void SetCurrentStreamForTests(EditLogOutputStream stream) { this.stream = stream; }
/// <exception cref="System.IO.IOException"/> public override void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache cache) { PadEditLog(elos, paddingLength); AddDeleteOpcode(elos, cache, 0, "/foo"); }
/// <exception cref="System.IO.IOException"/> public override void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache cache) { PadEditLog(elos, paddingLength); }
/// <summary>Set up the edit log.</summary> /// <exception cref="System.IO.IOException"/> public abstract void AddTransactionsToLog(EditLogOutputStream elos, FSEditLogOp.OpInstanceCache cache);