private static void InitSilo( string[] args )
 {
   siloHost = new SiloHost( "Primary" ) {
     ConfigFileName = "DevTestServerConfiguration.xml",
     DeploymentId = "1"
   };
   siloHost.InitializeOrleansSilo();
   var ok = siloHost.StartOrleansSilo();
   if( !ok )
     throw new SystemException( string.Format( "Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type ) );
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            m_SiloHost = new SiloHost(Dns.GetHostName())
            {
                ConfigFileName = "OrleansConfiguration.xml"
            };

            m_SiloHost.InitializeOrleansSilo();
            var startedok = m_SiloHost.StartOrleansSilo();

            if (!startedok)
            {
                throw new SystemException(
                          $"Failed to start Orleans silo '{m_SiloHost.Name}' as a {m_SiloHost.Type} node");
            }

            Console.ReadLine();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var config   = ClusterConfiguration.LocalhostPrimarySilo(2234, 22222);
            var silohost = new SiloHost("Ba", config);

            silohost.InitializeOrleansSilo();
            silohost.StartOrleansSilo();

            if (silohost.IsStarted)
            {
                Console.WriteLine("silohost 启动成功");
            }
            else
            {
                Console.WriteLine("启动失败");
            }
            Console.ReadKey();
        }
Beispiel #4
0
        private static void InitSilo(string[] args)
        {
            var siloName = Dns.GetHostName();

            _siloHost = new SiloHost(siloName)
            {
                ConfigFileName = "OrleansConfiguration.xml",
                Type           = Silo.SiloType.Primary
            };
            _siloHost.InitializeOrleansSilo();

            if (!_siloHost.StartOrleansSilo())
            {
                throw new SystemException(
                          $"Failed to start Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node");
            }
            ;
        }
Beispiel #5
0
        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"
                          );
            }
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new 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.");

            GrainClient.Initialize(ClientConfiguration.LocalhostSilo());
            var grain = GrainClient.GrainFactory.GetGrain <IGIFSGrain>(1);

            //Se define el objeto objRemoto para referenciar el grain de la interfaz IGIFSGrain del SILO
            //IGIFSGrain objRemoto = client.GetGrain<IGIFSGrain>(1);

            //Definimos el DataSet oDS y registramos en el mismo, el DataSet de noticias de la cache, que se
            //obtiene del método "LeerNoticias", declarado en el SILO

            grain.CargarGIFSALaCache().Wait();
            DataSet oDS = grain.LeerGIFSDesdeLaCache().Result;

            Console.WriteLine(oDS.Tables.Count.ToString());

            //
            // This is the place for your test code.
            //

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

            // Shut down
            client.Close();
            silo.ShutdownOrleansSilo();
        }
Beispiel #7
0
        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}");
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            var silo = new SiloHost("Silo");

            silo.ConfigFileName = "SiloConfiguration.xml";

            silo.InitializeOrleansSilo();
            var startSuccessful = silo.StartOrleansSilo();

            if (!startSuccessful)
            {
                throw new SystemException(String.Format("Failed to start Orleans silo '{0}' as a {1} node", silo.Name, silo.Type));
            }

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

            silo.ShutdownOrleansSilo();
        }
        static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new SiloHost("TestSilo", siloConfig);

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

            Console.WriteLine("Silo started.");

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

            clientConfig.SerializationProviders.Add(typeof(Orleans.Serialization.BondSerializer).GetTypeInfo());

            var client = new ClientBuilder().UseConfiguration(clientConfig).Build();

            client.Connect().Wait();

            Console.WriteLine("Client connected.");

            //
            // This is the place for your test code.
            //
            //var xxxx = new ClientConfiguration();
            //xxxx.GatewayProvider = ClientConfiguration.GatewayProviderType.None;
            //xxxx.Gateways.Add(new System.Net.IPEndPoint(IPAddress.Parse("127.0.0.1"), 40000));
            //GrainClient.Initialize(xxxx);

            //var gw = GrainClient.GrainFactory.GetGrain<IGateway>("gw1");
            //var succ = gw.Start().Result;

            //initThrift(gw);


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

            // Shut down
            client.Close();
            silo.ShutdownOrleansSilo();
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            var configFile = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "OrleansConfiguration.xml"));

            Console.Write("输入节点名称:");
            var nodeName = Console.ReadLine() ?? string.Empty;

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

                Console.WriteLine("Press any keys to exit.");
                Console.ReadKey();

                host.StopOrleansSilo();
            }
        }
Beispiel #11
0
        public bool Run()
        {
            bool ok = false;

            try
            {
                siloHost.InitializeOrleansSilo();

                //siloHost.Config.Defaults.DefaultTraceLevel = Runtime.Severity.Verbose3;

                siloHost.Config.Globals
                .RegisterBootstrapProvider <OrleansDashboard.Dashboard>("OrleansDashboard");

                siloHost.Config.AddSimpleMessageStreamProvider("SimpleStreamProvider");

                siloHost.Config.AddMemoryStorageProvider("PubSubStore");



                siloHost.Config.Globals
                .RegisterBootstrapProvider <MetricsTrackerBootstrapProvider>("MetricsTracker");

                ok = siloHost.StartOrleansSilo();

                if (ok)
                {
                    Console.WriteLine(string.Format("Successfully started Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
                else
                {
                    throw new SystemException(string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                var msg = string.Format("{0}:\n{1}\n{2}", exc.GetType().FullName, exc.Message, exc.StackTrace);
                Console.WriteLine(msg);
            }

            return(ok);
        }
Beispiel #12
0
        static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new 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.");

            //
            // This is the place for your test code.
            //
            Console.WriteLine("Step1");
            var grain = client.GetGrain <IStockGrain>("MSFT");

            Console.WriteLine("Step2");
            var price = grain.GetPrice().Result;

            Console.WriteLine("Step3");
            Console.WriteLine("P:" + price.ToString());

            //输出结果:先输出 Step1 step2,过10s过后输出Step3
            //因为StockGrain的OnActivateAsync是异步函数,所有GetGrain会快速返回。
            //StockGrain只有处理完OnActivateAsync函数过后,才会处理GetPrice.

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

            // Shut down
            client.Close();
            silo.ShutdownOrleansSilo();
        }
        static void Main(string[] args)
        {
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();

            siloConfig
            .SimpleMessageStreamProvider(FluentConfig.AltNetStream);
            siloConfig.Defaults.DefaultTraceLevel = Severity.Error;


            var silo = new SiloHost("Alt.NET Demo Silo", siloConfig);

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

            Console.WriteLine("Press Enter to close.");
            Console.ReadLine();

            // shut the silo down after we are done.
            silo.ShutdownOrleansSilo();
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();

            siloConfig.AddMemoryStorageProvider();

            var silo = new SiloHost("TestSilo", siloConfig);

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

            Console.WriteLine("Silo started.");

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

            // Shut down
            silo.ShutdownOrleansSilo();
        }
Beispiel #15
0
        private static void InitSilo(string[] args)
        {
            var siloName = Dns.GetHostName();
            var siloHost = new SiloHost(siloName)
            {
                ConfigFileName = args[0],
                Type           = Silo.SiloType.Primary,
                Verbose        = 0
            };

            siloHost.InitializeOrleansSilo();

            if (!siloHost.StartOrleansSilo())
            {
                throw new SystemException(
                          $"Failed to start Orleans silo '{siloHost.Name}' as a {siloHost.Type} node");
            }

            AppDomain.CurrentDomain.SetData("siloHost", siloHost);
        }
Beispiel #16
0
        public static IClusterClient InitializeLocalSiloAndClient()
        {
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();

            siloConfig.Defaults.DefaultTraceLevel = Severity.Warning;
            var silo = new SiloHost("Test Silo", siloConfig);

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

            Console.WriteLine("Silo started.");

            var clientConfig = ClientConfiguration.LocalhostSilo();
            var client       = new ClientBuilder().UseConfiguration(clientConfig).Build();

            client.Connect().Wait();

            Console.WriteLine("Client connected.");
            return(client);
        }
    private static void Main(string[] args)
    {
        // Todo: This configuration should not be called from the config file

        try
        {
            var config = ClusterConfiguration.LocalhostPrimarySilo();
            config.LoadFromFile(@".\OrleansConfiguration.xml");

            using (var silo = new SiloHost("primary", config))
            {
                // Init Mongo Membership
                silo.Config.Globals.LivenessType            = GlobalConfiguration.LivenessProviderType.Custom;
                silo.Config.Globals.MembershipTableAssembly = "Orleans.Providers.MongoDB";

                //Enable Reminder Service
                silo.Config.Globals.ReminderServiceType     = GlobalConfiguration.ReminderServiceProviderType.Custom;
                silo.Config.Globals.ReminderTableAssembly   = "Orleans.Providers.MongoDB";
                silo.Config.Defaults.StatisticsProviderName = "MongoStatisticsPublisher";

                //silo.Config.Defaults = "Orleans.Providers.MongoDB.Statistics.Repository.MongoStatisticsPublisherRepository";
                silo.InitializeOrleansSilo();

                var result = silo.StartOrleansSilo();
                if (result)
                {
                    Console.WriteLine("silo running");
                    Console.ReadKey();
                    return;
                }

                Console.WriteLine("could not start silo");
                Console.ReadKey();
            }
        }
        catch (Exception ex)
        {
            string a = "";
            throw;
        }
    }
        static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new 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.");

            int numberOfGrains = 200;

            var tasks = new Task[numberOfGrains];

            for (int i = 0; i < numberOfGrains; i++)
            {
                var           friend = client.GetGrain <IGrain1>(i);
                Task <string> task   = friend.SayHello();
                var           taskId = i;
                task.ContinueWith(helloTask => { Console.WriteLine($"{taskId}: {helloTask.Result}"); });
                tasks[i] = task;
            }

            Task.WaitAll(tasks);

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

            // Shut down
            client.Close();
            silo.ShutdownOrleansSilo();
        }
Beispiel #19
0
        static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new SiloHost("TestSilo", siloConfig);

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

            Console.WriteLine("Silo started.");

            //
            // This is the place for your test code.
            //

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

            // Shut down
            silo.ShutdownOrleansSilo();
        }
Beispiel #20
0
        public static void StartAzureTableSilo(int index, string clusterId)
        {
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo(11110 + index, 29999 + index);

            siloConfig.Globals.LivenessType         = GlobalConfiguration.LivenessProviderType.AzureTable;
            siloConfig.Globals.ReminderServiceType  = GlobalConfiguration.ReminderServiceProviderType.AzureTable;
            siloConfig.Globals.DataConnectionString = connectionString;
            siloConfig.Globals.DeploymentId         = clusterId;
            siloConfig.AddAzureTableStorageProvider("Storage", connectionString);
            if (index == 1)
            {
                siloConfig.Globals.RegisterDashboard();
            }
            siloConfig.Defaults.DefaultTraceLevel = Severity.Warning;
            var silo = new SiloHost("Test Silo", siloConfig);

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

            Console.WriteLine($"Silo {index} started.");
        }
Beispiel #21
0
    static void InitSilo(string[] args)
    {
        siloHost = new SiloHost(Dns.GetHostName())
        {
            // The Cluster config is quirky and weird to configure in code
            // so we're going to use a config file
            ConfigFileName = "OrleansConfiguration.xml",
        };

        siloHost.InitializeOrleansSilo();

        //siloHost.NodeConfig.TraceToConsole = false;
        //siloHost.NodeConfig.DefaultTraceLevel = Orleans.Runtime.Severity.Error;

        bool startedok = siloHost.StartOrleansSilo();

        if (!startedok)
        {
            throw new SystemException(
                      $"Failed to start Orleans silo '{siloHost.Name}' as a {siloHost.Type} node");
        }
    }
Beispiel #22
0
        public static void Main(string[] args)
        {
            var configFile = "DramaHost.xml";

            if (args.Length >= 1)
            {
                configFile = args[0];
            }

            var clusterConfig = new ClusterConfiguration();

            clusterConfig.LoadFromFile(configFile);

            var siloConfig = clusterConfig.Defaults;

            siloConfig.DefaultTraceLevel = Severity.Info;
            siloConfig.TraceToConsole    = true;
            siloConfig.TraceFilePattern  = "none";

            using (var siloHost = new SiloHost(Dns.GetHostName(), clusterConfig))
            {
                siloHost.InitializeOrleansSilo();
                if (!siloHost.StartOrleansSilo())
                {
                    Console.WriteLine($"failed to start orleans silo {siloHost.Name} as a {siloHost.Type} node");
                    return;
                }

                Console.WriteLine("press enter to close");
                Console.ReadLine();
            }

            // the debugger will kill the host and gateway as soon as either one terminates, so this lets us wait for a clean shutdown
            if (Debugger.IsAttached)
            {
                Console.WriteLine("running with attached debugger; press enter to quit");
                Console.ReadLine();
            }
        }
    private static void InitSilo( string[] args )
    {
      // this is a hack to replace the local azure storage emulator for a real storage account
      // which is stored in an environment variable in travis ci
      const string SILO_SETTINGS_FILE = "DevTestServerConfiguration.xml";
      string connectionString = null;
      if (null != (connectionString = Environment.GetEnvironmentVariable("DataConnectionString")))
      {
        Console.WriteLine("rewritten DataConnectinString variable");
        var settings = File.ReadAllText(SILO_SETTINGS_FILE).Replace("UseDevelopmentStorage=true", connectionString);
        File.WriteAllText(SILO_SETTINGS_FILE, settings);
      }

      siloHost = new SiloHost( "Primary" ) {
        ConfigFileName = SILO_SETTINGS_FILE,
        DeploymentId = "1"
      };
      siloHost.InitializeOrleansSilo();
      var ok = siloHost.StartOrleansSilo();
      if( !ok )
        throw new SystemException( string.Format( "Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type ) );
    }
Beispiel #24
0
        static void Main(string[] args)
        {
            //CONFIGURACIÓN SILO (cluster) LOCAL
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo();
            var silo       = new SiloHost("TestSilo", siloConfig);

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

            Console.WriteLine("SILO INICIADO EXITÓSAMENTE.");

            //CONFIGURACIÓN CLIENTE
            var clientConfig = ClientConfiguration.LocalhostSilo();
            var client       = new ClientBuilder().UseConfiguration(clientConfig).Build();

            client.Connect().Wait();

            Console.WriteLine("CLIENTE CONECTADO EXITÓSAMENTE");

            //LLAMADA DEL GRANO (actor) INICIAL, este no se usa para la distribución per se
            var principal = client.GetGrain <MergeInterface.IMergeSort>(Guid.NewGuid());
            var resultado = ReadFileYeah(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "oraciones.txt")).ToList();

            //CÁLCULO BÁSICO DE DISTRIBUCIÓN (el primer parámetro es arbitrario)
            var identificadores = distribucion(100, client, resultado);

            //LLAMADA CENTRAL DE MERGE SORT
            var yeah = MergeSort(client, identificadores, identificadores.Count, principal, resultado, 1, resultado.Count);

            WriteFileYeah(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, "oraciones.txt"), yeah);

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

            // Shut down
            client.Close();
            silo.ShutdownOrleansSilo();
        }
Beispiel #25
0
        public bool Run()
        {
            bool ok = false;

            try
            {
                siloHost.InitializeOrleansSilo();

                ok = siloHost.StartOrleansSilo();
                if (!ok)
                {
                    throw new SystemException(string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                var msg = string.Format("{0}:\n{1}\n{2}", exc.GetType().FullName, exc.Message, exc.StackTrace);
                Console.WriteLine(msg);
            }

            return(ok);
        }
Beispiel #26
0
        static void Main(string[] args)
        {
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo(2233, 1234);
            var silo       = new SiloHost("TestSilo", siloConfig);

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

            //检查一下
            if (silo.IsStarted)
            {
                Console.WriteLine("silohost 启动成功");
            }
            else
            {
                Console.WriteLine("启动失败");
            }
            Console.WriteLine("\n按回车键结束...");
            Console.ReadLine();

            // Shut down
            silo.ShutdownOrleansSilo();
        }
Beispiel #27
0
        private static void Main(string[] args)
        {
            // First, configure and start a local silo
            var siloConfig = ClusterConfiguration.LocalhostPrimarySilo(22222, 40000);
            var silo       = new SiloHost("TestSilo", siloConfig);

            //silo.ConfigFileName = "SiloHostConfiguration.xml";
            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.");

            //
            // This is the place for your test code.
            //

            //GrainClient.Initialize(clientConfig);
            //var friend = GrainClient.GrainFactory.GetGrain<IHello>(Guid.NewGuid());
            //var result = friend.SayHello("Goodbye").Result;
            //Console.WriteLine(result);



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

            // Shut down
            //client.Close();
            silo.ShutdownOrleansSilo();
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            //获得一个配置实例
            //他需要两个端口,第一个端口2334是用来silo与silo之间的通信的,第二个1234是用于监听client的请求的
            var config = Orleans.Runtime.Configuration.ClusterConfiguration.LocalhostPrimarySilo(2234, 1234);
            //初始化一个silohost,这里使用了Orleans提供的silohost而不是silo,其中silo的名字命名为Ba;
            SiloHost siloHost = new SiloHost("Ba", config);

            //初始化仓储
            siloHost.InitializeOrleansSilo();
            //启动
            siloHost.StartOrleansSilo();

            //检查一下
            if (siloHost.IsStarted)
            {
                Console.WriteLine("silohost 启动成功");
            }
            else
            {
                Console.WriteLine("启动失败");
            }
            Console.ReadKey();
        }
Beispiel #29
0
        public bool Start()
        {
            Console.WriteLine("Starting SiloHost...");

            var config = new ClusterConfiguration();

            config.LoadFromFile(_configPath);

            _siloHost = new SiloHost(_siloName, config);

            try
            {
                // if we run not DEV env, we need special initialization for Consul
                if (_siloHost.Config.Globals.LivenessType != GlobalConfiguration.LivenessProviderType.MembershipTableGrain)
                {
                    _siloHost.Config.Globals.LivenessType            = GlobalConfiguration.LivenessProviderType.Custom;
                    _siloHost.Config.Globals.MembershipTableAssembly = "OrleansConsulUtils";
                    _siloHost.Config.Globals.ReminderServiceType     = GlobalConfiguration.ReminderServiceProviderType.Disabled;
                }
                _siloHost.InitializeOrleansSilo();
                var ok = _siloHost.StartOrleansSilo();

                Console.WriteLine(ok
                    ? $"Successfully started Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node."
                    : $"Failed to start Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node.");

                return(ok);
            }
            catch (Exception exc)
            {
                _siloHost.ReportStartupError(exc);
                var msg = $"{exc.GetType().FullName}:\n{exc.Message}\n{exc.StackTrace}";
                Console.WriteLine(msg);
                return(false);
            }
        }
Beispiel #30
0
        static void Main(string[] args)
        {
            Console.Title = "Silo";
            try
            {
                using (var siloHost = new SiloHost(Console.Title))
                {
                    siloHost.LoadOrleansConfig();
                    siloHost.InitializeOrleansSilo();
                    var startedOk = siloHost.StartOrleansSilo();
                    Console.WriteLine("Silo started successfully");

                    Console.WriteLine("Press enter to exit...");
                    Console.ReadLine();
                    siloHost.ShutdownOrleansSilo();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            Console.ReadLine();
        }
Beispiel #31
0
 internal void Start()
 {
     host.LoadOrleansConfig();
     host.InitializeOrleansSilo();
     host.StartOrleansSilo();
 }
Beispiel #32
0
        static int Main(string[] args)
        {
            string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
            var    builder     = new ConfigurationBuilder()
                                 .SetBasePath(Directory.GetCurrentDirectory())
                                 .AddInMemoryCollection(new Dictionary <string, string> // add default settings, that will be overridden by commandline
            {
                { "Id", "OrleansHost" },
                { "Version", "1.0.0" },
                { "DeploymentId", "testdeploymentid" },
            })
                                 .AddCommandLine(args)
                                 .AddJsonFile($"appconfig.json", optional: true)
                                 .AddJsonFile($"appconfig.{environment}.json", optional: true)
                                 .AddEnvironmentVariables("ASPNETCORE_"); // The CloudService will pass settings (such as) the connectionstring through environment variables

            if ("Development".Equals(environment) && builder.GetFileProvider().GetFileInfo("OrleansHost.csproj").Exists)
            {
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets <Program>();
            }

            var config = builder.Build();

            loggerFactory.AddConsole(config.GetSection("Logging"));
            loggerFactory.AddDebug();
            var logger = loggerFactory.CreateLogger <Program>();

            ClusterConfiguration clusterConfig = ClusterConfiguration.LocalhostPrimarySilo();

            clusterConfig.Globals.DeploymentId         = config["Id"];
            clusterConfig.Globals.DataConnectionString = config.GetConnectionString("DataConnectionString");
            clusterConfig.AddMemoryStorageProvider("Default");
            clusterConfig.AddMemoryStorageProvider("PubSubStore");
            clusterConfig.AddSimpleMessageStreamProvider("Default");
            clusterConfig.Defaults.DefaultTraceLevel = Orleans.Runtime.Severity.Warning;
            clusterConfig.Defaults.TraceFileName     = "";
            clusterConfig.UseStartupType <Startup>();

            var siloHost = new SiloHost(config["Id"], clusterConfig);

            try
            {
                siloHost.InitializeOrleansSilo();
                bool ok = siloHost.StartOrleansSilo(catchExceptions: false);

                if (!ok)
                {
                    logger.LogError(string.Format($"Failed to start Orleans silo '{siloHost.Name}' as a {siloHost.Type} node."));
                    return(1);
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                return(2);
            }

            Console.WriteLine("OrleansHost is running. Press [Ctrl]-C to stop...");
            siloHost.WaitForOrleansSiloShutdown();
            // logger.LogInformation(string.Format($"Orleans silo '{siloHost.Name}' shutdown. Press [Enter]"));
            // Console.ReadLine();
            return(0);
        }