///<summary>Construct an OperationInterruptedException with ///the passed-in explanation and prefix, if any.</summary> public OperationInterruptedException(ShutdownEventArgs reason, String prefix) : base(reason == null ? (prefix + ": The AMQP operation was interrupted") : string.Format("{0}: The AMQP operation was interrupted: {1}", prefix, reason)) { ShutdownReason = reason; }
///<summary>Construct an OperationInterruptedException with ///the passed-in explanation, if any.</summary> public OperationInterruptedException(ShutdownEventArgs reason) : base(reason == null ? "The AMQP operation was interrupted" : string.Format("The AMQP operation was interrupted: {0}", reason)) { m_shutdownReason = reason; }
private static void Shutdown(ShutdownEventArgs args) { if (Server != null) { Server.Stop(); } }
public static void EventSink_Shutdown(ShutdownEventArgs e) { try { World.Broadcast(0x35, true, "The server has shut down."); } catch { } }
///<summary>Construct an instance containing the given ///shutdown reason.</summary> public AlreadyClosedException(ShutdownEventArgs reason) : base(reason) { }
public void InternalClose(ShutdownEventArgs reason) { if (!SetCloseReason(reason)) { if (m_closed) { throw new AlreadyClosedException(m_closeReason); } // We are quiescing, but still allow for server-close } OnShutdown(); m_session0.SetSessionClosing(true); TerminateMainloop(); }
///<summary>Try to close connection in a graceful way</summary> ///<remarks> ///<para> ///Shutdown reason contains code and text assigned when closing the connection, ///as well as the information about what initiated the close ///</para> ///<para> ///Abort flag, if true, signals to close the ongoing connection immediately ///and do not report any errors if it was already closed. ///</para> ///<para> ///Timeout determines how much time internal close operations should be given ///to complete. Negative or Timeout.Infinite value mean infinity. ///</para> ///</remarks> public void Close(ShutdownEventArgs reason, bool abort, int timeout) { if (!SetCloseReason(reason)) { if (!abort) { throw new AlreadyClosedException(m_closeReason); } } else { OnShutdown(); m_session0.SetSessionClosing(false); try { // Try to send connection.close // Wait for CloseOk in the MainLoop m_session0.Transmit(ConnectionCloseWrapper(reason.ReplyCode, reason.ReplyText)); } catch (AlreadyClosedException ace) { if (!abort) { throw ace; } } #pragma warning disable 0168 catch (NotSupportedException nse) { // buffered stream had unread data in it and Flush() // was called, ignore to not confuse the user } #pragma warning restore 0168 catch (IOException ioe) { if (m_model0.CloseReason == null) { if (!abort) { throw ioe; } else { LogCloseError("Couldn't close connection cleanly. " + "Socket closed unexpectedly", ioe); } } } finally { TerminateMainloop(); } } #if NETFX_CORE var receivedSignal = m_appContinuation.WaitOne(BlockingCell.validatedTimeout(timeout)); #else var receivedSignal = m_appContinuation.WaitOne(BlockingCell.validatedTimeout(timeout)); #endif if (!receivedSignal) { m_frameHandler.Close(); } }
public bool SetCloseReason(ShutdownEventArgs reason) { lock (m_eventLock) { if (m_closeReason == null) { m_closeReason = reason; return true; } else { return false; } } }
protected bool ShouldTriggerConnectionRecovery(ShutdownEventArgs args) { return (args.Initiator == ShutdownInitiator.Peer || // happens when EOF is reached, e.g. due to RabbitMQ node // connectivity loss or abrupt shutdown args.Initiator == ShutdownInitiator.Library); }
public virtual void OnModelShutdown(ShutdownEventArgs reason) { m_delegate.OnModelShutdown(reason); }
public void Close(ShutdownEventArgs reason, bool abort) { try { m_delegate.Close(reason, abort); } finally { m_connection.UnregisterModel(this); } }
public virtual void HandleModelShutdown(ShutdownEventArgs reason) { m_cell.Value = Either.Right(reason); }
public static void InvokeShutdown(ShutdownEventArgs e) { if (Shutdown != null) Shutdown(e); }
public void HandleConnectionStart(byte versionMajor, byte versionMinor, IDictionary<string, object> serverProperties, byte[] mechanisms, byte[] locales) { if (m_connectionStartCell == null) { var reason = new ShutdownEventArgs(ShutdownInitiator.Library, Constants.CommandInvalid, "Unexpected Connection.Start"); ((Connection)Session.Connection).Close(reason); } var details = new ConnectionStartDetails { m_versionMajor = versionMajor, m_versionMinor = versionMinor, m_serverProperties = serverProperties, m_mechanisms = mechanisms, m_locales = locales }; m_connectionStartCell.Value = details; m_connectionStartCell = null; }
public void HandleConnectionClose(ushort replyCode, string replyText, ushort classId, ushort methodId) { var reason = new ShutdownEventArgs(ShutdownInitiator.Peer, replyCode, replyText, classId, methodId); try { ((Connection)Session.Connection).InternalClose(reason); _Private_ConnectionCloseOk(); SetCloseReason((Session.Connection).CloseReason); } catch (IOException) { // Ignored. We're only trying to be polite by sending // the close-ok, after all. } catch (AlreadyClosedException) { // Ignored. We're only trying to be polite by sending // the close-ok, after all. } }
// You will note there are two practically identical overloads // of OnShutdown() here. This is because Microsoft's C# // compilers do not consistently support the Liskov // substitutability principle. When I use // OnShutdown(object,ShutdownEventArgs), the compilers // complain that OnShutdown can't be placed into a // ConnectionShutdownEventHandler because object doesn't // "match" IConnection, even though there's no context in // which the program could Go Wrong were it to accept the // code. The same problem appears for // ModelShutdownEventHandler. The .NET 1.1 compiler complains // about these two cases, and the .NET 2.0 compiler does not - // presumably they improved the type checker with the new // release of the compiler. public virtual void OnConnectionShutdown(object sender, ShutdownEventArgs reason) { m_cell.Value = reason; }
public virtual void OnModelShutdown(IModel sender, ShutdownEventArgs reason) { m_cell.Value = reason; }
public void OnSessionShutdown(ISession session, ShutdownEventArgs reason) { m_delegate.OnSessionShutdown(session, reason); }
public void HandleSessionShutdown(object sender, ShutdownEventArgs reason) { lock (m_sessionMap) { var session = (ISession) sender; m_sessionMap.Remove(session.ChannelNumber); Ints.Free(session.ChannelNumber); CheckAutoClose(); } }
public bool SetCloseReason(ShutdownEventArgs reason) { return m_delegate.SetCloseReason(reason); }
public void Close(ShutdownEventArgs reason) { m_delegate.Close(reason); }
/// <summary> /// The disconnect event handler. /// </summary> /// <param name="connection"> /// The connection. /// </param> /// <param name="eventArgs"> /// The event args. /// </param> private void DisconnectEventHandler(IConnection connection, ShutdownEventArgs eventArgs) { Task.Factory.StartNew( () => { connection.ConnectionShutdown -= this.DisconnectEventHandler; this.OnDisconnected(); this.HandleBusFailure(new BusConnectionException("Connection was shut down on [{0}].".FormatEx(this.Endpoint))); }); }
public void Close(ShutdownEventArgs reason) { Close(reason, false, Timeout.Infinite); }
// // Shutdown // protected void AssertShutdownError(ShutdownEventArgs args, int code) { Assert.AreEqual(args.ReplyCode, code); }
public void HandleMainLoopException(ShutdownEventArgs reason) { if (!SetCloseReason(reason)) { LogCloseError("Unexpected Main Loop Exception while closing: " + reason, new Exception(reason.ToString())); return; } OnShutdown(); LogCloseError("Unexpected connection closure: " + reason, new Exception(reason.ToString())); }
protected void AssertPreconditionFailed(ShutdownEventArgs args) { AssertShutdownError(args, Constants.PreconditionFailed); }
public override void HandleModelShutdown(IModel m, ShutdownEventArgs reason) { throw new SystemException("oops"); }
protected bool InitiatedByPeerOrLibrary(ShutdownEventArgs evt) { return !(evt.Initiator == ShutdownInitiator.Application); }
///<summary>Fires the Shutdown event.</summary> public override void HandleModelShutdown(IModel model, ShutdownEventArgs reason) { base.HandleModelShutdown(model, reason); if (Shutdown != null) { Shutdown(this, reason); } }
public override void HandleModelShutdown(object model, ShutdownEventArgs reason) { // keep track of duplicates if (this.Latch.WaitOne(0)){ this.DuplicateLatch.Set(); } else { this.Latch.Set(); } }