Esempio n. 1
0
        private void CreateClusteredSiloHost()
        {
            var silo = new SiloHostBuilder()
                       .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = orleansConfig.ClusterId;
                options.ServiceId = orleansConfig.ServiceId;
            });
            //.EnableDirectClient();

            string storageType = GetStorageType(orleansConfig.DataConnectionString);

            if (storageType.ToLowerInvariant() == "redis")
            {
                silo.UseRedisMembership(options => options.ConnectionString            = orleansConfig.DataConnectionString);
                silo.AddRedisGrainStorage("store", options => options.ConnectionString = orleansConfig.DataConnectionString);
            }
            else if (storageType.ToLowerInvariant() == "azurestorage")
            {
                silo.UseAzureStorageClustering(options => options.ConnectionString         = orleansConfig.DataConnectionString);
                silo.AddAzureBlobGrainStorage("store", options => options.ConnectionString = orleansConfig.DataConnectionString);
            }
            else
            {
                //throw
            }

            silo.ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000);

            LogLevel orleansLogLevel = GetLogLevel();
            var      loggers         = orleansConfig.GetLoggerTypes();

            silo.ConfigureLogging(builder =>
            {
                if (loggers.HasFlag(LoggerType.Console))
                {
                    builder.AddConsole();
                }
                if (loggers.HasFlag(LoggerType.Debug))
                {
                    builder.AddDebug();
                }
                builder.SetMinimumLevel(orleansLogLevel);
            });

            if (loggers.HasFlag(LoggerType.AppInsights) && !string.IsNullOrEmpty(orleansConfig.AppInsightsKey))
            {
                silo.AddApplicationInsightsTelemetryConsumer(orleansConfig.AppInsightsKey);
            }
            host = silo.Build();

            var clusterClient = (IClusterClient)host.Services.GetService(typeof(IClusterClient));

            GraphManager.Initialize(clusterClient);
        }
Esempio n. 2
0
        private ISiloHost AddClusteredSiloHost()
        {
            var silo = new SiloHostBuilder()
                       .Configure <ClusterOptions>(options =>
            {
                options.ClusterId = orleansConfig.ClusterId;
                options.ServiceId = orleansConfig.ServiceId;
            });


            if (string.IsNullOrEmpty(orleansConfig.DataConnectionString))
            {
                silo.AddMemoryGrainStorage("store");
            }
            else if (orleansConfig.DataConnectionString.Contains("6379") ||
                     orleansConfig.DataConnectionString.Contains("6380"))
            {
                silo.UseRedisMembership(options => options.ConnectionString            = orleansConfig.DataConnectionString);
                silo.AddRedisGrainStorage("store", options => options.ConnectionString = orleansConfig.DataConnectionString);
            }
            else
            {
                silo.UseAzureStorageClustering(options => options.ConnectionString         = orleansConfig.DataConnectionString);
                silo.AddAzureBlobGrainStorage("store", options => options.ConnectionString = orleansConfig.DataConnectionString);
            }

            silo.ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000);

            LogLevel orleansLogLevel = Enum.Parse <LogLevel>(orleansConfig.LogLevel);
            var      loggers         = orleansConfig.GetLoggerTypes();

            silo.ConfigureLogging(builder =>
            {
                if (loggers.HasFlag(LoggerType.Console))
                {
                    builder.AddConsole();
                }
                if (loggers.HasFlag(LoggerType.Debug))
                {
                    builder.AddDebug();
                }
                builder.SetMinimumLevel(orleansLogLevel);
            });

            if (!string.IsNullOrEmpty(orleansConfig.AppInsightsKey))
            {
                silo.AddApplicationInsightsTelemetryConsumer(orleansConfig.AppInsightsKey);
            }

            return(silo.Build());
        }