Esempio n. 1
0
 public ProxyDistributorModule(AsyncProxyCache asyncProxyCache, ProxyNetModule net,
                               QueueConfiguration queueConfiguration, ServerId local,
                               AsyncTasksConfiguration asyncGetData, AsyncTasksConfiguration asyncPing)
 {
     _asyncProxyCache        = asyncProxyCache;
     _asynPing               = asyncPing;
     _queueConfiguration     = queueConfiguration;
     _distributorSystemModel = new DistributorSystemModel();
     _asynGetData            = asyncGetData;
     _net   = net;
     _local = local;
     _async = new AsyncTaskModule(queueConfiguration);
     _queue = GlobalQueue.Queue;
 }
Esempio n. 2
0
        public ProxyInputModuleCommon(ProxyMainLogicModule mainLogic, QueueConfiguration queueConfiguration,
                                      ProxyDistributorModule distributor, AsyncProxyCache asyncProxyCache)
        {
            Contract.Requires(queueConfiguration != null);
            Contract.Requires(mainLogic != null);
            Contract.Requires(distributor != null);
            Contract.Requires(asyncProxyCache != null);

            _queueConfiguration = queueConfiguration;
            _distributor        = distributor;
            _asyncProxyCache    = asyncProxyCache;
            _mainLogic          = mainLogic;
            _queue = GlobalQueue.Queue;
            _apis  = new Dictionary <string, ProxyInputModule>();
        }
Esempio n. 3
0
        public ProxyInputModule(string tableName, bool hashFromValue, AsyncProxyCache asyncProxyCache,
                                IHashCalculater hashCalculater, ProxyDistributorModule distributor, ProxyInputModuleCommon processTransaction)
        {
            Contract.Requires(distributor != null);
            Contract.Requires(hashCalculater != null);
            Contract.Requires(asyncProxyCache != null);
            Contract.Requires(processTransaction != null);

            _tableName          = tableName;
            _distributor        = distributor;
            _processTransaction = processTransaction;
            _hashFromValue      = hashFromValue;
            _hashCalculater     = hashCalculater;
            _asyncProxyCache    = asyncProxyCache;
        }
Esempio n. 4
0
        public void AsyncProxyCache_AddToCache_WaitRemovedCallback_ExpiredData()
        {
            var cache = new AsyncProxyCache(TimeSpan.FromMilliseconds(200));
            var ev    = new InnerData(new Transaction("123", ""))
            {
                Transaction = { UserSupportCallback = new TaskCompletionSource <UserTransaction>() }
            };
            Task <UserTransaction> wait = ev.Transaction.UserSupportCallback.Task;

            cache.AddToCache("123", ev.Transaction);

            try
            {
                wait.Wait();
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
            Assert.IsTrue(wait.Result.IsError);
        }
Esempio n. 5
0
        public override void Build()
        {
            var q = new GlobalQueueInner();

            GlobalQueue.SetQueue(q);

            var asyncCache = new AsyncProxyCache(_asyncCacheConfiguration.TimeAliveSec);

            var net         = new ProxyNetModule(_connectionConfiguration, _connectionTimeoutConfiguration);
            var distributor = new ProxyDistributorModule(asyncCache, net, new QueueConfiguration(1, 1000), _local,
                                                         _asyncGetData, _asyncPing);

            net.SetDistributor(distributor);
            var cache = new ProxyCache(_cacheConfiguration.TimeAliveSec);
            var main  = new ProxyMainLogicModule(distributor, net, cache);
            var input = new ProxyInputModuleCommon(main, _queueConfiguration, distributor, asyncCache);

            CreateApi = input.CreateApi;

            var receive = new ProxyNetReceiver(distributor, _netReceiverConfiguration);

            AddModule(input);
            AddModule(main);
            AddModule(cache);
            AddModule(asyncCache);
            AddModule(net);
            AddModule(distributor);
            AddModule(receive);
            AddModule(q);

            AddModuleDispose(distributor);
            AddModuleDispose(receive);
            AddModuleDispose(q);
            AddModuleDispose(input);
            AddModuleDispose(asyncCache);
            AddModuleDispose(main);
            AddModuleDispose(net);
            AddModuleDispose(cache);
        }
Esempio n. 6
0
 public TestProxyDistributorModule(AsyncProxyCache asyncProxyCache, ProxyNetModule net,
                                   QueueConfiguration queueConfiguration, ServerId local, AsyncTasksConfiguration asyncGetData,
                                   AsyncTasksConfiguration asyncPing)
     : base(asyncProxyCache, net, queueConfiguration, local, asyncGetData, asyncPing)
 {
 }