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; }
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>(); }
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; }
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); }
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); }
public TestProxyDistributorModule(AsyncProxyCache asyncProxyCache, ProxyNetModule net, QueueConfiguration queueConfiguration, ServerId local, AsyncTasksConfiguration asyncGetData, AsyncTasksConfiguration asyncPing) : base(asyncProxyCache, net, queueConfiguration, local, asyncGetData, asyncPing) { }