Exemplo n.º 1
0
 internal Socket(NetMQSocket socket, SocketConfiguration config)
 {
     socket.Options.Linger = config.Linger;
     socket.Options.ReceiveHighWatermark = config.ReceivingHighWatermark;
     socket.Options.SendHighWatermark = config.SendingHighWatermark;
     this.socket = socket;
 }
        internal static RoundBasedRegisterTestSetup CreateRoundBasedRegister(IEnumerable<string> synod, string localNodeUri)
        {
            var intercomMessageHubSocketFactory = new IntercomMessageHubSocketFactory();
            var socketFactory = new Mock<ISocketFactory>();
            socketFactory.Setup(m => m.CreateSubscriberSocket()).Returns(intercomMessageHubSocketFactory.CreateSubscriberSocket);
            var appConfig = new ApplicationConfiguration
                            {
                                Synod = new SynodConfiguration
                                        {
                                            Members = synod,
                                            ClockDrift = TimeSpan.FromMilliseconds(100),
                                            MessageRoundtrip = TimeSpan.FromSeconds(4),
                                            NodeResponseTimeout = TimeSpan.FromSeconds(2),
                                            LocalNode = localNodeUri,
                                            MaxLeaseTimeSpan = TimeSpan.FromSeconds(10)
                                        }
                            };
            var leaseConfig = new LeaseConfiguration
                              {
                                  ClockDrift = appConfig.Synod.ClockDrift,
                                  MaxLeaseTimeSpan = appConfig.Synod.MaxLeaseTimeSpan,
                                  MessageRoundtrip = appConfig.Synod.MessageRoundtrip,
                                  NodeResponseTimeout = appConfig.Synod.NodeResponseTimeout
                              };
            var socketConfig = new SocketConfiguration
                               {
                                   ReceivingHighWatermark = 1000,
                                   SendingHighWatermark = 1000,
                                   Linger = TimeSpan.Zero
                               };
            var synodConfig = new Rendezvous.Consensus.SynodConfiguration(new SynodConfigurationProvider(appConfig));
            var loggerMock = new Mock<ILogger>();
            var intercomMessageHub = new IntercomMessageHub(new SocketFactory(socketConfig),
                                                            synodConfig,
                                                            loggerMock.Object);
            var ballotGenerator = new BallotGenerator(leaseConfig);
            var roundBasedRegister = new RoundBasedRegister(intercomMessageHub,
                                                            ballotGenerator,
                                                            synodConfig,
                                                            leaseConfig,
                                                            loggerMock.Object);

            Thread.Sleep(TimeSpan.FromMilliseconds(400));

            return new RoundBasedRegisterTestSetup(ballotGenerator, synodConfig.LocalNode, roundBasedRegister);
        }
Exemplo n.º 3
0
 public SocketFactory(SocketConfiguration config)
 {
     context = NetMQContext.Create();
     this.config = config ?? CreateDefaultConfiguration();
 }