Пример #1
0
        public static void Main(string[] args)
        {
            var log = CreateLog(args);

            SetupThreadPool();
            log.Info("Master is starting. IsServerGC = {IsServerGC}.", GCSettings.IsServerGC);

            var sessionStorage   = new SessionStorage(log);
            var heartbeatStorage = new HeartbeatStorage(TimeSpan.FromSeconds(15), log);
            var garbageCollector = new GarbageCollector(sessionStorage, heartbeatStorage, TimeSpan.FromSeconds(2), log);

            var server      = new TcpListener(IPAddress.Any, 16770);
            var adminServer = new AdminServer(16777, sessionStorage, heartbeatStorage);

            adminServer.Run();

            server.Start(100);
            garbageCollector.Start();

            while (true)
            {
                var client = server.AcceptSocket();

                var sessionLog = log.ForContext($"Session({client.RemoteEndPoint})");
                //sessionLog.Info("Accepted new client.");
                var session = new Session(new Link(client, sessionLog), new CommandHandler(sessionStorage, heartbeatStorage, sessionLog), sessionLog);
                session.Run();
            }
        }
Пример #2
0
 public GarbageCollector(SessionStorage sessionStorage, HeartbeatStorage heartbeatStorage, TimeSpan period, ILog log)
 {
     this.sessionStorage   = sessionStorage;
     this.heartbeatStorage = heartbeatStorage;
     this.period           = period;
     this.log = log.ForContext(GetType().Name);
 }
Пример #3
0
 public AdminServer(int port, SessionStorage sessionStorage, HeartbeatStorage heartbeatStorage)
 {
     this.port             = port;
     this.sessionStorage   = sessionStorage;
     this.heartbeatStorage = heartbeatStorage;
 }
Пример #4
0
 public CommandHandler(SessionStorage sessionStorage, HeartbeatStorage heartbeatStorage, ILog log)
 {
     this.sessionStorage   = sessionStorage;
     this.heartbeatStorage = heartbeatStorage;
     this.log = log.ForContext(GetType().Name);
 }
Пример #5
0
 public AdminSession(Link link, SessionStorage sessionStorage, HeartbeatStorage heartbeatStorage)
 {
     this.link             = link;
     this.sessionStorage   = sessionStorage;
     this.heartbeatStorage = heartbeatStorage;
 }