public HelloService(RpcActor localActor) : base(localActor) { }
public HelloService(RpcActor localActor, IRateLimiter rateLimiter) : base(localActor, rateLimiter) { }
public CalcClient(RpcActor localActor) : base(localActor) { }
static void Main(string[] args) { var localXmlFileLocalActorPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\LocalActor.xml"; var localXmlFileLocalActorConfiguration = LocalXmlFileActorConfiguration.Load(localXmlFileLocalActorPath); var localActor = new RpcActor(localXmlFileLocalActorConfiguration); var consul = new ConsulClient((c) => { c.Address = new Uri("http://*****:*****@"^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); } } rpcNode.Shutdown(); }
public OrderService(RpcActor localActor, IRateLimiter rateLimiter) : base(localActor, rateLimiter) { }
static void Main(string[] args) { var localActor = new RpcActor(); var helloClient = new HelloClient(localActor); var calcClient = new CalcClient(localActor); var orderClient = new OrderClient(localActor); localActor.RegisterRpcService(helloClient); localActor.RegisterRpcService(calcClient); localActor.RegisterRpcService(orderClient); 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(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(); }
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(); }
public OrderService(RpcActor localActor) : base(localActor) { }
public HelloClient(RpcActor localActor) : base(localActor) { }
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(); }
public OrderClient(RpcActor localActor) : base(localActor) { }
public CalcService(RpcActor localActor) : base(localActor) { }
static void Main(string[] args) { var localXmlFileLocalActorPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\LocalActor.xml"; var localXmlFileLocalActorConfiguration = LocalXmlFileActorConfiguration.Load(localXmlFileLocalActorPath); var localActor = new RpcActor(localXmlFileLocalActorConfiguration); var localXmlFileActorRegistryPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ActorRegistry.xml"; var localXmlFileActorRegistry = LocalXmlFileActorRegistry.Load(localXmlFileActorRegistryPath); var actorDirectory = new LocalXmlFileActorDirectory(localXmlFileActorRegistry); var localXmlFileServiceRegistryPath = Environment.CurrentDirectory + @"\\XmlConfiguration\\ServiceRegistry.xml"; var serviceRegistry = LocalXmlFileServiceRegistry.Load(localXmlFileServiceRegistryPath); var serviceDiscovery = new LocalXmlFileServiceDiscovery(serviceRegistry); var serviceRetriever = new ServiceRetriever(serviceDiscovery); var serviceResolver = new ServiceResolver(serviceRetriever); var proxyGenerator = new ServiceProxyGenerator(serviceResolver); var rpcClient = new RpcClient(localActor, actorDirectory, proxyGenerator); var helloClient = rpcClient.Resolve <IHelloService>(); var calcClient = rpcClient.Resolve <ICalcService>(); var orderClient = rpcClient.Resolve <IOrderService>(); rpcClient.Bootup(); while (true) { try { string text = Console.ReadLine().ToLowerInvariant().Trim(); if (text == "quit" || text == "exit") { break; } else if (text == "reconnect") { rpcClient.Shutdown(); rpcClient.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(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); } } rpcClient.Shutdown(); }