Esempio n. 1
0
        public async Task InitializeMembershipTable(GlobalConfiguration config, bool tryInitTableVersion, TraceLogger traceLogger)
        {
            logger = traceLogger;
            deploymentId = config.DeploymentId;

            if (logger.IsVerbose3) logger.Verbose3("SqlMembershipTable.InitializeMembershipTable called.");

            database = RelationalStorageUtilities.CreateGenericStorageInstance(config.AdoInvariant, config.DataConnectionString);

            //This initializes all of Orleans operational queries from the database using a well known view
            //and assumes the database with appropriate defintions exists already.
            queryConstants = await database.InitializeOrleansQueriesAsync();

            // even if I am not the one who created the table, 
            // try to insert an initial table version if it is not already there,
            // so we always have a first table version row, before this silo starts working.
            if(tryInitTableVersion)
            {
                var wasCreated = await InitTableAsync();
                if(wasCreated)
                {
                    logger.Info("Created new table version row.");
                }
            }
        }
Esempio n. 2
0
 public async Task Init(GlobalConfiguration config, TraceLogger logger)
 {
     serviceId = config.ServiceId.ToString();
     deploymentId = config.DeploymentId;
     database = RelationalStorageUtilities.CreateGenericStorageInstance(config.AdoInvariantForReminders,
         config.DataConnectionStringForReminders);
     queryConstants = await database.InitializeOrleansQueriesAsync();
 }
        public async Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Name = name;
            logger = providerRuntime.GetLogger("SqlStatisticsPublisher");

            string adoInvariant = AdoNetInvariants.InvariantNameSqlServer;
            if (config.Properties.ContainsKey("AdoInvariant"))
                adoInvariant = config.Properties["AdoInvariant"];

            database = RelationalStorageUtilities.CreateGenericStorageInstance(adoInvariant, config.Properties["ConnectionString"]);

            queryConstants = await database.InitializeOrleansQueriesAsync(); 
        }
Esempio n. 4
0
        public async Task InitializeGatewayListProvider(ClientConfiguration config, TraceLogger traceLogger)
        {
            logger = traceLogger;
            if (logger.IsVerbose3) logger.Verbose3("SqlMembershipTable.InitializeGatewayListProvider called.");

            deploymentId = config.DeploymentId;            
            maxStaleness = config.GatewayListRefreshPeriod;
            database = RelationalStorageUtilities.CreateGenericStorageInstance(config.AdoInvariant, config.DataConnectionString);

            //This initializes all of Orleans operational queries from the database using a well known view
            //and assumes the database with appropriate defintions exists already.
            queryConstants = await database.InitializeOrleansQueriesAsync();
        }
 async Task IClientMetricsDataPublisher.Init(ClientConfiguration config, IPAddress address, string clientId)
 {          
     database = RelationalStorageUtilities.CreateGenericStorageInstance(config.AdoInvariant, config.DataConnectionString);
     
     queryConstants = await database.InitializeOrleansQueriesAsync();
 }
        public static QueryConstantsBag CreateTestManagementQueries(string invariantName)
        {            
            //This is probably the same for all the databases.
            const string DeleteAllDataTemplate =
                @"DELETE OrleansStatisticsTable;
                    DELETE OrleansClientMetricsTable;
                    DELETE OrleansSiloMetricsTable;
                    DELETE OrleansRemindersTable;
                    DELETE OrleansMembershipTable;
                    DELETE OrleansMembershipVersionTable;";
                                        
            var queryBag = new QueryConstantsBag();
            queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.DeleteAllDataKey, DeleteAllDataTemplate);                        
            switch(invariantName)
            {
                case(AdoNetInvariants.InvariantNameSqlServer):
                {
                    return CreateSqlServerQueries();
                }
                default:
                {
                    break;
                }
            }

            return queryBag;
        }
 private static QueryConstantsBag CreateSqlServerQueries()
 {
     var queryBag = new QueryConstantsBag();
                 
     queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.DefaultConnectionStringKey, @"Data Source=(localdb)\MSSQLLocalDB;Database=Master;Integrated Security=True;Asynchronous Processing=True;Max Pool Size=200; MultipleActiveResultSets=True");            
     queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.ExistsDatabaseKey, "SELECT CAST(COUNT(1) AS BIT) FROM sys.databases WHERE name = @databaseName");
     queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.CreateDatabaseKey,
         @"USE [Master];
         DECLARE @fileName AS NVARCHAR(255) = CONVERT(NVARCHAR(255), SERVERPROPERTY('instancedefaultdatapath')) + N'{0}';
         EXEC('CREATE DATABASE [{0}] ON PRIMARY 
         (
             NAME = [{0}], 
             FILENAME =''' + @fileName + ''', 
             SIZE = 5MB, 
             MAXSIZE = 100MB, 
             FILEGROWTH = 5MB
         )')");
     queryBag.AddOrModifyQueryConstant(AdoNetInvariants.InvariantNameSqlServer, RelationalTestingConstants.DropDatabaseKey, @"USE [Master]; ALTER DATABASE [{0}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; DROP DATABASE [{0}];");
     
     return queryBag;
 }