silo cluster configuration notes (unsuccessfully)

using Com.Auth;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Orleans.Configuration;
using Orleans.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reflection;

namespace Orleans.SiloHost {
    class Startup {
        public IConfigurationRoot Configuration { get; internal set; }
        List<LoadItem> loads;
        internal void ConfigureService(IServiceCollection services) {
            services.Configure<List<LoadItem>>(Configuration.GetSection("loads"));
            var sp = services.BuildServiceProvider();
            var optionAccess = sp.GetService<IOptions<List<LoadItem>>>();
            loads = optionAccess.Value;
            services.AddDbContext<DbAuth>(option => {
                option.UseSqlite(Configuration["dbcon:com_auth"]);
            });
        }

        internal void SiloSetting(ISiloBuilder isb) {
            //isb.UseLocalhostClustering();
            isb.Configure<ClusterOptions>(options => {
                options.ClusterId = Fone.Orleans.OrleansBasic.DefaultClusterId;
                options.ServiceId = Fone.Orleans.OrleansBasic.DefaultServerId;
            });
            isb.Configure<EndpointOptions>(options => {
                //IP is here determines the machine or within the public network or
                 // options.AdvertisedIPAddress GetInternalIp = ();
                 // options.AdvertisedIPAddress = IPAddress.Loopback; 
                . Options.AdvertisedIPAddress = Dns.GetHostEntry (Dns.GetHostName ()) AddressList [ 0 ] .MapToIPv6 (); 
                options.SiloPort = int .Parse (the Configuration [ " Endpoint: s2s_send_port " ]);
                 //   Gateway port 
                options.GatewayPort = int .Parse (the Configuration [ " Endpoint: c2s_send_port " ]);
                 / / listening silo remote connection point
                = options.GatewayListeningEndpoint new new the IPEndPoint (options.AdvertisedIPAddress, options.GatewayPort);
                 // listening silo remote port junction 
                options.SiloListeningEndpoint = new new the IPEndPoint (options.AdvertisedIPAddress, options.SiloPort);
                 // gateway (client-> silo) listening endpoint
                 // options.GatewayListeningEndpoint the IPEndPoint new new = (IPAddress.Any, the int.Parse (the Configuration [ "Endpoint: c2s_listen_port"]));
                 // listening between the silo (silo-> silo) endpoint
                 // options.SiloListeningEndpoint = new IPEndPoint (IPAddress.Any, int.Parse (Configuration [ "endpoint: s2s_listen_port"]));
            });
            var assemblys = from i in loads
                            where !string.IsNullOrWhiteSpace(i.location)
                            select Assembly.Load(i.location);
            foreach (var item in assemblys) {
                Console.WriteLine(item.GetName());
                isb.ConfigureApplicationParts(parts => parts.AddApplicationPart(item).WithReferences());
            }
            isb.UseAdoNetClustering((AdoNetClusteringSiloOptions options) => {
                options.ConnectionString = the Configuration [ " dbcon: cluster_mssql " ]; 
                options.Invariant = " the System.Data.SqlClient " ; 
            }); 
            // listening silo main space remote connection point is created a connection point of the main silo
             // NYC. UseDevelopmentClustering (the IPEndPoint new new (IPAddress.Parse ( "192.168.8.1"), 11111)); 
        } 

        Internal  void ConfigureLogging (ILoggingBuilder ILB) { 
            ilb.AddConsole (); 
        } 
    } 
    static  public  class HostEx {
         static  public IHostBuilder ConfigByStartup(this IHostBuilder ihb) {
            var su = new Startup();
            ihb.ConfigureLogging(ilb => {
                su.ConfigureLogging(ilb);
            });
            ihb.ConfigureAppConfiguration(icb => {
                //icb.SetBasePath(
                //    System.IO.Path.GetFullPath("../../../")
                //    );
                icb.AddJsonFile("appsettings.json");
                su.Configuration = icb.Build();
            });

            ihb.ConfigureServices(services => {
                su.ConfigureService(services);
            });
            ihb.UseOrleans(isb => {
                su.SiloSetting(isb);
            });
            return ihb;
        }
    }
}

It is worth mentioning is the following sentence:

 
options.AdvertisedIPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].MapToIPv6();
 

Sentence, before using a MapToIPv4 () method results of a given value, then finally tried a handful of IPv6, the result is successful, this is not the use of public address 127.0.0.1 great significance because silo cluster general this is the need for multiple public network ip-machine communication is necessary, now go several ports configuration file read, but


        

using Com.Auth;using Microsoft.EntityFrameworkCore;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Hosting;using Microsoft.Extensions.Logging;using Microsoft.Extensions.Options;using Orleans.Configuration;using Orleans.Hosting;using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Reflection;
namespace Orleans.SiloHost {    class Startup {        public IConfigurationRoot Configuration { get; internal set; }        List<LoadItem> loads;        internal void ConfigureService(IServiceCollection services) {            services.Configure<List<LoadItem>>(Configuration.GetSection("loads"));            var sp = services.BuildServiceProvider();            var optionAccess = sp.GetService<IOptions<List<LoadItem>>>();            loads = optionAccess.Value;            services.AddDbContext<DbAuth>(option => {                option.UseSqlite(Configuration["dbcon:com_auth"]);            });        }
        internal void SiloSetting (ISiloBuilder isb) {//isb.UseLocalhostClustering (); isb.Configure <ClusterOptions> (options => {options.ClusterId = Fone.Orleans.OrleansBasic.DefaultClusterId; options.ServiceId = Fone.Orleans.OrleansBasic.DefaultServerId ;}); isb.Configure <EndpointOptions> (options => {// IP determines herein is a native or intranet or a public network //options.AdvertisedIPAddress = GetInternalIp (); //options.AdvertisedIPAddress = IPAddress.Loopback ; options.AdvertisedIPAddress = Dns.GetHostEntry (Dns.GetHostName ()) AddressList [0] .MapToIPv6 (); options.SiloPort = int.Parse. (Configuration [ "endpoint: s2s_send_port"]); // gateway port options. GatewayPort = int.Parse (Configuration [ "endpoint: c2s_send_port"]); // listening silo remote connection point options.GatewayListeningEndpoint = new IPEndPoint (options.AdvertisedIPAddress, options.GatewayPort); // listening silo remote port junction options.SiloListeningEndpoint = new IPEndPoint (options.AdvertisedIPAddress, options.SiloPort); // listening endpoint gateway (client-> silo) point //options.GatewayListeningEndpoint = new IPEndPoint (IPAddress.Any, int.Parse (Configuration [ "endpoint: c2s_listen_port"]) ); between // silo (silo-> silo) listening endpoint //options.SiloListeningEndpoint = new IPEndPoint (IPAddress.Any, int.Parse (Configuration [ "endpoint: s2s_listen_port"]));}); var assemblys = from i in loads where! string.IsNullOrWhiteSpace (i.location) select Assembly.Load (i.location); foreach (var item in assemblys) {Console.WriteLine (item.GetName ()); isb.ConfigureApplicationParts (parts => parts.AddApplicationPart (item) .WithReferences ()); } isb.UseAdoNetClustering ((AdoNetClusteringSiloOptions options) => {options.ConnectionString = Configuration [ "dbcon: cluster_mssql"]; options.Invariant = "System.Data.SqlClient";}); // main silo remote listening to the point of attachment create a master empty silo connection point //isb.UseDevelopmentClustering(new IPEndPoint (IPAddress.Parse ( "192.168.8.1"), 11111));}isb.ConfigureApplicationParts (parts => parts.AddApplicationPart (item) .WithReferences ());} isb.UseAdoNetClustering ((AdoNetClusteringSiloOptions options) => {options.ConnectionString = Configuration [ "dbcon: cluster_mssql"]; options.Invariant = "System .Data.SqlClient ";}); // main silo remote connection point of the listening space to create a main silo connection point //isb.UseDevelopmentClustering(new IPEndPoint (IPAddress.Parse (as" 192.168.8.1 "), 11111)) ;}isb.ConfigureApplicationParts (parts => parts.AddApplicationPart (item) .WithReferences ());} isb.UseAdoNetClustering ((AdoNetClusteringSiloOptions options) => {options.ConnectionString = Configuration [ "dbcon: cluster_mssql"]; options.Invariant = "System .Data.SqlClient ";}); // main silo remote connection point of the listening space to create a main silo connection point //isb.UseDevelopmentClustering(new IPEndPoint (IPAddress.Parse (as" 192.168.8.1 "), 11111)) ;}Invariant = "System.Data.SqlClient";}); // main silo remote connection point of the listening space to create a main silo connection point //isb.UseDevelopmentClustering(new IPEndPoint (IPAddress.Parse ( "192.168.8.1") is , 11111));Invariant = "System.Data.SqlClient";}); // main silo remote connection point of the listening space to create a main silo connection point //isb.UseDevelopmentClustering(new IPEndPoint (IPAddress.Parse ( "192.168.8.1") is , 11111));
        internal void ConfigureLogging(ILoggingBuilder ilb) {            ilb.AddConsole();        }    }    static public class HostEx {        static public IHostBuilder ConfigByStartup(this IHostBuilder ihb) {            var su = new Startup();            ihb.ConfigureLogging(ilb => {                su.ConfigureLogging(ilb);            });            ihb.ConfigureAppConfiguration(icb => {                //icb.SetBasePath(                //    System.IO.Path.GetFullPath("../../../")                //    );                icb.AddJsonFile("appsettings.json");                su.Configuration = icb.Build();            });
            ihb.ConfigureServices(services => {                su.ConfigureService(services);            });            ihb.UseOrleans(isb => {                su.SiloSetting(isb);            });            return ihb;        }    }}

 

Guess you like

Origin www.cnblogs.com/ProjectDD/p/12348188.html