Esempio n. 1
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var localActor = new RpcActor();

            var helloService = new HelloService(localActor, new CountableRateLimiter());
            var calcService  = new CalcService(localActor, new CountableRateLimiter());
            var orderService = new OrderService(localActor, new CountableRateLimiter());

            localActor.RegisterRpcService(helloService);
            localActor.RegisterRpcService(calcService);
            localActor.RegisterRpcService(orderService);

            localActor.Bootup();

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        localActor.Shutdown();
                        localActor.Bootup();
                    }
                    else if (Regex.Match(text, @"^notify(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"notify(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            NotifyOrderChanged(log, orderService);
                        }
                    }
                    else
                    {
                        log.WarnFormat("Cannot parse the operation for input [{0}].", text);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }

            localActor.Shutdown();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var localActor = new RpcActor();

            var helloService = RpcServiceGenerator.CreateService <IHelloService>(localActor, new HelloService());
            var calcService  = RpcServiceGenerator.CreateService <ICalcService>(localActor, new CalcService());
            var orderService = RpcServiceGenerator.CreateService <IOrderService>(localActor, new OrderService());

            localActor.RegisterRpcService(helloService as RpcService);
            localActor.RegisterRpcService(calcService as RpcService);
            localActor.RegisterRpcService(orderService as RpcService);

            localActor.Bootup();

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        localActor.Shutdown();
                        localActor.Bootup();
                    }
                    else
                    {
                        log.WarnFormat("Cannot parse the operation for input [{0}].", text);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }

            localActor.Shutdown();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var localActor = new RpcActor();

            localActor.Register <IHelloService>(new HelloService());
            localActor.Register <ICalcService>(new CalcService());
            localActor.Register <IOrderService>(new OrderService());

            localActor.Bootup();

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        localActor.Shutdown();
                        localActor.Bootup();
                    }
                    else
                    {
                        _log.WarnFormat("Cannot parse the operation for input [{0}].", text);
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }

            localActor.Shutdown();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var actor = new RpcActor();

            var rateLimiter = new CountableRateLimiter();

            var helloService = new HelloService(actor, rateLimiter);
            var calcService  = new CalcService(actor);
            var orderService = new OrderService(actor, rateLimiter);

            actor.RegisterRpcService(helloService);
            actor.RegisterRpcService(calcService);
            actor.RegisterRpcService(orderService);

            actor.Bootup();

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else
                    {
                        int times = 0;
                        if (int.TryParse(text, out times))
                        {
                            for (int i = 0; i < times; i++)
                            {
                                NotifyOrderChanged(log, orderService);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }

            actor.Shutdown();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var localActor = new RpcActor();

            var helloClient = RpcServiceProxyGenerator.CreateServiceProxy <IHelloService>(localActor, "server");
            var calcClient  = RpcServiceProxyGenerator.CreateServiceProxy <ICalcService>(localActor, "server");
            var orderClient = RpcServiceProxyGenerator.CreateServiceProxy <IOrderService>(localActor, "server");

            localActor.RegisterRpcService(helloClient as RpcService);
            localActor.RegisterRpcService(calcClient as RpcService);
            localActor.RegisterRpcService(orderClient as RpcService);

            localActor.Bootup();

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant().Trim();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        localActor.Shutdown();
                        localActor.Bootup();
                    }
                    else if (Regex.Match(text, @"^hello(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"^hello(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            Hello(log, helloClient);
                        }
                    }
                    else if (Regex.Match(text, @"^add(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"^add(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            Add(log, calcClient);
                        }
                    }
                    else if (Regex.Match(text, @"^order(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"order(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            PlaceOrder(log, orderClient);
                        }
                    }
                    else if (Regex.Match(text, @"^hello(\d+)x(\d+)$").Success)
                    {
                        var match       = Regex.Match(text, @"^hello(\d+)x(\d+)$");
                        int totalCalls  = int.Parse(match.Groups[1].Value);
                        int threadCount = int.Parse(match.Groups[2].Value);
                        Hello10000MultiThreading(log, helloClient, totalCalls, threadCount);
                    }
                    else if (Regex.Match(text, @"^add(\d+)x(\d+)$").Success)
                    {
                        var match       = Regex.Match(text, @"^add(\d+)x(\d+)$");
                        int totalCalls  = int.Parse(match.Groups[1].Value);
                        int threadCount = int.Parse(match.Groups[2].Value);
                        Add10000MultiThreading(log, calcClient, totalCalls, threadCount);
                    }
                    else
                    {
                        log.WarnFormat("Cannot parse the operation for input [{0}].", text);
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }

            localActor.Shutdown();
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            var localActorConfiguration = AppConfigActorConfiguration.Load();
            var localActor = new RpcActor(localActorConfiguration);

            var helloService     = new HelloService(localActor, new CountableRateLimiter());
            var calcService      = new CalcService(localActor, new CountableRateLimiter());
            var orderService     = new OrderService(localActor, new CountableRateLimiter());
            var orderEventClient = new OrderEventClient(localActor);

            localActor.RegisterRpcHandler(helloService);
            localActor.RegisterRpcHandler(calcService);
            localActor.RegisterRpcHandler(orderService);
            localActor.RegisterRpcHandler(orderEventClient);

            var directoryConfiguration = AppConfigCenterActorDirectoryConfiguration.Load();
            var directory = new CenterActorDirectory(directoryConfiguration);

            localActor.Bootup(directory);

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        localActor.Shutdown();

                        directory = new CenterActorDirectory(directoryConfiguration);
                        localActor.Bootup(directory);
                    }
                    else if (Regex.Match(text, @"^notify(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"notify(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            NotifyOrderDelivered(orderEventClient);
                        }
                    }
                    else
                    {
                        _log.WarnFormat("Cannot parse the operation for input [{0}].", text);
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }

            localActor.Shutdown();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var localActorConfiguration = AppConfigActorConfiguration.Load();
            var localActor = new RpcActor(localActorConfiguration);

            var helloClient       = new HelloClient(localActor);
            var calcClient        = new CalcClient(localActor);
            var orderClient       = new OrderClient(localActor);
            var orderEventService = new OrderEventService(localActor);

            localActor.RegisterRpcHandler(helloClient);
            localActor.RegisterRpcHandler(calcClient);
            localActor.RegisterRpcHandler(orderClient);
            localActor.RegisterRpcHandler(orderEventService);

            var directoryConfiguration = AppConfigCenterActorDirectoryConfiguration.Load();
            var directory = new CenterActorDirectory(directoryConfiguration);

            localActor.Bootup(directory);

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant().Trim();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        localActor.Shutdown();

                        directory = new CenterActorDirectory(directoryConfiguration);
                        localActor.Bootup(directory);
                    }
                    else if (Regex.Match(text, @"^hello(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"^hello(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            Hello(helloClient);
                        }
                    }
                    else if (Regex.Match(text, @"^add(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"^add(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            Add(calcClient);
                        }
                    }
                    else if (Regex.Match(text, @"^order(\d*)$").Success)
                    {
                        var match      = Regex.Match(text, @"order(\d*)$");
                        int totalCalls = 0;
                        if (!int.TryParse(match.Groups[1].Value, out totalCalls))
                        {
                            totalCalls = 1;
                        }
                        for (int i = 0; i < totalCalls; i++)
                        {
                            PlaceOrder(orderClient);
                        }
                    }
                    else if (Regex.Match(text, @"^hello(\d+)x(\d+)$").Success)
                    {
                        var match       = Regex.Match(text, @"^hello(\d+)x(\d+)$");
                        int totalCalls  = int.Parse(match.Groups[1].Value);
                        int threadCount = int.Parse(match.Groups[2].Value);
                        Hello10000MultiThreading(helloClient, totalCalls, threadCount);
                    }
                    else if (Regex.Match(text, @"^add(\d+)x(\d+)$").Success)
                    {
                        var match       = Regex.Match(text, @"^add(\d+)x(\d+)$");
                        int totalCalls  = int.Parse(match.Groups[1].Value);
                        int threadCount = int.Parse(match.Groups[2].Value);
                        Add10000MultiThreading(calcClient, totalCalls, threadCount);
                    }
                    else
                    {
                        _log.WarnFormat("Cannot parse the operation for input [{0}].", text);
                    }
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }

            localActor.Shutdown();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            NLogLogger.Use();

            ILog log = Logger.Get <Program>();

            var actor = new RpcActor();

            var helloClient = new HelloClient(actor);
            var calcClient  = new CalcClient(actor);
            var orderClient = new OrderClient(actor);

            actor.RegisterRpcService(helloClient);
            actor.RegisterRpcService(calcClient);
            actor.RegisterRpcService(orderClient);

            actor.Bootup();

            while (true)
            {
                try
                {
                    string text = Console.ReadLine().ToLowerInvariant();
                    if (text == "quit" || text == "exit")
                    {
                        break;
                    }
                    else if (text == "reconnect")
                    {
                        actor.Shutdown();
                        actor.Bootup();
                    }
                    else if (text == "hello")
                    {
                        Hello(log, helloClient);
                    }
                    else if (text == "hello10000")
                    {
                        Hello10000(log, helloClient);
                    }
                    #region hello10000
                    else if (text == "hello10000x1")
                    {
                        Hello10000MultiThreading(log, helloClient, 10000, 1);
                    }
                    else if (text == "hello10000x2")
                    {
                        Hello10000MultiThreading(log, helloClient, 10000, 2);
                    }
                    else if (text == "hello10000x4")
                    {
                        Hello10000MultiThreading(log, helloClient, 10000, 4);
                    }
                    else if (text == "hello10000x8")
                    {
                        Hello10000MultiThreading(log, helloClient, 10000, 8);
                    }
                    else if (text == "hello10000x16")
                    {
                        Hello10000MultiThreading(log, helloClient, 10000, 16);
                    }
                    else if (text == "hello10000x32")
                    {
                        Hello10000MultiThreading(log, helloClient, 10000, 32);
                    }
                    #endregion
                    #region hello20000
                    else if (text == "hello20000x1")
                    {
                        Hello10000MultiThreading(log, helloClient, 20000, 1);
                    }
                    else if (text == "hello20000x2")
                    {
                        Hello10000MultiThreading(log, helloClient, 20000, 2);
                    }
                    else if (text == "hello20000x4")
                    {
                        Hello10000MultiThreading(log, helloClient, 20000, 4);
                    }
                    else if (text == "hello20000x8")
                    {
                        Hello10000MultiThreading(log, helloClient, 20000, 8);
                    }
                    else if (text == "hello20000x16")
                    {
                        Hello10000MultiThreading(log, helloClient, 20000, 16);
                    }
                    else if (text == "hello20000x32")
                    {
                        Hello10000MultiThreading(log, helloClient, 20000, 32);
                    }
                    #endregion
                    #region hello100000
                    else if (text == "hello100000x1")
                    {
                        Hello10000MultiThreading(log, helloClient, 100000, 1);
                    }
                    else if (text == "hello100000x2")
                    {
                        Hello10000MultiThreading(log, helloClient, 100000, 2);
                    }
                    else if (text == "hello100000x4")
                    {
                        Hello10000MultiThreading(log, helloClient, 100000, 4);
                    }
                    else if (text == "hello100000x8")
                    {
                        Hello10000MultiThreading(log, helloClient, 100000, 8);
                    }
                    else if (text == "hello100000x16")
                    {
                        Hello10000MultiThreading(log, helloClient, 100000, 16);
                    }
                    else if (text == "hello100000x32")
                    {
                        Hello10000MultiThreading(log, helloClient, 100000, 32);
                    }
                    #endregion
                    #region hello300000
                    else if (text == "hello300000x1")
                    {
                        Hello10000MultiThreading(log, helloClient, 300000, 1);
                    }
                    else if (text == "hello300000x2")
                    {
                        Hello10000MultiThreading(log, helloClient, 300000, 2);
                    }
                    else if (text == "hello300000x4")
                    {
                        Hello10000MultiThreading(log, helloClient, 300000, 4);
                    }
                    else if (text == "hello300000x8")
                    {
                        Hello10000MultiThreading(log, helloClient, 300000, 8);
                    }
                    else if (text == "hello300000x16")
                    {
                        Hello10000MultiThreading(log, helloClient, 300000, 16);
                    }
                    else if (text == "hello300000x32")
                    {
                        Hello10000MultiThreading(log, helloClient, 300000, 32);
                    }
                    #endregion
                    #region hello1500000
                    else if (text == "hello1500000x1")
                    {
                        Hello10000MultiThreading(log, helloClient, 1500000, 1);
                    }
                    else if (text == "hello1500000x2")
                    {
                        Hello10000MultiThreading(log, helloClient, 1500000, 2);
                    }
                    else if (text == "hello1500000x4")
                    {
                        Hello10000MultiThreading(log, helloClient, 1500000, 4);
                    }
                    else if (text == "hello1500000x8")
                    {
                        Hello10000MultiThreading(log, helloClient, 1500000, 8);
                    }
                    else if (text == "hello1500000x16")
                    {
                        Hello10000MultiThreading(log, helloClient, 1500000, 16);
                    }
                    else if (text == "hello1500000x32")
                    {
                        Hello10000MultiThreading(log, helloClient, 1500000, 32);
                    }
                    #endregion
                    #region add10000
                    else if (text == "add10000x1")
                    {
                        Add10000MultiThreading(log, calcClient, 10000, 1);
                    }
                    else if (text == "add10000x2")
                    {
                        Add10000MultiThreading(log, calcClient, 10000, 2);
                    }
                    else if (text == "add10000x4")
                    {
                        Add10000MultiThreading(log, calcClient, 10000, 4);
                    }
                    else if (text == "add10000x8")
                    {
                        Add10000MultiThreading(log, calcClient, 10000, 8);
                    }
                    else if (text == "add10000x16")
                    {
                        Add10000MultiThreading(log, calcClient, 10000, 16);
                    }
                    else if (text == "add10000x32")
                    {
                        Add10000MultiThreading(log, calcClient, 10000, 32);
                    }
                    #endregion
                    #region add20000
                    else if (text == "add20000x1")
                    {
                        Add10000MultiThreading(log, calcClient, 20000, 1);
                    }
                    else if (text == "add20000x2")
                    {
                        Add10000MultiThreading(log, calcClient, 20000, 2);
                    }
                    else if (text == "add20000x4")
                    {
                        Add10000MultiThreading(log, calcClient, 20000, 4);
                    }
                    else if (text == "add20000x8")
                    {
                        Add10000MultiThreading(log, calcClient, 20000, 8);
                    }
                    else if (text == "add20000x16")
                    {
                        Add10000MultiThreading(log, calcClient, 20000, 16);
                    }
                    else if (text == "add20000x32")
                    {
                        Add10000MultiThreading(log, calcClient, 20000, 32);
                    }
                    #endregion
                    #region add100000
                    else if (text == "add100000x1")
                    {
                        Add10000MultiThreading(log, calcClient, 100000, 1);
                    }
                    else if (text == "add100000x2")
                    {
                        Add10000MultiThreading(log, calcClient, 100000, 2);
                    }
                    else if (text == "add100000x4")
                    {
                        Add10000MultiThreading(log, calcClient, 100000, 4);
                    }
                    else if (text == "add100000x8")
                    {
                        Add10000MultiThreading(log, calcClient, 100000, 8);
                    }
                    else if (text == "add100000x16")
                    {
                        Add10000MultiThreading(log, calcClient, 100000, 16);
                    }
                    else if (text == "add100000x32")
                    {
                        Add10000MultiThreading(log, calcClient, 100000, 32);
                    }
                    #endregion
                    #region add300000
                    else if (text == "add300000x1")
                    {
                        Add10000MultiThreading(log, calcClient, 300000, 1);
                    }
                    else if (text == "add300000x2")
                    {
                        Add10000MultiThreading(log, calcClient, 300000, 2);
                    }
                    else if (text == "add300000x4")
                    {
                        Add10000MultiThreading(log, calcClient, 300000, 4);
                    }
                    else if (text == "add300000x8")
                    {
                        Add10000MultiThreading(log, calcClient, 300000, 8);
                    }
                    else if (text == "add300000x16")
                    {
                        Add10000MultiThreading(log, calcClient, 300000, 16);
                    }
                    else if (text == "add300000x32")
                    {
                        Add10000MultiThreading(log, calcClient, 300000, 32);
                    }
                    #endregion
                    #region add1500000
                    else if (text == "add1500000x1")
                    {
                        Add10000MultiThreading(log, calcClient, 1500000, 1);
                    }
                    else if (text == "add1500000x2")
                    {
                        Add10000MultiThreading(log, calcClient, 1500000, 2);
                    }
                    else if (text == "add1500000x4")
                    {
                        Add10000MultiThreading(log, calcClient, 1500000, 4);
                    }
                    else if (text == "add1500000x8")
                    {
                        Add10000MultiThreading(log, calcClient, 1500000, 8);
                    }
                    else if (text == "add1500000x16")
                    {
                        Add10000MultiThreading(log, calcClient, 1500000, 16);
                    }
                    else if (text == "add1500000x32")
                    {
                        Add10000MultiThreading(log, calcClient, 1500000, 32);
                    }
                    #endregion
                    else
                    {
                        int times = 0;
                        if (int.TryParse(text, out times))
                        {
                            for (int i = 0; i < times; i++)
                            {
                                PlaceOrder(log, orderClient);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message, ex);
                }
            }

            actor.Shutdown();
        }