public void Run() { logger.Debug("Start."); var raftConfigStart = RaftConfig.Load(RaftConfigFileName); foreach (var node in raftConfigStart.Nodes) { // every node need a private config-file. var confName = System.IO.Path.GetTempFileName() + ".xml"; System.IO.File.Copy(raftConfigStart.XmlFileName, confName); Rafts.GetOrAdd(node.Value.Name, (_) => new TestRaft(node.Value.Name, confName)); } foreach (var raft in Rafts.Values) { raft.Raft.Server.Start(); } Agent = new Agent("Zeze.Raft.Agent.Test", raftConfigStart); Agent.Client.AddFactoryHandle( new AddCount().TypeId, new Net.Service.ProtocolFactoryHandle() { Factory = () => new AddCount(), }); Agent.Client.AddFactoryHandle( new GetCount().TypeId, new Net.Service.ProtocolFactoryHandle() { Factory = () => new GetCount(), }); Agent.Client.Start(); RunTrace(); Agent.Client.Stop(); foreach (var raft in Rafts.Values) { raft.StopRaft(); } logger.Debug("End."); }
/// <summary> /// Clears all rafts from all maps /// </summary> public void ClearRafts() { Rafts.Clear(); }