LogRecordSequence.TailPinned LogRecordSequence.TailPinned LogRecordSequence.TailPinned LogRecordSequence.TailPinned Event

定义

发信号通知需要移动序列的尾数据。Signals the need to move the tail of the sequence.

public:
 virtual event EventHandler<System::IO::Log::TailPinnedEventArgs ^> ^ TailPinned;
public event EventHandler<System.IO.Log.TailPinnedEventArgs> TailPinned;
member this.TailPinned : EventHandler<System.IO.Log.TailPinnedEventArgs> 
Public Custom Event TailPinned As EventHandler(Of TailPinnedEventArgs) 

实现

示例

此示例演示如何使用 TailPinned 事件。This example shows how to use the TailPinned event.

recordSequence.RetryAppend = true;  
recordSequence.TailPinned += new EventHandler<TailPinnedEventArgs>(HandleTailPinned);  
  
void HandleTailPinned(object sender, TailPinnedEventArgs tailPinnedEventArgs)  
{  
   // tailPinnedEventArgs.TargetSequenceNumber is the target   
   // sequence number to free up space to.    
   // However, this sequence number is not necessarily valid.  We have  
   // to use this sequence number as a starting point for finding a  
   // valid point within the log to advance toward. You need to  
   // identify a record with a sequence number equal to, or greater  
   // than TargetSequenceNumber; let's call this   
   // realTargetSequenceNumber. Once found, move the base  
  
   recordSequence.AdvanceBaseSequenceNumber(realTargetSequenceNumber);  
  
}  

注解

可以在记录序列空间不足时激发此事件。You can fire this event when the record sequence has run out of space. 此事件激发时,序列的尾数据(即基序列号)将前移以释放空间。When this event is fired, the tail of the sequence (that is, the base sequence number) is moved forward to free up space.

当记录序列决定必须释放空间时,可以借任何理由随时激发该事件。The event can be fired at any time when the record sequence decides that it must free up space, for any reason. 例如,当 CLFS 策略引擎确定共享同一日志文件的两个日志客户端的结尾相距过远时,它可能会决定激发该事件。For example, the CLFS policy engine may decide to fire the event when it determines that the tails of two log clients sharing the same log file are too far apart. 可以通过写入重新开始区域、截断日志及使用 AdvanceBaseSequenceNumber 方法清除空间来释放空间。Freeing space can be done by either writing restart areas, or truncating the log and using the AdvanceBaseSequenceNumber method to clear space. “示例”部分的代码示例演示了第二种方式。The code sample in the Example section demonstrates the second approach.

还可以在 WriteRestartArea 事件之外调用 TailPinned 方法以释放空间。You can also call the WriteRestartArea method outside of the TailPinned event to free space. 重新开始区域类似于其他日志处理系统内的检查点。A restart area is similar to a checkpoint in other log processing systems. 调用此方法则表示,在重新开始区域彻底完成以及可用于在以后追加记录之前,应用程序将考虑以前的所有记录。Calling this method indicates that the application considers all prior records before the restart area as fully completed, and usable for future record appends. 与其他任何记录类似,此方法写入的记录需要使用日志中实际的可用空间才有效。Similar to any other records, the record written by this method requires actual free space in the log to function.

适用于