public ExceptionTests() { this.silo = SiloHostBuilder.CreateDefault().ConfigureApplicationParts(parts => parts.AddFromAppDomain()).ConfigureLocalHostPrimarySilo().Build(); this.silo.StartAsync().GetAwaiter().GetResult(); this.client = ClientBuilder.CreateDefault().ConfigureApplicationParts(parts => parts.AddFromAppDomain()).UseConfiguration(ClientConfiguration.LocalhostSilo()).Build(); this.client.Connect().GetAwaiter().GetResult(); }
public void ClientBuilder_DoubleSpecifyConfigurationTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators) .UseConfiguration(new ClientConfiguration()) .UseConfiguration(new ClientConfiguration()); Assert.Throws <InvalidOperationException>(() => builder.Build()); }
public void ClientBuilder_DoubleBuildTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators); using (builder.Build()) { Assert.Throws <InvalidOperationException>(() => builder.Build()); } }
public void ClientBuilder_NoSpecifiedConfigurationTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators); using (var client = builder.Build()) { Assert.NotNull(client); } }
public void ClientBuilder_DoubleBuildTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators) .ConfigureServices(services => services.AddSingleton <IGatewayListProvider, NoOpGatewaylistProvider>()); using (builder.Build()) { Assert.Throws <InvalidOperationException>(() => builder.Build()); } }
public void ClientBuilder_NoSpecifiedConfigurationTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators) .ConfigureServices(services => services.AddSingleton <IGatewayListProvider, NoOpGatewaylistProvider>()); using (var client = builder.Build()) { Assert.NotNull(client); } }
static async Task InitializeOrleans() { //var config = new ClusterConfiguration(); //config.Globals.DataConnectionString = "Server=tnwli-pc.dmtnprod.lan;Database=ApprovalSystem;User Id=QTIP;Password=QTIP; "; //config.Globals.ClusterId = "AprovalSiloID"; //config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.SqlServer; //config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.SqlServer; //config.Defaults.PropagateActivityId = true; //config.Defaults.ProxyGatewayEndpoint = new System.Net.IPEndPoint(IPAddress.Any, 18000); var config = new ClientConfiguration(); config.ClusterId = "AprovalSiloID"; config.PropagateActivityId = true; config.AdoInvariant = "System.Data.SqlClient"; config.DataConnectionString = "Server=tnwli-pc.dmtnprod.lan;Database=ApprovalSystem;User Id=QTIP;Password=QTIP; "; config.GatewayProvider = ClientConfiguration.GatewayProviderType.SqlServer; Console.WriteLine("Initializing ... "); client = new ClientBuilder() .ConfigureApplicationParts(p => p.AddFromAppDomain().AddFromApplicationBaseDirectory()) .UseConfiguration(config).Build(); var builder = ClientBuilder.CreateDefault() .UseConfiguration(config) .ConfigureApplicationParts(parts => parts.AddFromAppDomain().AddFromApplicationBaseDirectory()); client = builder.Build(); try { await client.Connect(); running = true; Console.WriteLine("Initialized."); var grain = client.GetGrain <IUser>(Guid.Empty); while (running) { string proposal = "ACED Proposal"; //int num = 15; var response = await grain.Approve(proposal); Console.WriteLine($"{proposal} was Approved : { response}"); await Task.Delay(1000); } client.Dispose(); } catch (Exception ex) { throw ex; } }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(); options.UseSiloBuilderFactory <SiloBuilder>(); options.ClientBuilderFactory = cfg => ClientBuilder .CreateDefault() .UseConfiguration(cfg) .ConfigureApplicationParts( parts => parts.AddApplicationPart(typeof(IRuntimeCodeGenGrain).Assembly).WithCodeGeneration()); return(new TestCluster(options)); }
public void ClientBuilder_AssembliesTest() { var builder = ClientBuilder.CreateDefault(); Assert.Throws <OrleansConfigurationException>(() => builder.Build()); // Adding an application assembly causes the builder = ClientBuilder.CreateDefault().AddApplicationPart(typeof(IAccountGrain).Assembly); using (var client = builder.Build()) { Assert.NotNull(client); } }
public SerializationTestEnvironment(ClientConfiguration config = null, Action <IClientBuilder> configureClientBuilder = null) { if (config == null) { config = this.DefaultConfig(); } var builder = ClientBuilder.CreateDefault(); builder.UseConfiguration(config); builder.ConfigureApplicationParts(parts => parts.AddFromAppDomain().AddFromApplicationBaseDirectory()); configureClientBuilder?.Invoke(builder); this.Client = builder.Build(); this.RuntimeClient = this.Client.ServiceProvider.GetRequiredService <OutsideRuntimeClient>(); }
protected override TestCluster CreateTestCluster() { var options = new TestClusterOptions(); ILoggerFactory codeGenLoggerFactory = new LoggerFactory(); codeGenLoggerFactory.AddProvider(new FileLoggerProvider("ClientCodeGeneration.log")); options.UseSiloBuilderFactory <SiloBuilder>(); options.ClientBuilderFactory = cfg => ClientBuilder .CreateDefault() .UseConfiguration(cfg) .ConfigureApplicationParts( parts => parts.AddApplicationPart(typeof(IRuntimeCodeGenGrain).Assembly).WithCodeGeneration(codeGenLoggerFactory.CreateLogger("RuntimeCodeGen"))); return(new TestCluster(options)); }
public void ClientBuilder_ServiceProviderTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators) .ConfigureServices(services => services.AddSingleton <IGatewayListProvider, NoOpGatewaylistProvider>()); Assert.Throws <ArgumentNullException>(() => builder.ConfigureServices(null)); var registeredFirst = new int[1]; var one = new MyService { Id = 1 }; builder.ConfigureServices( services => { Interlocked.CompareExchange(ref registeredFirst[0], 1, 0); services.AddSingleton(one); }); var two = new MyService { Id = 2 }; builder.ConfigureServices( services => { Interlocked.CompareExchange(ref registeredFirst[0], 2, 0); services.AddSingleton(two); }); using (var client = builder.Build()) { var services = client.ServiceProvider.GetServices <MyService>()?.ToList(); Assert.NotNull(services); // Both services should be registered. Assert.Equal(2, services.Count); Assert.NotNull(services.FirstOrDefault(svc => svc.Id == 1)); Assert.NotNull(services.FirstOrDefault(svc => svc.Id == 2)); // Service 1 should have been registered first - the pipeline order should be preserved. Assert.Equal(1, registeredFirst[0]); // The last registered service should be provided by default. Assert.Equal(2, client.ServiceProvider.GetRequiredService <MyService>().Id); } }
public ExceptionTests() { this.silo = SiloHostBuilder.CreateDefault() .ConfigureApplicationParts( parts => parts.AddApplicationPart(typeof(ExceptionGrain).Assembly).WithReferences()) .ConfigureLocalHostPrimarySilo() .Build(); this.silo.StartAsync().GetAwaiter().GetResult(); this.client = ClientBuilder.CreateDefault() .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IExceptionGrain).Assembly).WithReferences()) .UseConfiguration(ClientConfiguration.LocalhostSilo()) .Build(); this.client.Connect().GetAwaiter().GetResult(); }
private static async Task Run() { ClientConfiguration clientConfig = ClientConfiguration.LoadFromFile("ClientConfiguration.xml"); IClientBuilder clientBuilder = ClientBuilder.CreateDefault(); IClusterClient clusterClient = clientBuilder.UseConfiguration(clientConfig) .Build(); await clusterClient.Connect(); Console.WriteLine("输入手机号"); var number = Console.ReadLine(); var userService = clusterClient.GetGrain <IUserService>(1); var result = userService.Exist(number); while (!result.IsCompleted) { } if (result.Status == TaskStatus.Faulted) { foreach (var exceptionInnerException in result.Exception.InnerExceptions) { Console.WriteLine(exceptionInnerException.Message); } } //try //{ // result.Wait(); //} //catch (AggregateException e) //{ // foreach (var eInnerException in e.InnerExceptions) // { // Console.WriteLine(eInnerException.Message); // } // Console.WriteLine(e.Message); //} Console.WriteLine(result.Result); await clusterClient.Close(); }
public void ClientBuilder_NullConfigurationTest() { var builder = ClientBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators); Assert.Throws <ArgumentNullException>(() => builder.UseConfiguration(null)); }