public void ProxySystem_CreateSync_SendSyncDataToFakeDistributor_NoError() { var queue = new QueueConfiguration(1, 100); var connection = new ConnectionConfiguration("testService", 10); var ndrc2 = new NetReceiverConfiguration(32190, "localhost", "testService"); var pcc = new ProxyCacheConfiguration(TimeSpan.FromSeconds(20000000)); var proxy = new TestProxySystem(new ServerId("", 1), queue, connection, pcc, pcc, ndrc2, new AsyncTasksConfiguration(TimeSpan.FromMinutes(60000)), new AsyncTasksConfiguration(TimeSpan.FromMinutes(60000)), new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout)); proxy.Build(); proxy.Start(); var distr = new ServerId("localhost", 22190); TestHelper.OpenDistributorHost(distr, connection); proxy.Distributor.SayIAmHere(distr); var provider = new StoredDataHashCalculator(); var hash = provider.CalculateHashFromKey(10); var transaction = new Transaction(hash, "") { OperationName = OperationName.Create, OperationType = OperationType.Sync }; Task.Factory.StartNew(() => { Thread.Sleep(200); transaction.Complete(); proxy.Queue.ProxyDistributorQueue.Add(new OperationCompleteCommand(transaction)); }); try { var api = proxy.CreateApi("", false, provider); var wait = api.CreateSync(10, TestHelper.CreateStoredData(10)); wait.Wait(); Assert.AreEqual(TransactionState.Complete, wait.Result.State); } catch (Exception e) { Assert.Fail(e.Message); } proxy.Dispose(); }
public void CachePerformance() { var ts1 = TimeSpan.FromMilliseconds(400); var ts2 = TimeSpan.FromSeconds(1000); var cache = new DistributorCache(ts1, ts2); var max = new List <long>(); var min = new List <long>(); var avg = new List <float>(); var obj = new List <InnerData>(); cache.Start(); const int count = 10000; var calc = new StoredDataHashCalculator(); for (int i = 0; i < count; i++) { obj.Add(TestHelper.CreateEvent(calc, i + 1)); } long v1 = 0, v2 = 0; float v3 = 0; TestCachePerfHelper(cache, obj, 100, ref v1, ref v2, ref v3); cache.Dispose(); min.Add(v1); max.Add(v2); avg.Add(v3); cache = new DistributorCache(ts1, ts2); cache.Start(); TestCachePerfHelper(cache, obj, 1000, ref v1, ref v2, ref v3); cache.Dispose(); min.Add(v1); max.Add(v2); avg.Add(v3); cache = new DistributorCache(ts1, ts2); cache.Start(); TestCachePerfHelper(cache, obj, 10000, ref v1, ref v2, ref v3); cache.Dispose(); min.Add(v1); max.Add(v2); avg.Add(v3); }