/// <exception cref="System.IO.IOException"/> internal EditLogBackupInputStream(string name) { address = name; inner = new EditLogBackupInputStream.ByteBufferInputStream(); @in = null; reader = null; }
/// <exception cref="System.IO.IOException"/> internal virtual void SetBytes(byte[] newBytes, int version) { inner.SetData(newBytes); tracker = new FSEditLogLoader.PositionTrackingInputStream(inner); @in = new DataInputStream(tracker); this.version = version; reader = new FSEditLogOp.Reader(@in, tracker, version); }
/// <exception cref="Org.Apache.Hadoop.Hdfs.Server.Namenode.EditLogFileInputStream.LogHeaderCorruptException /// "/> /// <exception cref="System.IO.IOException"/> private void Init(bool verifyLayoutVersion) { Preconditions.CheckState(state == EditLogFileInputStream.State.Uninit); BufferedInputStream bin = null; try { fStream = log.GetInputStream(); bin = new BufferedInputStream(fStream); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); dataIn = new DataInputStream(tracker); try { logVersion = ReadLogVersion(dataIn, verifyLayoutVersion); } catch (EOFException) { throw new EditLogFileInputStream.LogHeaderCorruptException("No header found in log" ); } // We assume future layout will also support ADD_LAYOUT_FLAGS if (NameNodeLayoutVersion.Supports(LayoutVersion.Feature.AddLayoutFlags, logVersion ) || logVersion < NameNodeLayoutVersion.CurrentLayoutVersion) { try { LayoutFlags.Read(dataIn); } catch (EOFException) { throw new EditLogFileInputStream.LogHeaderCorruptException("EOF while reading layout " + "flags from log"); } } reader = new FSEditLogOp.Reader(dataIn, tracker, logVersion); reader.SetMaxOpSize(maxOpSize); state = EditLogFileInputStream.State.Open; } finally { if (reader == null) { IOUtils.Cleanup(Log, dataIn, tracker, bin, fStream); state = EditLogFileInputStream.State.Closed; } } }
/// <summary>Construct BookKeeper edit log input stream.</summary> /// <remarks> /// Construct BookKeeper edit log input stream. /// Starts reading from firstBookKeeperEntry. This allows the stream /// to take a shortcut during recovery, as it doesn't have to read /// every edit log transaction to find out what the last one is. /// </remarks> /// <exception cref="System.IO.IOException"/> internal BookKeeperEditLogInputStream(LedgerHandle lh, EditLogLedgerMetadata metadata , long firstBookKeeperEntry) { this.lh = lh; this.firstTxId = metadata.GetFirstTxId(); this.lastTxId = metadata.GetLastTxId(); this.logVersion = metadata.GetDataLayoutVersion(); this.inProgress = metadata.IsInProgress(); if (firstBookKeeperEntry < 0 || firstBookKeeperEntry > lh.GetLastAddConfirmed()) { throw new IOException("Invalid first bk entry to read: " + firstBookKeeperEntry + ", LAC: " + lh.GetLastAddConfirmed()); } BufferedInputStream bin = new BufferedInputStream(new BookKeeperEditLogInputStream.LedgerInputStream (lh, firstBookKeeperEntry)); tracker = new FSEditLogLoader.PositionTrackingInputStream(bin); DataInputStream @in = new DataInputStream(tracker); reader = new FSEditLogOp.Reader(@in, tracker, logVersion); }
/// <exception cref="System.IO.IOException"/> internal virtual void Clear() { SetBytes(null, 0); reader = null; this.version = 0; }