public void StartAndStopViaEvent() { RpcAgentManager mgr = new RpcAgentManager(new RpcAgentConfiguration()); bool started = false; mgr.OnStarted += (s, e) => { mgr.StopThriftRpcAgentProcess(); started = true; }; mgr.StartThriftRpcAgentProcess(); int retries = 0; while (!started && retries < 10) { Thread.Sleep(500); retries++; } if (!started) { Assert.Fail("Thrift RPC Agent didn't start"); } }
public void StartAndStopViaEvent() { RpcAgentManager mgr = new RpcAgentManager(new RpcAgentConfiguration()); bool started = false; mgr.OnStarted += (s, e) => { started = true; Log.Info("Started RPC Agent manager ok, now stopping it"); mgr.StopThriftRpcAgentProcess(); }; Log.Info("Starting RPC Agent manager with default configuration"); mgr.StartThriftRpcAgentProcess(); int retries = 0; while (!started && retries < 10) { Thread.Sleep(500); retries++; } if (!started) { Assert.Fail("Thrift RPC Agent didn't start within 5000ms"); } Log.Info("RPC Agent manager confirmed terminated"); }
private CommandResult FindProducers(string[] arg) { RpcAgentConfiguration consumerConfig = new RpcAgentConfiguration { LogLevel = "panic,fatal,error,warn,info,debug", LogFile = new FileInfo("WPWithinConsumer.log"), ServicePort = 9096, }; RpcAgentManager consumerAgent = new RpcAgentManager(consumerConfig); consumerAgent.StartThriftRpcAgentProcess(); try { WPWithinService service = new WPWithinService(consumerConfig); service.SetupDevice("Scanner", $".NET Sample Producer scanner running on ${Dns.GetHostName()}"); List <ServiceMessage> devices = service.DeviceDiscovery(10000).ToList(); _output.WriteLine("Found total of {0} devices", devices.Count); for (int deviceIndex = 0; deviceIndex < devices.Count; deviceIndex++) { ServiceMessage device = devices[deviceIndex]; _output.WriteLine( $"Device {deviceIndex}) {device.ServerId} running on {device.Hostname}:{device.PortNumber}"); _output.WriteLine($"\tDescription: {device.DeviceDescription}, URL Prefix: {device.UrlPrefix}"); service.InitConsumer("http://", device.Hostname, device.PortNumber ?? 80, device.UrlPrefix, device.ServerId, new HceCard("Bilbo", "Baggins", "Card", "5555555555554444", 11, 2018, "113")); try { List <ServiceDetails> services = service.RequestServices().ToList(); _output.WriteLine("\t{0} services found on device {1}", services.Count, deviceIndex); for (int serviceIndex = 0; serviceIndex < services.Count; serviceIndex++) { ServiceDetails svc = services[serviceIndex]; _output.WriteLine($"\t\tService {serviceIndex}) {svc.ServiceId}: {svc.ServiceDescription}"); List <Price> prices = service.GetServicePrices(svc.ServiceId).ToList(); foreach (Price price in prices) { _output.WriteLine("\t\t\tPrice: {0}", price); } } } catch (Exception ex) { _error.WriteLine(ex); } } } finally { consumerAgent.StopThriftRpcAgentProcess(); } return(CommandResult.Success); }
private CommandResult StartRpcClient(string[] arg) { if (_rpcManager != null) { _error.WriteLine("Thrift RPC Agent already active. Stop it before trying to start a new one"); return(CommandResult.NonCriticalError); } _rpcManager = new RpcAgentManager(new RpcAgentConfiguration()); _rpcManager.StartThriftRpcAgentProcess(); _service = new WPWithinService(_defaultAgentConfig); return(CommandResult.Success); }
private CommandResult StopRpcClient(string[] arg) { if (_rpcManager == null) { _error.WriteLine("Thift RPC Agent not active. Start it before trying to stop it."); return(CommandResult.NonCriticalError); } _service.Dispose(); _service = null; _rpcManager.StopThriftRpcAgentProcess(); _rpcManager = null; return(CommandResult.Success); }
private CommandResult ConsumePurchase(string[] arg) { RpcAgentConfiguration consumerConfig = new RpcAgentConfiguration { LogLevel = "panic,fatal,error,warn,info,debug", LogFile = new FileInfo("WPWithinConsumer.log"), ServicePort = 9096, }; RpcAgentManager consumerAgent = new RpcAgentManager(consumerConfig); consumerAgent.StartThriftRpcAgentProcess(); WPWithinService service = new WPWithinService(consumerConfig); SimpleConsumer consumer = new SimpleConsumer(_output, _error); consumer.MakePurchase(service); consumerAgent.StopThriftRpcAgentProcess(); return CommandResult.Success; }
public void StartAndStop() { RpcAgentConfiguration cfg = new RpcAgentConfiguration { CallbackPort = 9092, ServicePort = 9091, ServiceHost = "localhost" }; RpcAgentManager mgr = new RpcAgentManager(cfg); mgr.StartThriftRpcAgentProcess(); try { using (WPWithinService service = new WPWithinService(cfg)) { Log.InfoFormat("Successfully connected {0} to Thrift RPC Agent on {1}", service, cfg); } } finally { mgr.StopThriftRpcAgentProcess(); } }
public void StartThriftRpcService() { _mgr = new RpcAgentManager(new RpcAgentConfiguration()); _mgr.StartThriftRpcAgentProcess(); }