Esempio n. 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);
        }
Esempio n. 2
0
        public void DefaultAppAgent()
        {
            var name = "Agent";
            var agent = new DefaultAgent(new TraceLoggerFactory()//DependencyResolver.Resolve<ILoggerFactory>()
                , "Master"
                , name, "test"
                , new DefaultHandle());

            agent.Run();

            var msg = "";
            while ((msg += "1").Length < 4099) ;

            var i = 0;
            while (i++ < 5)
            {
                Trace.WriteLine("发送消息,文本长度=" + msg.Length);
                Trace.WriteLine("返回:" + DefaultMaster.Send(null, ".", name, msg).Length);
                Thread.Sleep(1000);
            }
        }