public void WriterSystemModel_GetDestination_ChechAvailableServers() { var config = new DistributorHashConfiguration(1); var writer = new HashWriter(new HashMapConfiguration("test", HashMapCreationMode.CreateNew, 6, 3, HashFileType.Distributor)); writer.CreateMap(); writer.SetServer(0, "local", 11010, 157); writer.SetServer(1, "local", 11011, 157); writer.SetServer(2, "local", 11012, 157); writer.SetServer(3, "local", 11010, 157); writer.SetServer(4, "local", 11011, 157); writer.SetServer(5, "local", 11012, 157); writer.Save(); var model = new WriterSystemModel(config, new HashMapConfiguration("test", HashMapCreationMode.ReadFromFile, 1, 1, HashFileType.Distributor)); model.Start(); var ev = new InnerData(new Transaction("123", "")) { Transaction = new Transaction(HashConvertor.GetString("1"), "") }; ev.Transaction.Destination = new List <ServerId>(); var ret = model.GetDestination(ev); Assert.IsTrue(ret.Count == 1); model.ServerNotAvailable(ret.First()); var ret2 = model.GetDestination(ev); Assert.IsTrue(ret2.Count == 1); Assert.AreNotEqual(ret.First(), ret2.First()); model.ServerNotAvailable(ret2.First()); var ret3 = model.GetDestination(ev); Assert.IsTrue(ret3.Count == 1); Assert.AreNotEqual(ret.First(), ret3.First()); Assert.AreNotEqual(ret3.First(), ret2.First()); model.ServerNotAvailable(ret3.First()); var ret4 = model.GetDestination(ev); Assert.IsTrue(ret4.Count == 0); }
public void WriterSystemModel_GetUnavailableServers_CheckAvailableAndUnAvailableServers() { var server1 = new ServerId("local", 11010); var server2 = new ServerId("local", 11011); var server3 = new ServerId("local", 11012); var config = new DistributorHashConfiguration(1); var writer = new HashWriter(new HashMapConfiguration("TestDbModelGetUnavalibaleServers", HashMapCreationMode.CreateNew, 6, 3, HashFileType.Collector)); writer.CreateMap(); writer.SetServer(0, server1.RemoteHost, server1.Port, 157); writer.SetServer(1, server2.RemoteHost, server2.Port, 157); writer.SetServer(2, server3.RemoteHost, server3.Port, 157); writer.SetServer(3, server1.RemoteHost, server1.Port, 157); writer.SetServer(4, server2.RemoteHost, server2.Port, 157); writer.SetServer(5, server3.RemoteHost, server3.Port, 157); writer.Save(); var model = new WriterSystemModel(config, new HashMapConfiguration("TestDbModelGetUnavalibaleServers", HashMapCreationMode.ReadFromFile, 1, 1, HashFileType.Writer)); model.Start(); model.ServerNotAvailable(server1); Assert.AreEqual(1, model.GetUnavailableServers().Count); model.ServerNotAvailable(server1); Assert.AreEqual(1, model.GetUnavailableServers().Count); model.ServerNotAvailable(server2); Assert.AreEqual(2, model.GetUnavailableServers().Count); model.ServerNotAvailable(server3); Assert.AreEqual(3, model.GetUnavailableServers().Count); model.ServerAvailable(server1); Assert.AreEqual(2, model.GetUnavailableServers().Count); model.ServerAvailable(server1); Assert.AreEqual(2, model.GetUnavailableServers().Count); model.ServerAvailable(server2); Assert.AreEqual(1, model.GetUnavailableServers().Count); model.ServerAvailable(server3); Assert.AreEqual(0, model.GetUnavailableServers().Count); }
private void ServerNotAvailableInner(ServerId server) { Logger.Logger.Instance.Debug("Distributor: Server not available " + server); _modelOfDbWriters.ServerNotAvailable(server); }