public void Setup() { tokenSource = new CancellationTokenSource(); socketFactory = new Mock <ISocketFactory>(); publisherSocket = new Mock <ISocket>(); subscriberSocket = new Mock <ISocket>(); routerSocket = new Mock <ISocket>(); socketFactory.Setup(m => m.CreateRouterSocket()).Returns(routerSocket.Object); socketFactory.Setup(m => m.CreatePublisherSocket()).Returns(publisherSocket.Object); socketFactory.Setup(m => m.CreateSubscriberSocket()).Returns(subscriberSocket.Object); localSocketFactory = new Mock <ILocalSocketFactory>(); multiplexingSocket = new Mock <ILocalSocket <IMessage> >(); localSocketFactory.Setup(m => m.Create <IMessage>()).Returns(multiplexingSocket.Object); securityProvider = new Mock <ISecurityProvider>(); var pingDomain = Guid.NewGuid().ToString(); securityProvider.Setup(m => m.GetDomain(It.IsAny <byte[]>())).Returns(pingDomain); routerLocalSocket = new Mock <ILocalSendingSocket <IMessage> >(); config = new ClusterHealthMonitorConfiguration { IntercomEndpoint = new Uri("tcp://127.0.0.1:8087"), StalePeersCheckInterval = TimeSpan.FromMinutes(1) }; logger = new Mock <ILogger>(); connectedPeerRegistry = new Mock <IConnectedPeerRegistry>(); connectedPeerRegistry.Setup(m => m.GetPeersWithExpiredHeartBeat()).Returns(Enumerable.Empty <KeyValuePair <ReceiverIdentifier, ClusterMemberMeta> >()); clusterHealthMonitor = new ClusterHealthMonitor(socketFactory.Object, localSocketFactory.Object, securityProvider.Object, routerLocalSocket.Object, connectedPeerRegistry.Object, config, logger.Object); }
public void Setup() { config = new ClusterHealthMonitorConfiguration { PeerIsStaleAfter = TimeSpan.FromSeconds(2), MissingHeartBeatsBeforeDeletion = 3 }; peerRegistry = new ConnectedPeerRegistry(config); }
public ClusterHealthMonitor(ISocketFactory socketFactory, ILocalSocketFactory localSocketFactory, ISecurityProvider securityProvider, ILocalSendingSocket <IMessage> routerLocalSocket, IConnectedPeerRegistry connectedPeerRegistry, ClusterHealthMonitorConfiguration config, ILogger logger) { deadPeersCheckInterval = TimeSpan.FromDays(1); this.socketFactory = socketFactory; this.securityProvider = securityProvider; multiplexingSocket = localSocketFactory.Create <IMessage>(); this.config = config; this.routerLocalSocket = routerLocalSocket; this.connectedPeerRegistry = connectedPeerRegistry; this.logger = logger; }
public ConnectedPeerRegistry(ClusterHealthMonitorConfiguration config) { peers = new HashDictionary <ReceiverIdentifier, ClusterMemberMeta>(); this.config = config; }