async Task IMembershipTable.InitializeMembershipTable(bool tryInitTableVersion)
        {
            session = await CassandraSessionFactory.CreateSession(options.ConnectionString);

            queries = await OrleansQueries.CreateInstance(session);

            if (tryInitTableVersion)
            {
                await session.ExecuteAsync(queries.InsertMembershipVersion());
            }
        }
Пример #2
0
        /// <summary>
        /// Creates an instance of a database of type <see cref="RelationalOrleansQueries"/> and Initializes Orleans queries from the database. 
        /// Orleans uses only these queries and the variables therein, nothing more.
        /// </summary>
        /// <param name="storage">the underlying storage instance</param>
        public static async Task<RelationalOrleansQueries> CreateInstance(IRelationalStorage storage)
        {
            //this will probably be the same for all relational dbs
            const string orleansQueriesSelectTemplate = "SELECT QueryKey, QueryText FROM OrleansQuery;";
            var orleansQueries = new OrleansQueries();
            var propertiesDictionary = typeof(OrleansQueries).GetFields().ToDictionary(p => p.Name, p => p);
            var populatedKeys = await storage.ReadAsync(orleansQueriesSelectTemplate, _ => { }, (selector, _) =>
            {
                var queryKey = selector.GetValue<string>("QueryKey");
                var queryText = selector.GetValue<string>("QueryText");
                propertiesDictionary[queryKey].SetValue(orleansQueries, queryText);
                return queryKey;
            }).ConfigureAwait(continueOnCapturedContext: false);

            //Check that all the required keys are loaded and throw an exception giving the keys expected but not loaded.
            var missingQueryKeys = populatedKeys.Except(propertiesDictionary.Keys);
            if (missingQueryKeys.Any())
            {
                throw new ArgumentException(string.Format("Not all required queries found when loading from the database. Missing are: {0}", string.Join(",", missingQueryKeys)));
            }

            return new RelationalOrleansQueries(storage, orleansQueries);
        }
Пример #3
0
        async Task Init(CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(options.ConnctionString))
            {
                throw new BadProviderConfigException($"Connection string not specified for cassandra grain storage '{name}'.");
            }

            foreach (var providerInfo in options.SerializationProviders.Values)
            {
                providerInfo.provider.Init(providerRuntime);
            }

            if (options.SerializationProviders.Count == 1)
            {
                logger.Warn(0, $"No serialization providers have been specified, will use default serialzer " +
                            $"on top of Orleans serialization. This serializer does NOT support versioning. Specify " +
                            $"custom providers using `CassandraGrainStorageOptions.AddSerializationProvider`.");
            }

            session = await CassandraSessionFactory.CreateSession(options.ConnctionString);

            queries = await OrleansQueries.CreateInstance(session);
        }
Пример #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="storage">the underlying relational storage</param>
 /// <param name="orleansQueries">Orleans functional queries</param>
 private RelationalOrleansQueries(IRelationalStorage storage, OrleansQueries orleansQueries)
 {
     this.storage = storage;
     this.orleansQueries = orleansQueries;
 }
Пример #5
0
        async Task IGatewayListProvider.InitializeGatewayListProvider()
        {
            session = await CassandraSessionFactory.CreateSession(options.ConnectionString);

            queries = await OrleansQueries.CreateInstance(session);
        }
Пример #6
0
        public async Task Init()
        {
            session = await CassandraSessionFactory.CreateSession(options.ConnectionString);

            queries = await OrleansQueries.CreateInstance(session);
        }