Example #1
0
        public void ProxyDistributorModule_TransactionDestination_CreateTransAndGetDestination()
        {
            var model   = new DistributorSystemModel();
            var server1 = new ServerId("localhost", 1);
            var server2 = new ServerId("localhost", 2);

            model.AddServer(server1);
            model.AddServer(server2);

            const string hash = "123";

            var res1 = model.CreateTransaction(hash);

            Assert.IsNotNull(res1);
            var res2 = model.GetDestination(res1.UserTransaction);

            Assert.IsTrue(server1.Equals(res2));

            var res3 = model.CreateTransaction(hash);

            Assert.IsNotNull(res3);
            var res4 = model.GetDestination(res3.UserTransaction);

            Assert.IsTrue(server2.Equals(res4));

            model.ServerNotAvailable(server1);

            var res5 = model.CreateTransaction(hash);

            Assert.IsNotNull(res5);
            var res6 = model.GetDestination(res5.UserTransaction);

            Assert.IsTrue(server2.Equals(res6));

            model.ServerNotAvailable(server2);

            var res7 = model.CreateTransaction(hash);

            Assert.AreEqual(Errors.NotAvailableServersInSystem + "; ", res7.ErrorDescription);
        }
Example #2
0
        public RemoteResult SayIAmHereRemoteResult(ServerId destination)
        {
            if (!_distributorNet.ConnectToDistributor(destination))
            {
                return(new ServerNotAvailable(destination));
            }

            var ret = _distributorNet.SendToDistributor(destination,
                                                        new AddDistributorFromDistributorCommand(new ServerId(_localforproxy)));

            if (!ret.IsError)
            {
                _modelOfAnotherDistributors.AddServer(destination);
                ret = _distributorNet.SendToDistributor(destination, new TakeInfoCommand());

                if (!ret.IsError)
                {
                    var data = ret as SystemInfoResult;
                    AddDistributors(data.DataContainer.AllDistributors);
                }
            }
            return(ret);
        }
Example #3
0
        public RemoteResult SayIAmHere(ServerId destination)
        {
            if (!_net.ConnectToDistributor(destination))
            {
                return(new ServerNotAvailable(destination));
            }

            _distributorSystemModel.AddServer(destination);

            var ret = _net.SendDistributor(destination, new TakeInfoCommand());

            if (ret is SystemInfoResult)
            {
                var data = ret as SystemInfoResult;
                AddNewDistributorList(data.DataContainer.AllDistributors);
            }
            else
            {
                ret = new FailNetResult(Errors.InnerServerError);
            }

            return(ret);
        }