示例#1
0
        public void Build(int storageServer, string hashFile, int countReplics)
        {
            Q = new GlobalQueueInner();
            GlobalQueue.SetQueue(Q);

            var queueConfiguration   = new QueueConfiguration(1, 1000);
            var hashMapConfiguration = new HashMapConfiguration(hashFile,
                                                                HashMapCreationMode.ReadFromFile, 1, countReplics, HashFileType.Writer);
            var local = new ServerId("localhost", storageServer);

            _net = new WriterNetModule(new ConnectionConfiguration("testService", 10),
                                       new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout));

            Db = new DbModuleCollection();
            Db.AddDbModule(new TestDbInMemory());

            _async  = new AsyncTaskModule(new QueueConfiguration(1, 10));
            Restore = new AsyncDbWorkModule(_net, _async, Db,
                                            new RestoreModuleConfiguration(10, TimeSpan.FromMinutes(100)),
                                            new RestoreModuleConfiguration(10, TimeSpan.FromMilliseconds(100)),
                                            new RestoreModuleConfiguration(-1, TimeSpan.FromHours(1), false, TimeSpan.FromHours(1)),
                                            new QueueConfiguration(1, 100), local);

            Distributor = new DistributorModule(_async, Restore, _net, local,
                                                hashMapConfiguration, new QueueConfiguration(2, 10), Db);
            _mainС = new MainLogicModule(Distributor, Db);
            Input  = new InputModule(_mainС, queueConfiguration);
            _netRc = new NetWriterReceiver(Input, Distributor,
                                           new NetReceiverConfiguration(storageServer, "localhost", "testService"),
                                           new NetReceiverConfiguration(1, "fake", "fake"));
        }
示例#2
0
        public override void Build()
        {
            var q = new GlobalQueueInner();

            GlobalQueue.SetQueue(q);

            var db = new DbModuleCollection();

            var net = new WriterNetModule(_connectionConfiguration, _connectionTimeoutConfiguration);

            var async   = new AsyncTaskModule(_queueConfiguration);
            var restore = new AsyncDbWorkModule(net, async, db, _initiatorRestoreConfiguration,
                                                _transferRestoreConfiguration, _timeoutRestoreConfiguration,
                                                _queueConfigurationRestore, _local, _isNeedRestore);

            var distributor = new DistributorModule(async, restore, net, _local, _hashMapConfiguration,
                                                    _queueConfiguration, db);

            Distributor = distributor;
            DbModule    = db;

            var main     = new MainLogicModule(distributor, db);
            var input    = new InputModule(main, _queueConfiguration);
            var receiver = new NetWriterReceiver(input, distributor, _receiverConfigurationForWrite,
                                                 _receiverConfigurationForCollector);

            AddModule(distributor);
            AddModule(input);
            AddModule(db);
            AddModule(async);
            AddModule(restore);
            AddModule(main);
            AddModule(receiver);
            AddModule(q);

            AddModuleDispose(receiver);
            AddModuleDispose(restore);
            AddModuleDispose(async);
            AddModuleDispose(q);
            AddModuleDispose(input);
            AddModuleDispose(main);
            AddModuleDispose(distributor);
            AddModuleDispose(db);
            AddModuleDispose(net);
        }