Esempio n. 1
0
        public override void Run()
        {
            Trace.WriteLine("OrleansAzureSilos-Run entry point called", "Information");

            Trace.WriteLine("OrleansAzureSilos-OnStart Starting Orleans silo", "Information");

            var config = new ClusterConfiguration();

            config.LoadFromFile("OrleansConfiguration.xml");

            // check if the user forgot to change Orleans.xml before deploying to cloud
            if (!CloudConfigurationManager.GetSetting("DataConnectionString").Contains("UseDevelopmentStorage") &&
                config.Globals
                .ProviderConfigurations[ProviderCategoryConfiguration.STORAGE_PROVIDER_CATEGORY_NAME]
                .Providers["GloballySharedAzureAccount"]
                .Properties["DataConnectionString"]
                .Contains("UseDevelopmentStorage"))
            {
                throw new Exception(
                          "please edit OrleansConfiguration.xml to configure global azure storage account before deploying to cloud");
            }

            // insert the ClusterId based on the cloud configuration
            config.Globals.ClusterId = CloudConfigurationManager.GetSetting("ClusterId");


            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            this.orleansAzureSilo = new AzureSilo();
            bool ok = this.orleansAzureSilo.Start(config);

            Trace.WriteLine("OrleansAzureSilos-OnStart Orleans silo started ok=" + ok, "Information");

            this.orleansAzureSilo.Run(); // Call will block until silo is shutdown
        }
Esempio n. 2
0
        public override void Run()
        {
            Trace.WriteLine("OrleansAzureSilos-Run entry point called", "Information");

            Trace.WriteLine("OrleansAzureSilos-OnStart Starting Orleans silo", "Information");

            var config = AzureSilo.DefaultConfiguration();

            config.AddMemoryStorageProvider();
            config.Defaults.DefaultTraceLevel = Orleans.Runtime.Severity.Verbose;
            //options.ClientConfiguration.DefaultTraceLevel = Orleans.Runtime.Severity.Verbose3;
            //config.Defaults.TraceToConsole = true;

            // First example of how to configure an existing provider
            Example_ConfigureExistingStorageProvider(config);
            Example_ConfigureNewStorageProvider(config);
            Example_ConfigureNewBootstrapProvider(config);

            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            orleansAzureSilo = new AzureSilo();
            bool ok = orleansAzureSilo.Start(config);

            Trace.WriteLine("OrleansAzureSilos-OnStart Orleans silo started ok=" + ok, "Information");

            orleansAzureSilo.Run(); // Call will block until silo is shutdown
        }
Esempio n. 3
0
        public override bool OnStart()
        {
            Trace.WriteLine("Starting Role Entry Point");

            silo = new AzureSilo();

            return(silo.Start());
        }
Esempio n. 4
0
        internal AzureClusterActorSystem(ClusterConfigurator cluster, string deploymentId, string connectionString)
        {
            ClusterActorSystem.Current = this;

            this.cluster          = cluster;
            this.deploymentId     = deploymentId;
            this.connectionString = connectionString;

            host = new AzureSilo();
        }
Esempio n. 5
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            this.cloudSilo = new AzureSilo();
            var success = this.cloudSilo.Start();

            return(success);
        }
Esempio n. 6
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            Trace.WriteLine("Starting Role Entry Point");

            silo = new AzureSilo();

            return(silo.Start(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance));
        }
Esempio n. 7
0
        public override void Run()
        {
            var config = AzureSilo.DefaultConfiguration();

            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            silo = new AzureSilo();
            bool isSiloStarted = silo.Start(config);

            silo.Run(); // Call will block until silo is shutdown
        }
Esempio n. 8
0
        public override void Dispose()
        {
            if (host == null)
            {
                return;
            }

            host.Stop();
            host = null;

            cluster.Dispose();
        }
Esempio n. 9
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            silo = new AzureSilo();

            return(silo.Start(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance));
        }
Esempio n. 10
0
        public override void OnStop()
        {
            Log.Trace();

            if (_silo != null)
            {
                Log.Info("Stopping silo.");
                _silo.Stop();
                Log.Info("Stopped silo.");
                _silo = null;
            }

            base.OnStop();
        }
Esempio n. 11
0
        public override void Run()
        {
            Trace.WriteLine("OrleansAzureSilos-Run entry point called", "Information");

            Trace.WriteLine("OrleansAzureSilos-OnStart Starting Orleans silo", "Information");

            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            orleansAzureSilo = new AzureSilo();
            bool ok = orleansAzureSilo.Start(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance);

            Trace.WriteLine("OrleansAzureSilos-OnStart Orleans silo started ok=" + ok, "Information");

            orleansAzureSilo.Run(); // Call will block until silo is shutdown
        }
Esempio n. 12
0
        private async Task ValidateConfigurationAtStartup(string connectionString)
        {
            var serviceRuntime = new TestServiceRuntimeWrapper
            {
                DeploymentId = "foo"
            };

            serviceRuntime.Settings["DataConnectionString"] = connectionString;
            serviceRuntime.InstanceName = "name";

            var config = AzureSilo.DefaultConfiguration(serviceRuntime);

            AzureSilo orleansAzureSilo = new AzureSilo(serviceRuntime, this.loggerFactory);
            bool      ok = await orleansAzureSilo.ValidateConfiguration(config);

            Assert.True(ok);
        }
Esempio n. 13
0
        public async Task ValidateConfiguration_IncorrectKey()
        {
            var serviceRuntime = new TestServiceRuntimeWrapper();

            serviceRuntime.DeploymentId = "bar";
            serviceRuntime.Settings["DataConnectionString"] = "DefaultEndpointsProtocol=https;AccountName=orleanstest;AccountKey=IncorrectKey";
            serviceRuntime.InstanceName = "name";

            var config = AzureSilo.DefaultConfiguration(serviceRuntime);

            config.AddMemoryStorageProvider();

            AzureSilo orleansAzureSilo = new AzureSilo(serviceRuntime, this.loggerFactory);
            bool      ok = await orleansAzureSilo.ValidateConfiguration(config);

            Assert.False(ok);
        }
Esempio n. 14
0
        public async Task ValidateConfiguration_InvalidConnectionString()
        {
            var serviceRuntime = new TestServiceRuntimeWrapper
            {
                DeploymentId = "bar"
            };

            serviceRuntime.Settings["DataConnectionString"] = "InvalidConnectionString";
            serviceRuntime.InstanceName = "name";

            var config = AzureSilo.DefaultConfiguration(serviceRuntime);

            AzureSilo orleansAzureSilo = new AzureSilo(serviceRuntime, this.loggerFactory);
            bool      ok = await orleansAzureSilo.ValidateConfiguration(config);

            Assert.False(ok);
        }
Esempio n. 15
0
        public async void ValidateConfiguration_InvalidConnectionString()
        {
            var serviceRuntime = new TestServiceRuntimeWrapper();

            serviceRuntime.DeploymentId = "bar";
            serviceRuntime.Settings["DataConnectionString"] = "InvalidConnectionString";
            serviceRuntime.InstanceName = "name";

            var config = AzureSilo.DefaultConfiguration(serviceRuntime);

            config.AddMemoryStorageProvider();

            AzureSilo orleansAzureSilo = new AzureSilo(serviceRuntime);
            bool      ok = await orleansAzureSilo.ValidateConfiguration(config);

            Assert.False(ok);
        }
Esempio n. 16
0
        public async Task ValidateConfiguration_Startup()
        {
            Skip.IfNot(StorageEmulator.TryStart(), "This test explicitly requires the Azure Storage emulator to run");

            var serviceRuntime = new TestServiceRuntimeWrapper();

            serviceRuntime.DeploymentId = "foo";
            serviceRuntime.Settings["DataConnectionString"] = "UseDevelopmentStorage=true";
            serviceRuntime.InstanceName = "name";

            var config = AzureSilo.DefaultConfiguration(serviceRuntime);

            config.AddMemoryStorageProvider();

            AzureSilo orleansAzureSilo = new AzureSilo(serviceRuntime, this.loggerFactory);
            bool      ok = await orleansAzureSilo.ValidateConfiguration(config);

            Assert.True(ok);
        }
Esempio n. 17
0
        /// <summary>
        /// The on start.
        /// </summary>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override bool OnStart()
        {
            // Note that you need to do this :)
            // Note that you need to do this :)
            // Note that you need to do this :)
            // Also check out AzureTableJournalProvider, for actual use.
            JournalProviderManager.Manager.GetProviderDelegate =
                (_, __) => new AzureTableJournalProvider("UseDevelopmentStorage=true", JsonSerializationSettings.JsonConfig);

            this.silo = new AzureSilo();

            var ok = base.OnStart();

            if (ok)
            {
                ok = this.silo.Start();
            }

            return(ok);
        }
Esempio n. 18
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            orleansAzureSilo = new AzureSilo();

            bool result = base.OnStart();

            if (result)
            {
                result = orleansAzureSilo.Start(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance);
            }

            Trace.TraceInformation("FDD.OrleansGPSTracker.OrleansSilo has been started (result={0})", result);

            return(result);
        }
Esempio n. 19
0
        public override bool OnStart()
        {
            Trace.WriteLine("OrleansAzureSilos-OnStart called", "Information");
            Trace.WriteLine("OrleansAzureSilos-OnStart Initializing config", "Information");

            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
            RoleEnvironment.Changing += RoleEnvironmentChanging;
            SetupEnvironmentChangeHandlers();

            var config = AzureSilo.DefaultConfiguration();

            config.AddMemoryStorageProvider();

            // First example of how to configure an existing provider
            Example_ConfigureNewStorageProvider(config);
            Example_ConfigureExistingStorageProvider(config);
            Example_ConfigureNewBootstrapProvider(config);

            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            // Just validate that the configuration is OK (for example, that the storage used in membership is accessible)
            var  silo = new AzureSilo();
            bool ok   = silo.ValidateConfiguration(config).Result;

            Trace.WriteLine("OrleansAzureSilos-OnStart called silo.ValidateConfiguration ok=" + ok, "Information");

            if (ok)
            {
                this.orleansAzureSilo     = silo;
                this.clusterConfiguration = config;

                ok = base.OnStart();
                Trace.WriteLine("OrleansAzureSilos-OnStart called base.OnStart ok=" + ok, "Information");
            }

            return(ok);
        }
Esempio n. 20
0
        public override void Run()
        {
            Trace.WriteLine("OrleansAzureSilos-Run entry point called", "Information");

            Trace.WriteLine("OrleansAzureSilos-OnStart Starting Orleans silo", "Information");

            var config = new ClusterConfiguration();

            config.LoadFromFile("OrleansConfiguration.xml");

            // insert the ClusterId based on the cloud configuration
            config.Globals.ClusterId = CloudConfigurationManager.GetSetting("ClusterId");

            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            this.orleansAzureSilo = new AzureSilo();
            bool ok = this.orleansAzureSilo.Start(config);

            Trace.WriteLine("OrleansAzureSilos-OnStart Orleans silo started ok=" + ok, "Information");

            this.orleansAzureSilo.Run(); // Call will block until silo is shutdown
        }
Esempio n. 21
0
        public override void Run()
        {
            Trace.TraceInformation("OrleansWorker is running");

            try
            {
                var config = new ClusterConfiguration();
                config.StandardLoad();
                ConfigureStorageProvider(config);
                _silo = new AzureSilo();
                var isSiloStarted = _silo.Start(config);
                if (isSiloStarted == false)
                {
                    Trace.TraceError("OrleansWorker.Run() -Error in starting silo");
                }
                _silo.Run();
            }
            finally
            {
                this._manualResetEvent.Set();
            }
        }
Esempio n. 22
0
        public override void Run()
        {
            Log.Trace();

            try {
                var siloConfig = AzureSilo.DefaultConfiguration();

                // Silo timeout is substantially longer than client timeout to allow sync to wait.
                siloConfig.Globals.ResponseTimeout = SiloRequestTimeout;

                // This allows App Services and Cloud Services to agree on a deploymentId.
                siloConfig.Globals.DeploymentId = _config.DeploymentId;

                // Add custom JSON.Net object serialization
                siloConfig.Globals.SerializationProviders.Add(typeof(JsonObjectSerializer).GetTypeInfo());

                // Ensure exceptions can be serialized
                siloConfig.Globals.FallbackSerializationProvider = typeof(ILBasedSerializer).GetTypeInfo();

                // Dependency Injection
                siloConfig.UseStartupType <ShipStartupProvider>();

                siloConfig.AddAzureTableStorageProvider("AzureStore", _config.DataConnectionString);

                // It is IMPORTANT to start the silo not in OnStart but in Run.
                // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
                _silo = new AzureSilo();
                _silo.Start(siloConfig);

                // Block until silo is shutdown
                _silo.Run();
            } catch (Exception e) {
                e.Report("Error while running silo. Aborting.");
            }

            Log.Info("Run loop exiting.");
        }
Esempio n. 23
0
        public override void Run()
        {
            Trace.WriteLine("OrleansAzureSilos-Run entry point called", "Information");

            Trace.WriteLine("OrleansAzureSilos-OnStart Starting Orleans silo", "Information");

            var config = new ClusterConfiguration();

            config.StandardLoad();

            // First example of how to configure an existing provider
            //ConfigureExistingStorageProvider(config);
            //ConfigureNewStorageProvider(config);
            //ConfigureNewBootstrapProvider(config);

            // It is IMPORTANT to start the silo not in OnStart but in Run.
            // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
            orleansAzureSilo = new AzureSilo();
            bool ok = orleansAzureSilo.Start(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance, config);

            Trace.WriteLine("OrleansAzureSilos-OnStart Orleans silo started ok=" + ok, "Information");

            orleansAzureSilo.Run(); // Call will block until silo is shutdown
        }
Esempio n. 24
0
        public override void Run()
        {
            var env = RoleEnvironment.GetConfigurationSettingValue("Environment");

            if (string.IsNullOrEmpty(env))
            {
                throw new InvalidOperationException("Unable to determine environment.");
            }
            var config = ConreignSiloConfiguration.Load(Environment.CurrentDirectory, env);

            config.ClusterId  = RoleEnvironment.DeploymentId;
            config.InstanceId = RoleEnvironment.CurrentRoleInstance.Id;
            var app = ConreignSilo.Create(config);
            var orleansConfiguration = app.CreateOrleansConfiguration();

            _silo = new AzureSilo();
            var started = _silo.Start(orleansConfiguration, app.Configuration.SystemStorageConnectionString);

            if (!started)
            {
                throw new InvalidOperationException("Silo was not started.");
            }
            _silo.Run();
        }
Esempio n. 25
0
        private bool ParseArguments(string[] args)
        {
            string deploymentId = null;

            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;

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

            var config = AzureEnvironment.IsInAzure ? AzureSilo.DefaultConfiguration() : ClusterConfiguration.LocalhostPrimarySilo();

            siloHost = new SiloHost(siloName, config);

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

            return(true);
        }
Esempio n. 26
0
        private void Run(CancellationToken cancellationToken)
        {
            try
            {
                var config = new ClusterConfiguration();
                //config.StandardLoad();

                if (RoleEnvironment.IsEmulated)
                {
                    config.LoadFromFile(@"OrleansLocalConfiguration.xml");
                }
                else
                {
                    config.LoadFromFile(@"OrleansConfiguration.xml");
                }

                var ipAddr = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["OrleansSiloEndPoint"].IPEndpoint.Address.ToString();
                Environment.SetEnvironmentVariable("MyIPAddr", ipAddr);

                var instanceCount = RoleEnvironment.CurrentRoleInstance.Role.Instances.Count;
                Environment.SetEnvironmentVariable("MyInstanceCount", instanceCount.ToString());

                this.instances = instanceCount;

                // TODO: Delete Orleans Tables
                // To avoid double delete, check for existence
                //CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("DataConnectionString"));
                //table = tableClient.GetTableReference("OrleansGrainState");
                //table.DeleteIfExists();
                // Create the table client.
                //CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

                //CloudTable table = tableClient.GetTableReference("OrleansSiloStatistics");
                //table.DeleteIfExists();

                //CloudTable  table = tableClient.GetTableReference("OrleansClientStatistics");
                //table.DeleteIfExists();

                // It is IMPORTANT to start the silo not in OnStart but in Run.
                // Azure may not have the firewalls open yet (on the remote silos) at the OnStart phase.
                orleansAzureSilo = new AzureSilo();
                var ok = orleansAzureSilo.Start(config);

                if (ok)
                {
                    Trace.TraceInformation("OrleansWorkerRole-OnStart Orleans silo started ok=" + ok, "Information");
                    Trace.TraceInformation("OrleansWorkerRole is running");

                    LogAnalysisVariables();

                    orleansAzureSilo.Run();                     // Call will block until silo is shutdown

                    Trace.TraceInformation("OrleansWorkerRole stop running");
                    WriteToTempFile("OrleansWorkerRole stop running");
                    //SaveErrorToBlob("Orleans Silo stops!");
                }
                else
                {
                    Trace.TraceError("Orleans Silo could not start");
                    WriteToTempFile("Orleans Silo could not start");
                    //SaveErrorToBlob("Orleans Silo could not start");
                }
            }
            catch (Exception ex)
            {
                while (ex is AggregateException)
                {
                    ex = ex.InnerException;
                }
                Trace.TraceError("Error during initialization of OrleansWorkerRole {0}", ex.ToString());
                var excString = ex.ToString();
                WriteToTempFile(excString);
                //SaveErrorToBlob(excString);
                throw ex;
            }
        }
 internal AzureClusterActorSystem(ClusterConfigurator cluster)
 {
     ClusterActorSystem.Current = this;
     this.cluster = cluster;
     host         = new AzureSilo();
 }