public void ProxyMainLogic_Process_SendDataToRealDistributor() { var queue = new QueueConfiguration(1, 1000); var server1 = new ServerId("localhost", 21171); var server2 = new ServerId("localhost", 21172); var server3 = new ServerId("localhost", 21173); var netconfig = new ConnectionConfiguration("testService", 10); TestHelper.OpenDistributorHost(server1, netconfig); TestHelper.OpenDistributorHost(server2, netconfig); var net = new ProxyNetModule(netconfig, new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout)); var distributor = new ProxyDistributorModule(new AsyncProxyCache(TimeSpan.FromMinutes(100)), net, queue, server1, new AsyncTasksConfiguration(TimeSpan.FromDays(1)), new AsyncTasksConfiguration(TimeSpan.FromDays(1))); net.SetDistributor(distributor); var cache = new ProxyCache(TimeSpan.FromSeconds(20)); var main = new ProxyMainLogicModule(distributor, net, cache); net.Start(); distributor.Start(); distributor.SayIAmHere(server1); distributor.SayIAmHere(server2); distributor.SayIAmHere(server3); cache.Start(); main.Start(); const string hash = ""; var ev = new InnerData(new Transaction("", "")); ev.Transaction = distributor.CreateTransaction(hash); ev.Transaction = distributor.CreateTransaction(hash); ev.Transaction = distributor.CreateTransaction(hash); ev.Transaction.Destination = new List <ServerId> { server1 }; bool res = main.Process(ev); var server = cache.Get(ev.Transaction.EventHash); Assert.IsNull(server); Assert.IsTrue(res); main.Dispose(); distributor.Dispose(); net.Dispose(); }
public UserTransaction Create(object key, object value) { var hash = _hashFromValue ? _hashCalculater.CalculateHashFromValue(value) : _hashCalculater.CalculateHashFromKey(key); var transaction = _distributor.CreateTransaction(hash); transaction.OperationName = OperationName.Create; transaction.OperationType = OperationType.Async; if (!transaction.IsError) { CompleteTransaction(key, value, transaction); PerfCounters.ProxyCounters.Instance.CreateCount.Increment(); } return(transaction.UserTransaction); }