public static void HandleTailPinned(object arg, TailPinnedEventArgs tailPinnedEventArgs) { Console.WriteLine("TailPinned has fired"); // Based on the implementation of a logging application, the log base can be moved // to free up more log space and if it is not possible to move the // base, the application should report by throwing an exception. if (MyLog.AdvanceBase) { try { // TailPnnedEventArgs has the recommended sequence number and its generated // based on PinnedTailThreshold policy. // This does not map to an actual sequence number in the record sequence // but an approximation and potentially frees up the threshold % log space // when the log base is advanced to a valid sequence number closer to the // recommended sequence number. // The user should use this sequence number to locate a closest valid sequence // number to advance the base of the log. SequenceNumber recommendedTargetSeqNum = tailPinnedEventArgs.TargetSequenceNumber; // Get the actual Target sequence number. SequenceNumber actualTargetSeqNum = MyLog.GetAdvanceBaseSeqNumber(recommendedTargetSeqNum); MySequence.AdvanceBaseSequenceNumber(actualTargetSeqNum); } catch (Exception e) { Console.WriteLine("Exception thrown {0} {1}", e.GetType(), e.Message); } } else { // Report back Error if under some conditions the log cannot // advance the base sequence number. Console.WriteLine("Reporting Error! Unable to move the base sequence number!"); throw new IOException(); } }
private void TailPinned(object sender, TailPinnedEventArgs e) { Debug.WriteLine($"Log {this.logFileBase}: tail pinned! Suggested that we advance base to {e.TargetSequenceNumber.Identifier()}"); }