Beispiel #1
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
        }
Beispiel #2
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
        }
Beispiel #3
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);
        }
        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);
        }
        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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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.");
        }
Beispiel #10
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);
        }