コード例 #1
0
 public ISiloHostBuilder CreateSiloBuilder(string siloName, ClusterConfiguration clusterConfiguration)
 {
     return(SiloHostBuilder
            .CreateDefault()
            .UseConfiguration(clusterConfiguration)
            .ConfigureSiloName(siloName)
            .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IRuntimeCodeGenGrain).Assembly).WithCodeGeneration()));
 }
コード例 #2
0
        public void SiloHostBuilder_NullConfigurationTest()
        {
            var builder = SiloHostBuilder.CreateDefault()
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().AddFromAppDomain())
                          .ConfigureServices(RemoveConfigValidators);

            Assert.Throws <ArgumentNullException>(() => builder.UseConfiguration(null));
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        public void SiloHostBuilder_DoubleSpecifyConfigurationTest()
        {
            var builder = SiloHostBuilder.CreateDefault()
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().AddFromAppDomain())
                          .ConfigureServices(RemoveConfigValidators).UseConfiguration(new ClusterConfiguration()).UseConfiguration(new ClusterConfiguration());

            Assert.Throws <InvalidOperationException>(() => builder.Build());
        }
コード例 #5
0
        public void SiloHostBuilder_DoubleBuildTest()
        {
            var builder = SiloHostBuilder.CreateDefault().UseConfiguration(new ClusterConfiguration()).ConfigureServices(RemoveConfigValidators);

            using (builder.Build())
            {
                Assert.Throws <InvalidOperationException>(() => builder.Build());
            }
        }
コード例 #6
0
        public void SiloHostBuilder_NoSpecifiedConfigurationTest()
        {
            var builder = SiloHostBuilder.CreateDefault().UseConfiguration(new ClusterConfiguration()).ConfigureServices(RemoveConfigValidators);

            using (var silo = builder.Build())
            {
                Assert.NotNull(silo);
            }
        }
コード例 #7
0
        public void SiloHostBuilder_NoSpecifiedConfigurationTest()
        {
            var builder = SiloHostBuilder.CreateDefault()
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().AddFromAppDomain())
                          .UseConfiguration(new ClusterConfiguration()).ConfigureServices(RemoveConfigValidators);

            using (var silo = builder.Build())
            {
                Assert.NotNull(silo);
            }
        }
コード例 #8
0
            public ISiloHostBuilder CreateSiloBuilder(string siloName, ClusterConfiguration clusterConfiguration)
            {
                ILoggerFactory codeGenLoggerFactory = new LoggerFactory();

                codeGenLoggerFactory.AddProvider(new FileLoggerProvider($"{siloName}-CodeGeneration.log"));
                return(SiloHostBuilder
                       .CreateDefault()
                       .UseConfiguration(clusterConfiguration)
                       .ConfigureSiloName(siloName)
                       .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IRuntimeCodeGenGrain).Assembly).WithCodeGeneration(codeGenLoggerFactory.CreateLogger("RuntimeCodeGen"))));
            }
コード例 #9
0
        public void SiloHostBuilder_DoubleBuildTest()
        {
            var builder = SiloHostBuilder.CreateDefault()
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().AddFromAppDomain())
                          .UseConfiguration(new ClusterConfiguration()).ConfigureServices(RemoveConfigValidators)
                          .ConfigureServices(services => services.AddSingleton <IMembershipTable, NoOpMembershipTable>());

            using (builder.Build())
            {
                Assert.Throws <InvalidOperationException>(() => builder.Build());
            }
        }
コード例 #10
0
        public void SiloHostBuilder_AssembliesTest()
        {
            var builder = SiloHostBuilder.CreateDefault();

            Assert.Throws <OrleansConfigurationException>(() => builder.Build());

            // Adding an application assembly causes the
            builder = SiloHostBuilder.CreateDefault().UseConfiguration(new ClusterConfiguration()).AddApplicationPart(typeof(IAccountGrain).Assembly);
            using (var silo = builder.Build())
            {
                Assert.NotNull(silo);
            }
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: raidnav/DDBMSP
        private static void StartSilo()
        {
            var config = new SiloHost(Dns.GetHostName(), new FileInfo("OrleansConfiguration.xml"));

            if (Environment.GetEnvironmentVariable("LAUCHING_ENV") == "LOCALHOST")
            {
                config.Config = ClusterConfiguration.LocalhostPrimarySilo();
                config.Config.AddMemoryStorageProvider("RedisStore");
            }
            else
            {
                config.Config.Globals.MembershipTableAssembly = typeof(Orleans.ConsulUtils.LegacyConsulGatewayListProviderConfigurator).Assembly.FullName;
                var consulIps = Dns.GetHostAddressesAsync("consul").Result;
                config.Config.Globals.DataConnectionString = $"http://{consulIps.First()}:8500";
                config.Config.Globals.LivenessType         = GlobalConfiguration.LivenessProviderType.Custom;

                var ips = Dns.GetHostAddressesAsync(Dns.GetHostName()).Result;
                config.Config.Defaults.HostNameOrIPAddress = ips.FirstOrDefault()?.ToString();

                config.Config.Globals.RegisterStorageProvider <Orleans.StorageProviders.RedisStorage.RedisStorage>(
                    "RedisStore", new Dictionary <string, string>()
                {
                    { "RedisConnectionString", "storage" },
                    { "UseJsonFormat", "false" }
                });
            }


            config.Config.Globals.ClusterId           = "DDBMSP-Cluster";
            config.Config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.Disabled;
            config.Config.Globals.SerializationProviders.Add(typeof(ProtobufSerializer).GetTypeInfo());
            config.Config.RegisterDashboard();

            var builder = SiloHostBuilder.CreateDefault().UseConfiguration(config.Config);

            builder.GetApplicationPartManager()
            .AddApplicationPart(typeof(Common.CSharpRepl.Context).Assembly)
            .AddApplicationPart(typeof(ArticleState).Assembly)
            .AddFromApplicationBaseDirectory()
            .AddApplicationPart(typeof(Interfaces.Grains.Aggregators.IAggregator <>).Assembly);

            SiloHost = builder.ConfigureSiloName(Dns.GetHostName())
                       .UseDashboard(options => {
                options.HostSelf = true;
                options.Port     = 8080;
                options.Host     = "*";
            })
                       .Build();

            SiloHost.StartAsync();
        }
コード例 #12
0
        public void SiloHostBuilder_ServiceProviderTest()
        {
            var builder = SiloHostBuilder.CreateDefault()
                          .ConfigureApplicationParts(parts => parts.AddFromApplicationBaseDirectory().AddFromAppDomain())
                          .UseConfiguration(new ClusterConfiguration()).ConfigureServices(RemoveConfigValidators)
                          .ConfigureServices(services => services.AddSingleton <IMembershipTable, NoOpMembershipTable>());

            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 silo = builder.Build())
            {
                var services = silo.Services.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, silo.Services.GetRequiredService <MyService>().Id);
            }
        }
コード例 #13
0
ファイル: ExceptionTests.cs プロジェクト: zsybupt/orleans
        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();
        }
コード例 #14
0
        public void SiloHostBuilder_NullConfigurationTest()
        {
            var builder = SiloHostBuilder.CreateDefault().ConfigureServices(RemoveConfigValidators);

            Assert.Throws <ArgumentNullException>(() => builder.UseConfiguration(null));
        }