public void WhenClusterMonitorStarts_ClusterRoutesAreRequested() { Func <Barrier, bool> setBarrier = (b) => { b.SignalAndWait(); return(true); }; autoDiscoveryListener.Setup(m => m.StartBlockingListenMessages(It.IsAny <Action>(), It.IsAny <CancellationToken>(), It.Is <Barrier>(b => setBarrier(b)))); autoDiscoverySender.Setup(m => m.StartBlockingSendMessages(It.IsAny <CancellationToken>(), It.Is <Barrier>(b => setBarrier(b)))); // clusterMonitor.Start(); // Func <Message, bool> isRequestClusterRoutesMessage = (msg) => { if (msg.Equals(MessageIdentifier.Create <RequestClusterMessageRoutesMessage>())) { var payload = msg.GetPayload <RequestClusterMessageRoutesMessage>(); Assert.IsTrue(Unsafe.ArraysEqual(scaleOutAddress.Identity, payload.RequestorNodeIdentity)); Assert.AreEqual(scaleOutAddress.Uri.ToSocketAddress(), payload.RequestorUri); return(true); } return(false); }; autoDiscoverySender.Verify(m => m.EnqueueMessage(It.Is <IMessage>(msg => isRequestClusterRoutesMessage(msg.As <Message>()))), Times.Once); }
public ClusterMonitor Create(bool start = true) { if (_role == NodeRole.StandAlone) return CreateStandAlone(); var monitor = new ClusterMonitor(_role, _localAddress, _partnerAddress, state => { switch (state.Status) { case NodeStatus.Connecting: if (_whenConnecting != null) _whenConnecting(); break; case NodeStatus.Active: if (_whenActive != null) _whenActive(); break; case NodeStatus.Passive: if (_whenPassive != null) _whenPassive(); break; case NodeStatus.Stopped: if (_whenStopped != null) _whenStopped(); break; } }, _onClusterException, _confirmActivationFuncs, _partnerTimeout, _connectTimeout, _becomeActiveWhenPrimaryOnInitialConnectionTimeout); if (start) monitor.Start(); return monitor; }
public bool Start(HostControl hostControl) { if (_clusterMonitor.Role == NodeRole.StandAlone) { StartFeed(); } else { _clusterMonitor.Start(); } return(true); }