private void RaiseHeartbeatFailed() { _currentConsumerTaskCancellation.Cancel(); _heartbeatSocket.Close(); _heartbeatSocket.Dispose(); _consumerSocket.Close(); _consumerSocket.Dispose(); }
public void Dispose() { _cancel.Cancel(); _heartbeatSocket.Close(); _heartbeatSocket.Dispose(); }
/// <summary> /// Stop node discovery and interconnection /// </summary> private void Stop() { if (!_isRunning) { return; } _loggerDelegate?.Invoke($"Stopping {_name} {_uuid.ToShortString6()}. Publishing beacon on port 0. Removing _beacon and _inbox from poller."); // Stop broadcast/listen beacon by broadcasting port 0 PublishBeacon(0); Thread.Sleep(1); // Allow 1 millisecond for beacon to go out _poller.Remove(_beacon); _beacon.ReceiveReady -= OnBeaconReady; _beacon.Unsubscribe(); _beacon.Dispose(); _beacon = null; // Stop polling on inbox _poller.Remove(_inbox); _inbox.ReceiveReady -= OnInboxReady; _inbox.Dispose(); // Tell the application we are stopping var msg = new NetMQMessage(3); msg.Append("STOP"); msg.Append(_uuid.ToByteArray()); msg.Append(_name); _outbox.SendMultipartMessage(msg); _isRunning = false; }
/// <summary> /// Release any contained resources. /// </summary> /// <param name="disposing">true if managed resources are to be released</param> protected virtual void Dispose(bool disposing) { if (!disposing) { return; } if (_isRunning) { Stop(); } if (_poller.IsRunning) { _poller?.Stop(); } _poller?.Dispose(); _beacon?.Dispose(); _inbox?.Dispose(); _outbox?.Dispose(); foreach (var peer in _peers.Values) { peer.Destroy(); } foreach (var group in _peerGroups.Values) { group.Dispose(); } foreach (var group in _ownGroups.Values) { group.Dispose(); } }
public void Kill() { _poller.Stop(); _frontend.Close(); _frontend.Dispose(); _backend.Close(); _backend.Dispose(); }
public void Stop() { _cancel.Cancel(); _heartbeatSocket.Close(); _heartbeatSocket.Dispose(); _publisherSocket.Close(); _publisherSocket.Dispose(); }
private void ProxyThread() { RouterSocket router = null; DealerSocket dealer = null; try { router = _ctx.CreateRouterSocket(); dealer = _ctx.CreateDealerSocket(); router.Bind(_frontendAddress); switch (_backendCxMode) { case ConnectionMode.Connect: dealer.Connect(_backendAddress); break; case ConnectionMode.Bind: dealer.Bind(_backendAddress); break; } router.Options.Linger = TimeSpan.Zero; dealer.Options.Linger = TimeSpan.Zero; var xproxy = new Proxy(router, dealer, null); xproxy.Start(); } catch (TerminatingException) { } finally { if (router != null) { try { router.Dispose(); } catch (NetMQException) { } } if (dealer != null) { try { dealer.Dispose(); } catch (NetMQException) { } } } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { shellSocket?.Dispose(); controlSocket?.Dispose(); ioPubSocket?.Dispose(); } disposedValue = true; } }
public void NetMQReceiver_WithNullSerializer_ThrowsArgumentNullException() { // Arrange var socket = new RouterSocket(); // Act TestDelegate test = () => new NetMQReceiver(socket, null, requestDispatcher); // Assert Assert.That(test, Throws.ArgumentNullException); // Cleanup socket.Dispose(); }
protected override Task DestroyInternal() { _cancel.Cancel(); _poller.Stop(); _heartbeatSocket.Close(); _heartbeatSocket.Dispose(); _stateRequestSocket.Close(); _stateRequestSocket.Dispose(); return(Task.CompletedTask); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { _poller?.Dispose(); _responseSocket?.Dispose(); _publisherSocket?.Dispose(); } disposedValue = true; } }
public void NetMQReceiver_WithNullRequestDispatcher_ThrowsArgumentNullException() { // Arrange var socket = new RouterSocket(); // Act TestDelegate construct = () => new NetMQReceiver(socket, messageFactory, null); // Assert Assert.That(construct, Throws.ArgumentNullException); // Cleanup socket.Dispose(); }
public override void Dispose() { try { _router.Dispose(); _runtime.Dispose(); } catch (Exception e) { _logger.LogError(e.ToString()); } finally { base.Dispose(); } }
public void Kill() { _poller.Stop(); _heartbeat.Close(); _heartbeat.Dispose(); _frontend.Close(); _frontend.Dispose(); _backend.Close(); _backend.Dispose(); _workerQueue.Dispose(); _workQueue.Dispose(); }
public void DisposeThrowsIfSocketAlreadyDisposed() { var socket = new RouterSocket(); var poller = new NetMQPoller { socket }; // Dispose the socket. // It is incorrect to have a disposed socket in a poller. // Disposed sockets can throw into the poller's thread. socket.Dispose(); // Dispose throws if a polled socket is disposed var ex = Assert.Throws <NetMQException>(() => poller.Dispose()); Assert.AreEqual("Invalid state detected: NetMQPoller contains a disposed NetMQSocket. Sockets must be either removed before being disposed, or disposed after the poller is disposed.", ex.Message); }
public override Task Stop() { _cancel.Cancel(); _poller.Stop(); _heartbeat.Close(); _heartbeat.Dispose(); _frontend.Close(); _frontend.Dispose(); _backend.Close(); _backend.Dispose(); return(Task.CompletedTask); }
/// <summary> /// Cleans up resources /// </summary> private void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { TerminateConnection(); if (!(socket is null)) { socket.ReceiveReady -= OnRequestReceived; socket.Dispose(); socket = null; } } disposedValue = true; } }
/// <summary> /// Shut down the service and clean up resources. /// </summary> new public void Stop() { if (IsRunning) { try { _routerSocket.Disconnect(_facadeAddress); _routerSocket.Dispose(); base.Stop(); } finally { IsRunning = false; NetMQConfig.Cleanup(); } } }
public void Addresses_WhenDisposed_ThrowsInvalidOperationException() { // Arrange var socket = new RouterSocket(); var receiver = new NetMQReceiver(socket, messageFactory, requestDispatcher); var address = TcpAddress.Wildcard(5555); receiver.Dispose(); // Act void AddAddress() => receiver.AddAddress(address); // Assert Assert.That(AddAddress, Throws.TypeOf <InvalidOperationException>()); // Cleanup socket.Dispose(); }
public void Stop() { _cancel.Cancel(); _poller.Stop(); _heartbeat.Close(); _heartbeat.Dispose(); _publishStateUpdate.Close(); _publishStateUpdate.Dispose(); _subscribeToUpdates.Close(); _subscribeToUpdates.Dispose(); _stateRequest.Close(); _stateRequest.Dispose(); }
public void AddThrowsIfSocketAlreadyDisposed() { var poller = new NetMQPoller(); var socket = new RouterSocket(); // Dispose the socket. // It is incorrect to have a disposed socket in a poller. // Disposed sockets can throw into the poller's thread. socket.Dispose(); // Adding a disposed socket throws var ex = Assert.Throws <ArgumentException>(() => poller.Add(socket)); Assert.True(ex.Message.StartsWith("Must not be disposed.")); Assert.AreEqual("socket", ex.ParamName); // Still dispose it. It throws after cleanup. Assert.Throws <NetMQException>(() => poller.Dispose()); }
public async Task DisposeAsync() { _logger.Debug("Disposing..."); if (_contextInitialized) { _removedPeers[AsPeer] = DateTime.UtcNow; await DistributeDeltaAsync(false); _router.Dispose(); _deltas.Dispose(); foreach (DealerSocket s in _dealers.Values) { s.Dispose(); } _dealers.Clear(); _contextInitialized = false; } _logger.Debug("Disposed."); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { _disposed = true; //prevent second call to Dispose if (disposing) { if (null != _sessionCleanupTimer) { _sessionCleanupTimer.Enable = false; } if (null != _socketPoller) { _socketPoller.Dispose(); } if (null != _sendQueue) { _sendQueue.Dispose(); } if (null != _routerSocket) { _routerSocket.Dispose(); } if (null != _hostPoller) { _hostPoller.Dispose(); } if (null != _receivedQueue) { _receivedQueue.Dispose(); } if (null != _sendFailureQueue) { _sendFailureQueue.Dispose(); } } } }
protected override void Cleanup() { m_frontend.Dispose(); m_backend.Dispose(); }
protected override void Cleanup() { m_frontend.Dispose(); m_backend.Dispose(); Console.WriteLine("Cleanup"); }
public override void Dispose() { poller?.Dispose(); dealerSocket?.Dispose(); routerSocket?.Dispose(); }
public void Dispose() { _input?.Dispose(); _output?.Dispose(); }
protected override void Cleanup() { m_serverSocket.Dispose(); }