Esempio n. 1
0
 private void TailPinned(object sender, TailPinnedEventArgs e)
 {
     Debug.WriteLine($"Log {this.logFileBase}: tail pinned! Suggested that we advance base to {e.TargetSequenceNumber.Identifier()}");
 }
        void HandleTailPinned()
        {
            TailPinnedEventArgs args;
            SequenceNumber targetLsn;

            targetLsn = new SequenceNumber(this.notification.Lsn);
            args = new TailPinnedEventArgs(targetLsn);

            EventHandler<TailPinnedEventArgs> handler;
            handler = this.InternalTailPinned;
            if (handler != null)
            {
                try
                {
                    handler(this, args);
                }
#pragma warning suppress 56500 // This is a callback exception
                catch (Exception e)
                {
                    try
                    {
                        int errorCode = Marshal.GetHRForException(e);
                        UnsafeNativeMethods.LogTailAdvanceFailure(this.logStore.Handle, errorCode);
                    }
#pragma warning suppress 56500 // We will be terminating the process with any exception in this call
                    catch (Exception exception)
                    {
                        // If LogTailAdvanceFailure fails, there's nothing we can do to recover.
                        // If we keep executing, the log's tail will be pinned forever.
                        // CLFS will never know that we have finished with its notification.
                        DiagnosticUtility.InvokeFinalHandler(exception);
                    }

                    if (Fx.IsFatal(e))
                        throw;
                }
            }
            else
            {
                // User hasn't subscribed to TailPinnned. If RetryAppend is true, IO.Log will register for 
                // notification and invoke CLFS policy to handle LogFull Condition.
                // IO.Log must report to CLFS that the log tail cannot be advanced. CLFS expects either
                // base to be advanced or report the failure else it will hang waiting for the outcome.
                //

                try
                {
                    UnsafeNativeMethods.LogTailAdvanceFailure(this.logStore.Handle, 0);
                }
#pragma warning suppress 56500 // We will be terminating the process with any exception in this call
                catch (Exception exception)
                {
                    // If LogTailAdvanceFailure fails, there's nothing we can do to recover.
                    // If we keep executing, the log's tail will be pinned forever.
                    // CLFS will never know that we have finished with its notification.
                    DiagnosticUtility.InvokeFinalHandler(exception);
                }

            }
        }
        void HandleTailPinned()
        {
            TailPinnedEventArgs args;
            SequenceNumber      targetLsn;

            targetLsn = new SequenceNumber(this.notification.Lsn);
            args      = new TailPinnedEventArgs(targetLsn);

            EventHandler <TailPinnedEventArgs> handler;

            handler = this.InternalTailPinned;
            if (handler != null)
            {
                try
                {
                    handler(this, args);
                }
#pragma warning suppress 56500 // This is a callback exception
                catch (Exception e)
                {
                    try
                    {
                        int errorCode = Marshal.GetHRForException(e);
                        UnsafeNativeMethods.LogTailAdvanceFailure(this.logStore.Handle, errorCode);
                    }
#pragma warning suppress 56500 // We will be terminating the process with any exception in this call
                    catch (Exception exception)
                    {
                        // If LogTailAdvanceFailure fails, there's nothing we can do to recover.
                        // If we keep executing, the log's tail will be pinned forever.
                        // CLFS will never know that we have finished with its notification.
                        DiagnosticUtility.InvokeFinalHandler(exception);
                    }

                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }
                }
            }
            else
            {
                // User hasn't subscribed to TailPinnned. If RetryAppend is true, IO.Log will register for
                // notification and invoke CLFS policy to handle LogFull Condition.
                // IO.Log must report to CLFS that the log tail cannot be advanced. CLFS expects either
                // base to be advanced or report the failure else it will hang waiting for the outcome.
                //

                try
                {
                    UnsafeNativeMethods.LogTailAdvanceFailure(this.logStore.Handle, 0);
                }
#pragma warning suppress 56500 // We will be terminating the process with any exception in this call
                catch (Exception exception)
                {
                    // If LogTailAdvanceFailure fails, there's nothing we can do to recover.
                    // If we keep executing, the log's tail will be pinned forever.
                    // CLFS will never know that we have finished with its notification.
                    DiagnosticUtility.InvokeFinalHandler(exception);
                }
            }
        }