コード例 #1
0
 public NodeLifecycleManagerFactory(INodeTable nodeTable, IDiscoveryMessageFactory discoveryMessageFactory, IEvictionManager evictionManager, INodeStatsManager nodeStatsManager, IDiscoveryConfig discoveryConfig, ILogManager logManager)
 {
     _logger                  = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
     _nodeTable               = nodeTable ?? throw new ArgumentNullException(nameof(nodeTable));
     _discoveryConfig         = discoveryConfig ?? throw new ArgumentNullException(nameof(discoveryConfig));
     _discoveryMessageFactory = discoveryMessageFactory ?? throw new ArgumentNullException(nameof(discoveryMessageFactory));
     _evictionManager         = evictionManager ?? throw new ArgumentNullException(nameof(evictionManager));
     _nodeStatsManager        = nodeStatsManager ?? throw new ArgumentNullException(nameof(nodeStatsManager));
 }
コード例 #2
0
 public NodeLifecycleManagerFactory(INodeFactory nodeFactory, INodeTable nodeTable, ILogger logger, IDiscoveryConfigurationProvider discoveryConfigurationProvider, IDiscoveryMessageFactory discoveryMessageFactory, IEvictionManager evictionManager, INodeStatsProvider nodeStatsProvider)
 {
     _nodeFactory = nodeFactory;
     _nodeTable   = nodeTable;
     _logger      = logger;
     _discoveryConfigurationProvider = discoveryConfigurationProvider;
     _discoveryMessageFactory        = discoveryMessageFactory;
     _evictionManager   = evictionManager;
     _nodeStatsProvider = nodeStatsProvider;
 }
コード例 #3
0
 public NodeLifecycleManager(Node node, IDiscoveryManager discoveryManager, INodeTable nodeTable, IDiscoveryMessageFactory discoveryMessageFactory, IEvictionManager evictionManager, INodeStats nodeStats, IDiscoveryConfig discoveryConfig, ILogger logger)
 {
     _discoveryManager        = discoveryManager;
     _nodeTable               = nodeTable;
     _logger                  = logger;
     _discoveryConfig         = discoveryConfig;
     _discoveryMessageFactory = discoveryMessageFactory;
     _evictionManager         = evictionManager;
     NodeStats                = nodeStats;
     ManagedNode              = node;
     UpdateState(NodeLifecycleState.New);
 }
コード例 #4
0
 public NodeLifecycleManager(Node node, IDiscoveryManager discoveryManager, INodeTable nodeTable, ILogger logger, IConfigProvider configurationProvider, IDiscoveryMessageFactory discoveryMessageFactory, IEvictionManager evictionManager, INodeStats nodeStats)
 {
     _discoveryManager        = discoveryManager;
     _nodeTable               = nodeTable;
     _logger                  = logger;
     _configurationProvider   = configurationProvider.GetConfig <NetworkConfig>();
     _discoveryMessageFactory = discoveryMessageFactory;
     _evictionManager         = evictionManager;
     NodeStats                = nodeStats;
     ManagedNode              = node;
     UpdateState(NodeLifecycleState.New);
 }
コード例 #5
0
        public void Initialize()
        {
            _discoveryManagerMock = Substitute.For <IDiscoveryManager>();
            _discoveryConfigMock  = Substitute.For <IDiscoveryConfig>();


            NetworkNodeDecoder.Init();
            SetupNodeIds();

            var logManager = LimboLogs.Instance;

            _loggerMock = Substitute.For <ILogger>();
            //setting config to store 3 nodes in a bucket and for table to have one bucket//setting config to store 3 nodes in a bucket and for table to have one bucket

            _configurationProvider    = new ConfigProvider();
            _networkConfig.ExternalIp = "99.10.10.66";
            _networkConfig.LocalIp    = "10.0.0.5";

            IDiscoveryConfig discoveryConfig = _configurationProvider.GetConfig <IDiscoveryConfig>();

            discoveryConfig.PongTimeout  = 50;
            discoveryConfig.BucketSize   = 3;
            discoveryConfig.BucketsCount = 1;

            _ipResolverMock = Substitute.For <IIPResolver>();

            IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>();

            var calculator = new NodeDistanceCalculator(discoveryConfig);

            _nodeTable = new NodeTable(calculator, discoveryConfig, _networkConfig, logManager);
            _nodeTable.Initialize(TestItem.PublicKeyA);
            _nodeStatsMock = Substitute.For <INodeStats>();

            _timestamper = Timestamper.Default;

            var evictionManager = new EvictionManager(_nodeTable, logManager);

            _evictionManagerMock = Substitute.For <IEvictionManager>();
            var lifecycleFactory = new NodeLifecycleManagerFactory(_nodeTable, new DiscoveryMessageFactory(_timestamper), evictionManager, new NodeStatsManager(statsConfig, logManager), discoveryConfig, logManager);

            _udpClient = Substitute.For <IMessageSender>();

            var discoveryDb = new SimpleFilePublicKeyDb("Test", "test", logManager);

            _discoveryManager = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(discoveryDb, logManager), discoveryConfig, logManager, _ipResolverMock);
            _discoveryManager.MessageSender = _udpClient;

            _discoveryManagerMock = Substitute.For <IDiscoveryManager>();
        }
コード例 #6
0
 public NodeLifecycleManagerFactory(INodeTable nodeTable,
                                    IEvictionManager evictionManager,
                                    INodeStatsManager nodeStatsManager,
                                    NodeRecord self,
                                    IDiscoveryConfig discoveryConfig,
                                    ITimestamper timestamper,
                                    ILogManager?logManager)
 {
     _logger           = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
     _nodeTable        = nodeTable ?? throw new ArgumentNullException(nameof(nodeTable));
     _discoveryConfig  = discoveryConfig ?? throw new ArgumentNullException(nameof(discoveryConfig));
     _timestamper      = timestamper ?? throw new ArgumentNullException(nameof(timestamper));
     _evictionManager  = evictionManager ?? throw new ArgumentNullException(nameof(evictionManager));
     _nodeStatsManager = nodeStatsManager ?? throw new ArgumentNullException(nameof(nodeStatsManager));
     _selfNodeRecord   = self ?? throw new ArgumentNullException(nameof(self));
 }
コード例 #7
0
        public void Setup()
        {
            _discoveryManagerMock = Substitute.For <IDiscoveryManager>();
            _discoveryConfigMock  = Substitute.For <IDiscoveryConfig>();

            NetworkNodeDecoder.Init();
            SetupNodeIds();

            LimboLogs?logManager = LimboLogs.Instance;

            _loggerMock = Substitute.For <ILogger>();
            //setting config to store 3 nodes in a bucket and for table to have one bucket//setting config to store 3 nodes in a bucket and for table to have one bucket

            IConfigProvider configurationProvider = new ConfigProvider();

            _networkConfig.ExternalIp = "99.10.10.66";
            _networkConfig.LocalIp    = "10.0.0.5";

            IDiscoveryConfig discoveryConfig = configurationProvider.GetConfig <IDiscoveryConfig>();

            discoveryConfig.PongTimeout  = 50;
            discoveryConfig.BucketSize   = 3;
            discoveryConfig.BucketsCount = 1;

            NodeDistanceCalculator calculator = new(discoveryConfig);

            _nodeTable = new NodeTable(calculator, discoveryConfig, _networkConfig, logManager);
            _nodeTable.Initialize(TestItem.PublicKeyA);
            _nodeStatsMock = Substitute.For <INodeStats>();

            EvictionManager evictionManager = new(_nodeTable, logManager);

            _evictionManagerMock = Substitute.For <IEvictionManager>();
            ITimerFactory timerFactory = Substitute.For <ITimerFactory>();
            NodeLifecycleManagerFactory lifecycleFactory = new(_nodeTable, evictionManager,
                                                               new NodeStatsManager(timerFactory, logManager), new NodeRecord(), discoveryConfig, Timestamper.Default, logManager);

            IMsgSender udpClient = Substitute.For <IMsgSender>();

            SimpleFilePublicKeyDb discoveryDb = new("Test", "test", logManager);

            _discoveryManager           = new DiscoveryManager(lifecycleFactory, _nodeTable, new NetworkStorage(discoveryDb, logManager), discoveryConfig, logManager);
            _discoveryManager.MsgSender = udpClient;

            _discoveryManagerMock = Substitute.For <IDiscoveryManager>();
        }
コード例 #8
0
 public NodeLifecycleManager(Node node,
                             IDiscoveryManager discoveryManager,
                             INodeTable nodeTable,
                             IEvictionManager evictionManager,
                             INodeStats nodeStats,
                             NodeRecord nodeRecord,
                             IDiscoveryConfig discoveryConfig,
                             ITimestamper timestamper,
                             ILogger logger)
 {
     _discoveryManager = discoveryManager ?? throw new ArgumentNullException(nameof(discoveryManager));
     _nodeTable        = nodeTable ?? throw new ArgumentNullException(nameof(nodeTable));
     _logger           = logger ?? throw new ArgumentNullException(nameof(logger));
     _discoveryConfig  = discoveryConfig ?? throw new ArgumentNullException(nameof(discoveryConfig));
     _timestamper      = timestamper ?? throw new ArgumentNullException(nameof(timestamper));
     _evictionManager  = evictionManager ?? throw new ArgumentNullException(nameof(evictionManager));
     _nodeRecord       = nodeRecord ?? throw new ArgumentNullException(nameof(nodeRecord));
     NodeStats         = nodeStats ?? throw new ArgumentNullException(nameof(nodeStats));
     ManagedNode       = node;
     UpdateState(NodeLifecycleState.New);
 }