public override void Start() { if (_model.UseStart) { _model.Start(); _asyncTaskModule.AddAsyncTask( new AsyncDataPeriod(_asyncPing.TimeoutPeriod, PingProcess, AsyncTasksNames.AsyncPing, -1), false); } }
public void CollectorModel_GetSystemState_CheckWritersState() { const int countReplics = 2; var writer = new HashWriter(new HashMapConfiguration("TestCollectorModel", HashMapCreationMode.CreateNew, 4, 3, HashFileType.Distributor)); writer.CreateMap(); writer.SetServer(0, "localhost", 1, 157); writer.SetServer(1, "localhost", 2, 157); writer.SetServer(2, "localhost", 3, 157); writer.SetServer(3, "localhost", 4, 157); writer.Save(); var model = new CollectorModel(new DistributorHashConfiguration(countReplics), new HashMapConfiguration("TestCollectorModel", HashMapCreationMode.ReadFromFile, 1, countReplics, HashFileType.Writer)); model.Start(); var state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.AllServersAvailable, state); model.ServerNotAvailable(new ServerId("localhost", 1)); state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.AllDataAvailable, state); model.ServerNotAvailable(new ServerId("localhost", 3)); state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.AllDataAvailable, state); model.ServerNotAvailable(new ServerId("localhost", 2)); state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.SomeDataUnavailable, state); model.ServerAvailable(new ServerId("localhost", 1)); state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.SomeDataUnavailable, state); model.ServerNotAvailable(new ServerId("localhost", 4)); state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.SomeDataUnavailable, state); model.ServerAvailable(new ServerId("localhost", 3)); state = model.GetSystemState(); Assert.AreEqual(SystemSearchStateInner.AllDataAvailable, state); }