예제 #1
0
        public void Master()
        {
            var f = new TraceLoggerFactory();
            var master = new DefaultMaster(f, (m, w) =>
            {
                try
                {
                    throw new Exception();
                }
                catch (Exception e)
                {
                    w.WriteLine(e.Message);
                    w.Flush();
                }
            });
            master.Run();
            var agent = new DefaultAgent(f, ".", "agent", "test", new DefaultHandle());
            agent.Run();

            DefaultMaster.Send(new TraceLog(), ".", DefaultMaster.Name, "");
            Thread.Sleep(10000);
            Trace.WriteLine("关闭agent");
            agent.Stop();
            Thread.Sleep(5000);
            Trace.WriteLine("打开agent");
            agent.Run();
            Thread.Sleep(10000);
            Trace.WriteLine("关闭master");
            master.Stop();
            Thread.Sleep(5000);
            Trace.WriteLine("打开master");
            master.Run();
            Thread.Sleep(10000);
            master.Broadcast("cache summary");
            Thread.Sleep(10000);
        }
예제 #2
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="master"></param>
 /// <param name="handle">允许设置额外的命令扩展委托</param>
 public MasterMessageHandle(DefaultMaster master, Action<string, StreamWriter> handle)
 {
     this._master = master;
     this._handle = handle ?? new Action<string, StreamWriter>((m, w) => { });
 }