public static bool TryStart(string location, string hostname) { try { if (Orleans.GrainClient.IsInitialized) { return(true); } var config = new Orleans.Runtime.Configuration.ClientConfiguration(); config.DeploymentId = "PiraeusDeployment"; config.PropagateActivityId = true; var hostEntry = Dns.GetHostEntry(System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME")); var ip = hostEntry.AddressList[0]; Trace.TraceWarning("Host Entry IP Address {0}", ip.ToString()); config.Gateways.Add(new IPEndPoint(ip, 30000)); client = new ClientBuilder().UseConfiguration(config).Build(); Task task = client.Connect(); Task.WaitAll(task); Orleans.GrainClient.Initialize(config); } catch (Exception ex) { Trace.TraceWarning("Failed to intiailize orleans client via hostname"); Trace.TraceError(ex.Message); } return(Orleans.GrainClient.IsInitialized); }
static async Task DoClientWork() { // basic configuration var clientconfig = new Orleans.Runtime.Configuration.ClientConfiguration(); clientconfig.Gateways.Add(new IPEndPoint(IPAddress.Loopback, 30000)); GrainClient.Initialize(clientconfig); var idE1 = "5ad92744-a0b1-487b-a9e7-e6b91e9a9826"; var idE2 = "2eef0ac5-540f-4421-b9a9-79d89400f7ab"; var e1 = GrainClient.GrainFactory.GetGrain <IEmployee>(Guid.Parse(idE1)); var e2 = GrainClient.GrainFactory.GetGrain <IEmployee>(Guid.Parse(idE2)); Console.WriteLine("Current State:"); await e1.Print(); await e2.Print(); if (!await e1.SpendCurrency(10)) { Console.WriteLine("Employee {0} does not have 10 currency to spend", idE1); } if (!await e2.SpendCurrency(10)) { Console.WriteLine("Employee {0} does not have 10 currency to spend", idE2); } await e1.AddCurrency(20); await e2.AddGoods(10); await e1.Print(); await e2.Print(); var transaction = new TransactionHelper <EmployeeStateTransfer>(); transaction.Add(e1, new EmployeeStateTransfer() { Currency = -5, Goods = 5 }); transaction.Add(e2, new EmployeeStateTransfer() { Currency = 5, Goods = -5 }); Console.WriteLine("Executing transaction to trade 5 currency for 5 goods... "); await transaction.Execute(); Console.WriteLine("Transaction complete."); await e1.Print(); await e2.Print(); Console.WriteLine("Done!"); }
private static void DoSomeClientWork() { var clientconfig=new Orleans.Runtime.Configuration.ClientConfiguration(); clientconfig.Gateways.Add(new IPEndPoint(IPAddress.Loopback, 30000)); GrainClient.Initialize(clientconfig); var friend = GrainClient.GrainFactory.GetGrain<IHello>(0); var result = friend.SayHello("Goodbye").Result; Console.WriteLine(result); }
static void DoSomeClientWork() { var clientconfig = new Orleans.Runtime.Configuration.ClientConfiguration(); clientconfig.Gateways.Add(new IPEndPoint(IPAddress.Loopback, 30000)); GrainClient.Initialize(clientconfig); var friend = GrainClient.GrainFactory.GetGrain <IHello>(0); var result = friend.SayHello("Goodbye").Result; Console.WriteLine(result); }
static async Task DoClientWork() { // basic configuration var clientconfig = new Orleans.Runtime.Configuration.ClientConfiguration(); clientconfig.Gateways.Add(new IPEndPoint(IPAddress.Loopback, 30000)); GrainClient.Initialize(clientconfig); var idE1 = "5ad92744-a0b1-487b-a9e7-e6b91e9a9826"; var idE2 = "2eef0ac5-540f-4421-b9a9-79d89400f7ab"; var e1 = GrainClient.GrainFactory.GetGrain<IEmployee>(Guid.Parse(idE1)); var e2 = GrainClient.GrainFactory.GetGrain<IEmployee>(Guid.Parse(idE2)); Console.WriteLine("Current State:"); await e1.Print(); await e2.Print(); if (!await e1.SpendCurrency(10)) { Console.WriteLine("Employee {0} does not have 10 currency to spend", idE1); } if (!await e2.SpendCurrency(10)) { Console.WriteLine("Employee {0} does not have 10 currency to spend", idE2); } await e1.AddCurrency(20); await e2.AddGoods(10); await e1.Print(); await e2.Print(); var transaction = new TransactionHelper<EmployeeStateTransfer>(); transaction.Add(e1, new EmployeeStateTransfer() { Currency = -5, Goods = 5 }); transaction.Add(e2, new EmployeeStateTransfer() { Currency = 5, Goods = -5 }); Console.WriteLine("Executing transaction to trade 5 currency for 5 goods... "); await transaction.Execute(); Console.WriteLine("Transaction complete."); await e1.Print(); await e2.Print(); Console.WriteLine("Done!"); }
public static bool TryStart(string location, string hostname) { try { if (Orleans.GrainClient.IsInitialized) { return(true); } //IPAddress ip = GetIP(hostname); IPAddress ip = System.Net.Dns.GetHostAddresses(hostname)[0]; var config = new Orleans.Runtime.Configuration.ClientConfiguration(); config.Gateways.Add(new IPEndPoint(ip, 30000)); config.OpenConnectionTimeout = TimeSpan.FromMinutes(4); Orleans.GrainClient.Initialize(config); } catch (Exception ex) { Trace.TraceWarning("Failed to intiailize orleans client via hostname"); Trace.TraceError(ex.Message); } return(Orleans.GrainClient.IsInitialized); }
public override void AdjustForTest(Orleans.Runtime.Configuration.ClientConfiguration config) { config.RegisterStreamProvider <AzureQueueStreamProvider>(AQStreamProviderName, new Dictionary <string, string>()); base.AdjustForTest(config); }