Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //var config = Orleans.Runtime.Configuration.ClusterConfiguration.LocalhostPrimarySilo();

            var host = new Orleans.Runtime.Host.SiloHost("Default");

            host.LoadOrleansConfig();

            host.InitializeOrleansSilo();
            host.StartOrleansSilo();


            //var config = Orleans.Runtime.Configuration.ClientConfiguration.LocalhostSilo();
            //GrainClient.Initialize(config);

            //var userID = Guid.NewGuid();
            //IHello pub = Orleans.GrainClient.GrainFactory.GetGrain<IHello>(userID);

            while (true)
            {
                var msg = Console.ReadLine();

                if (msg == "quit")
                {
                    break;
                }
                //pub.SendUpdateMessage(msg);
            }

            host.StopOrleansSilo();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            MaximizeWindow();

            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new Orleans.Runtime.Host.SiloHost("TestSilo", siloConfig);

            silo.InitializeOrleansSilo();
            silo.StartOrleansSilo();

            Console.WriteLine("Silo started.");

            // Then configure and connect a client.
            var clientConfig = ClientConfiguration.LocalhostSilo();
            var client       = new ClientBuilder().UseConfiguration(clientConfig).Build();

            client.Connect().Wait();

            Console.WriteLine("Client connected.");

            DoWork(client).Wait();

            Console.WriteLine("\nPress Enter to terminate...");
            Console.ReadLine();

            // Shut down
            client.Close();
            silo.ShutdownOrleansSilo();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var config = new Orleans.Runtime.Configuration.ClusterConfiguration();

            config.LoadFromFile("Host.xml");
            //SiloHost siloHost = new SiloHost(System.Net.Dns.GetHostName());
            //初始化一个silohost,这里使用了Orleans提供的silohost而不是silo,其中silo的名字命名为Ba;
            Orleans.Runtime.Host.SiloHost siloHost = new Orleans.Runtime.Host.SiloHost("Ba", config);
            //初始化仓储
            siloHost.InitializeOrleansSilo();
            //启动
            siloHost.StartOrleansSilo();

            //检查一下
            if (siloHost.IsStarted)
            {
                Console.WriteLine("silohost 启动成功");
            }
            else
            {
                Console.WriteLine("启动失败");
            }
            Console.ReadKey();


            //关闭silo
            siloHost.StopOrleansSilo();
            //未初始化这个silo    (搞不懂啥意思)
            siloHost.UnInitializeOrleansSilo();
            //优雅的关闭这个silo
            siloHost.ShutdownOrleansSilo();
            Console.ReadKey();
        }
Exemplo n.º 4
0
        private static void InitSilo(string[] args)
        {
            var config = new ClusterConfiguration();

            config.LoadFromFile(@".\OrleansHost.xml");
            var host = new Orleans.Runtime.Host.SiloHost(Guid.NewGuid().ToString(), config);

            host.InitializeOrleansSilo();
            host.StartOrleansSilo();
        }
        private static async Task <Orleans.Runtime.Host.SiloHost> StartSilo()
        {
            // define the cluster configuration
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new Orleans.Runtime.Host.SiloHost("Test Silo", siloConfig);

            silo.InitializeOrleansSilo();
            silo.StartOrleansSilo();
            return(silo);
        }
Exemplo n.º 6
0
 static void Main(string[] args)
 {
     using (var host = new Orleans.Runtime.Host.SiloHost("Default"))
     {
         host.LoadOrleansConfig();
         host.InitializeOrleansSilo();
         host.StartOrleansSilo();
         Console.WriteLine("Starting...");
         Console.Read();
         host.StopOrleansSilo();
     }
 }
Exemplo n.º 7
0
        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 Orleans.Runtime.Host.SiloHost(siloArgs.SiloName, config);
            siloHost.LoadOrleansConfig();
        }
Exemplo n.º 8
0
        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 Orleans.Runtime.Host.SiloHost(siloArgs.SiloName, config);
            siloHost.LoadOrleansConfig();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Metric.Config
            .WithHttpEndpoint("http://localhost:1234/server/")
            .WithAllCounters();

            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();

            siloConfig.UseStartupType <Startup>();
            siloConfig.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain;
            siloConfig.Globals.RegisterStorageProvider <MemoryStorage>("nonGuaranteedMessagesStore");
            var silo = new Orleans.Runtime.Host.SiloHost("DataRelaySilo", siloConfig);

            silo.InitializeOrleansSilo();
            silo.Config.Globals.RegisterDashboard();
            silo.StartOrleansSilo();

            Console.WriteLine("Silo started.");
            Console.ReadKey();

            silo.ShutdownOrleansSilo();
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            //获得一个配置实例
            //它需要两个端口,第一个端口2234是用来silo与silo之间的通信的,第二个1234是用于监听client的请求的
            //var config = Orleans.Runtime.Configuration.ClusterConfiguration.LocalhostPrimarySilo(2234, 1234);

            //使用配置文件
            var config = new Orleans.Runtime.Configuration.ClusterConfiguration();

            config.LoadFromFile("host.xml");

            //初始化一个silohost,这里使用了Orleans提供的silohost而不是silo,其中silo的名字命名为Ba;
            Orleans.Runtime.Host.SiloHost silohost = new Orleans.Runtime.Host.SiloHost("Ba", config);

            //silohost.Config.Globals.LivenessType = GlobalConfiguration.LivenessProviderType.Custom;
            //silohost.Config.Globals.MembershipTableAssembly = "OrleansConsulUtils";
            //silohost.Config.Globals.ReminderServiceType = GlobalConfiguration.ReminderServiceProviderType.Disabled;

            silohost.InitializeOrleansSilo();

            silohost.StartOrleansSilo();

            //检查一下
            if (silohost.IsStarted)
            {
                Console.WriteLine("siloHost 启动成功");
            }
            else
            {
                Console.WriteLine("启动失败");
            }

            Console.ReadKey();

            // 关闭,停止
            silohost.StopOrleansSilo();
            silohost.UnInitializeOrleansSilo();
            silohost.ShutdownOrleansSilo();
        }
Exemplo n.º 11
0
        private bool ParseArguments(string[] args)
        {
            string deploymentId = null;

            string configFileName = "DevTestServerConfiguration.xml"; //From Core
            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":      //From Core
                        // 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)  //From Core
                {
                    configFileName = a;
                    argPos++;
                }
                else
                {
                    // Too many command line arguments
                    Console.WriteLine("Too many command line arguments supplied: " + a);
                    return(false);
                }
            }

            //var config = ClusterConfiguration.LocalhostPrimarySilo();
            //config.AddMemoryStorageProvider();
            //siloHost = new SiloHost(siloName, config);

            siloHost = new Orleans.Runtime.Host.SiloHost(siloName);
            siloHost.ConfigFileName = configFileName;

            if (deploymentId != null)
            {
                siloHost.DeploymentId = deploymentId;
            }

            return(true);
        }
Exemplo n.º 12
0
 protected virtual void Dispose(bool dispose)
 {
     siloHost.Dispose();
     siloHost = null;
 }
Exemplo n.º 13
0
        private bool ParseArguments(string[] args)
        {
            string deploymentId = null;

            var siloName = Dns.GetHostName(); // Default to machine name

            var argPos = 1;

            foreach (var arg in args)
            {
                if (arg.StartsWith("-") || arg.StartsWith("/"))
                {
                    switch (arg.ToLowerInvariant())
                    {
                    case "/?":
                    case "/help":
                    case "-?":
                    case "-help":
                        // Query usage help
                        return(false);

                    default:
                        Console.WriteLine("Bad command line arguments supplied: " + arg);
                        return(false);
                    }
                }

                if (arg.Contains("="))
                {
                    var parts = arg.Split('=');
                    if (string.IsNullOrEmpty(parts[1]))
                    {
                        Console.WriteLine("Bad command line arguments supplied: " + arg);
                        return(false);
                    }
                    switch (parts[0].ToLowerInvariant())
                    {
                    case "deploymentid":
                        deploymentId = parts[1];
                        break;

                    default:
                        Console.WriteLine("Bad command line arguments supplied: " + arg);
                        return(false);
                    }
                }

                // unqualified arguments below
                else if (argPos == 1)
                {
                    siloName = arg;
                    argPos++;
                }
                else
                {
                    // Too many command line arguments
                    Console.WriteLine("Too many command line arguments supplied: " + arg);
                    return(false);
                }
            }

            var config = ClusterConfiguration.LocalhostPrimarySilo();

            config.AddMemoryStorageProvider();
            _siloHost = new Orleans.Runtime.Host.SiloHost(siloName, config);

            if (deploymentId != null)
            {
                _siloHost.DeploymentId = deploymentId;
            }

            return(true);
        }
Exemplo n.º 14
0
 public void Dispose()
 {
     _siloHost.Dispose();
     _siloHost = null;
 }