当前位置: 首页>>代码示例>>C#>>正文


C# Host.SiloHost类代码示例

本文整理汇总了C#中Orleans.Runtime.Host.SiloHost的典型用法代码示例。如果您正苦于以下问题:C# SiloHost类的具体用法?C# SiloHost怎么用?C# SiloHost使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SiloHost类属于Orleans.Runtime.Host命名空间,在下文中一共展示了SiloHost类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main()
        {
            while (true)
            {
                Console.WriteLine("请输入配置文件名称:");
                var configName = Console.ReadLine();
                var configFile = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                    $"{Path.GetFileNameWithoutExtension(configName)}.xml"));
                if (!configFile.Exists)
                {
                    Console.WriteLine($"配置文件:{configFile.FullName},不存在!");
                    continue;
                }
                Console.WriteLine("请输入节点名称:");
                var nodeName = Console.ReadLine() ?? string.Empty;
                using (var host = new SiloHost(nodeName, configFile))
                {
                    host.LoadOrleansConfig();
                    host.InitializeOrleansSilo();
                    host.StartOrleansSilo();

                    Console.WriteLine("已启动,按下任意键退出。");
                    Console.ReadLine();

                    host.StopOrleansSilo();
                }
                break;
            }
        }
开发者ID:andyshao,项目名称:Samples-1,代码行数:29,代码来源:Program.cs

示例2: Run

        private static void Run()
        {
            var config = GetClusterConfiguration();
            config.Globals.SeedNodes.Add(new IPEndPoint(IPAddress.Loopback, 11111));
            config.Defaults.HostNameOrIPAddress = "localhost";
            config.Defaults.Port = 11111;
            config.Defaults.ProxyGatewayEndpoint = new IPEndPoint(IPAddress.Loopback, 12345);

            var process = Process.GetCurrentProcess();
            var name = Environment.MachineName + "_" + process.Id + Guid.NewGuid().ToString("N").Substring(3);

            var silo = new SiloHost(name, config);

            // Configure the silo for the current environment.
            silo.SetSiloType(Silo.SiloType.Primary);

            Trace.TraceInformation("Silo configuration: \n" + silo.Config.ToString(name));

            silo.InitializeOrleansSilo();
            Trace.TraceInformation("Successfully initialized Orleans silo '{0}' as a {1} node.", silo.Name, silo.Type);
            Trace.TraceInformation("Starting Orleans silo '{0}' as a {1} node.", silo.Name, silo.Type);

            if (silo.StartOrleansSilo())
            {
                silo.WaitForOrleansSiloShutdown();
            }
        }
开发者ID:OrleansContrib,项目名称:Orleans.Consensus,代码行数:27,代码来源:Program.cs

示例3: InitSilo

 private static void InitSilo(string[] args)
 {
     siloHost=new SiloHost(System.Net.Dns.GetHostName());
     siloHost.ConfigFileName = "OrleansConfiguration.xml";
     siloHost.InitializeOrleansSilo();
     var startedOk = siloHost.StartOrleansSilo();
     if (!startedOk)
     {
         throw new SystemException(String.Format("Failed to start Orleans silo '{0}' as a {1} node", siloHost.Name, siloHost.Type));
     }
 }
开发者ID:feizeikesi,项目名称:Orleans,代码行数:11,代码来源:Program.cs

示例4: InitSilo

        static void InitSilo(string[] args)
        {
            siloHost = new SiloHost(System.Net.Dns.GetHostName());
            // The Cluster config is quirky and weird to configure in code, so we're going to use a config file
            siloHost.ConfigFileName = "OrleansConfiguration.xml";

            siloHost.InitializeOrleansSilo();
            var startedok = siloHost.StartOrleansSilo();
            if (!startedok)
                throw new SystemException(String.Format("Failed to start Orleans silo '{0}' as a {1} node", siloHost.Name, siloHost.Type));
        }
开发者ID:jeoffman,项目名称:OrleansStreamingTest,代码行数:11,代码来源:Program.cs

示例5: Main

        private static void Main(string[] args){
            using (SiloHost host = new SiloHost("Default")){
                host.LoadOrleansConfig();
                host.InitializeOrleansSilo();
                host.StartOrleansSilo();

                Console.WriteLine("Start--------");
                Console.ReadLine();

                host.StopOrleansSilo();
            }
        }
开发者ID:lzlzlz911,项目名称:Orleans4Net,代码行数:12,代码来源:Program.cs

示例6: OrleansHostWrapper

 /// <summary>
 /// start secondary
 /// </summary>
 /// <param name="port"></param>
 /// <param name="proxyPort"></param>
 public OrleansHostWrapper(int port, int proxyPort)
 {
     var config = new ClusterConfiguration();
     var siloAddress = new IPEndPoint(IPAddress.Loopback, 22222);
     config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.MembershipTableGrain;
     config.Globals.SeedNodes.Add(siloAddress);
     config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain;
     config.Defaults.HostNameOrIPAddress = "localhost";
     config.Defaults.Port = port;
     config.Defaults.ProxyGatewayEndpoint = new IPEndPoint(IPAddress.Loopback, proxyPort);
     config.PrimaryNode = siloAddress;
     siloHost = new SiloHost("secondary", config);
 }
开发者ID:OrleansContrib,项目名称:OrleansDashboard,代码行数:18,代码来源:OrleansHostWrapper.cs

示例7: InitSilo

        static void InitSilo(string[] args)
        {
            siloHost = new SiloHost(System.Net.Dns.GetHostName());
            // possible from code, but easier via config
            siloHost.ConfigFileName = "OrleansConfiguration.xml";

            siloHost.InitializeOrleansSilo();
            var startedok = siloHost.StartOrleansSilo();
            if (!startedok)
            {
                throw new SystemException(String.Format("Failed to start silo '{0}' as '{1}' node", siloHost.Name, siloHost.Type));
            }
        }
开发者ID:saeedakhter,项目名称:OrleansStrongConsistency,代码行数:13,代码来源:Program.cs

示例8: InitSilo

        static void InitSilo(string[] args)
        {
            _siloHost = new SiloHost(Dns.GetHostName())
            {
                ConfigFileName = "ServerConfiguration.xml"
            };

            _siloHost.InitializeOrleansSilo();

            var startedOk = _siloHost.StartOrleansSilo();

            if (!startedOk)
                throw new SystemException($"Failed to start Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node");
        }
开发者ID:legigor,项目名称:talkach,代码行数:14,代码来源:Program.cs

示例9: OrleansHostWrapper

        public OrleansHostWrapper(ClusterConfiguration config, string[] args)
        {
            var siloArgs = SiloArgs.ParseArguments(args);
            if (siloArgs == null)
            {
                return;
            }

            if (siloArgs.DeploymentId != null)
            {
                config.Globals.DeploymentId = siloArgs.DeploymentId;
            }

            siloHost = new SiloHost(siloArgs.SiloName, config);
            siloHost.LoadOrleansConfig();
        }
开发者ID:osjimenez,项目名称:orleans,代码行数:16,代码来源:OrleansHostWrapper.cs

示例10: InitSilo

 private static void InitSilo(string[] args)
 {
     _host = new SiloHost(Dns.GetHostName())
     {
         ConfigFileName = "OrleansConfiguration.xml"
     };
     _host.LoadOrleansConfig();
     _host.InitializeOrleansSilo();
     if (_host.StartOrleansSilo())
     {
         Console.WriteLine($"Started host {_host.Name} as a {_host.Type} node");
     }
     else
     {
         Console.WriteLine($"Failed to start host {_host.Name}");
     }
 }
开发者ID:malevy,项目名称:dining-orleans,代码行数:17,代码来源:Program.cs

示例11: InitSilo

        private static void InitSilo(String[] args)
        {
            Common.initConsoleLog();

            siloHost = new SiloHost(Dns.GetHostName())
            {
                ConfigFileName = "OrleansConfiguration.xml"
            };

            siloHost.InitializeOrleansSilo();
            if (!siloHost.StartOrleansSilo())
            {
                throw new Exception(
                    $"Failed to start Orleans silo '{siloHost.Name}' " +
                    $"as a {siloHost.Type} node"
                );
            }
        }
开发者ID:LadyLeia,项目名称:exchange2crm,代码行数:18,代码来源:Program.cs

示例12: InitSilo

 private static void InitSilo(string[] args)
 {
     var configFile = Path.Combine(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location) , "OrleansConfiguration.xml"); 
     _host = new SiloHost(Dns.GetHostName())
     {
         ConfigFileName = configFile
     };
     _host.LoadOrleansConfig();
     _host.InitializeOrleansSilo();
     if (_host.StartOrleansSilo())
     {
         Console.WriteLine($"Started host {_host.Name} as a {_host.Type} node");
     }
     else
     {
         Console.WriteLine($"Failed to start host {_host.Name}");
     }
 }
开发者ID:malevy,项目名称:Barker,代码行数:18,代码来源:Program.cs

示例13: Main

        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("请输入配置文件名称:");
                var configName = Console.ReadLine();
                configName = string.IsNullOrEmpty(configName) ? "OrleansConfiguration" : configName;
                var configFile = new FileInfo(
                    Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                    string.Format("{0}.xml", configName)));
                if (!configFile.Exists)
                {
                    Console.WriteLine("配置文件:{0} 不存在", configFile.Name);
                    continue;
                }
                Console.WriteLine("请输入节点名称");
                var nodeName = Console.ReadLine() ?? string.Empty;

                using (var host = new SiloHost(nodeName, configFile))
                {
                    host.LoadOrleansConfig();
                    host.InitializeOrleansSilo();
                    host.StartOrleansSilo();

                    Console.WriteLine("已启动,按下任意键退出");
                    Console.ReadLine();
                    host.StopOrleansSilo();
                }
            }
           
            //AppDomain hostDomain=AppDomain.CreateDomain("OrleansHost",null,new AppDomainSetup()
            //{
            //    AppDomainInitializer =InitSilo
            //});

            //DoSomeClientWork();
            //Console.WriteLine("Orleans Silo is running.\nPress Enter to terminate...");
            //Console.ReadLine();

            //hostDomain.DoCallBack(ShutdownSilo);
        }
开发者ID:feizeikesi,项目名称:Orleans,代码行数:41,代码来源:Program.cs

示例14: SiloConfig_Programatic

        public void SiloConfig_Programatic()
        {
            string siloName = "SiloConfig_Programatic";

            var config = new ClusterConfiguration();
            config.Globals.CacheSize = 11;

            var host = new SiloHost(siloName, config); // Use supplied config data + Initializes logger configurations

            ClusterConfiguration siloConfig = host.Config;

            output.WriteLine(siloConfig.Globals);

            Assert.AreEqual("", siloConfig.SourceFile, "SourceFile should be blank for programmatic config");
            Assert.AreEqual(11, siloConfig.Globals.CacheSize, "CacheSize picked up from config object");
        }
开发者ID:caomw,项目名称:orleans,代码行数:16,代码来源:ConfigTests.cs

示例15: ParseArguments

        private bool ParseArguments(string[] args)
        {
            string deploymentId = null;

            string configFileName = "DevTestServerConfiguration.xml";
            string siloName = Dns.GetHostName(); // Default to machine name

            int argPos = 1;
            for (int i = 0; i < args.Length; i++)
            {
                string a = args[i];
                if (a.StartsWith("-") || a.StartsWith("/"))
                {
                    switch (a.ToLowerInvariant())
                    {
                        case "/?":
                        case "/help":
                        case "-?":
                        case "-help":
                            // Query usage help
                            return false;
                        default:
                            Console.WriteLine("Bad command line arguments supplied: " + a);
                            return false;
                    }
                }
                else if (a.Contains("="))
                {
                    string[] split = a.Split('=');
                    if (String.IsNullOrEmpty(split[1]))
                    {
                        Console.WriteLine("Bad command line arguments supplied: " + a);
                        return false;
                    }
                    switch (split[0].ToLowerInvariant())
                    {
                        case "deploymentid":
                            deploymentId = split[1];
                            break;
                        case "deploymentgroup":
                            // TODO: Remove this at some point in future
                            Console.WriteLine("Ignoring deprecated command line argument: " + a);
                            break;
                        default:
                            Console.WriteLine("Bad command line arguments supplied: " + a);
                            return false;
                    }
                }
                // unqualified arguments below
                else if (argPos == 1)
                {
                    siloName = a;
                    argPos++;
                }
                else if (argPos == 2)
                {
                    configFileName = a;
                    argPos++;
                }
                else
                {
                    // Too many command line arguments
                    Console.WriteLine("Too many command line arguments supplied: " + a);
                    return false;
                }
            }

            siloHost = new SiloHost(siloName);
            siloHost.ConfigFileName = configFileName;
            if (deploymentId != null)
                siloHost.DeploymentId = deploymentId;

            return true;
        }
开发者ID:cingalia,项目名称:Project-Orleans,代码行数:74,代码来源:OrleansHostWrapper.cs


注:本文中的Orleans.Runtime.Host.SiloHost类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。