Exemplo n.º 1
0
        /// <summary>
        /// Initializes the storage provider.
        /// </summary>
        /// <param name="name">The name of this provider instance.</param>
        /// <param name="providerRuntime">A Orleans runtime object managing all storage providers.</param>
        /// <param name="config">Configuration info for this provider instance.</param>
        /// <returns>Completion promise for this operation.</returns>
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Log = providerRuntime.GetLogger(this.GetType().FullName);

            this.Name = name;

            if (!config.Properties.ContainsKey(DATA_CONNECTION_STRING) ||
                !config.Properties.ContainsKey(DATABASE_NAME_PROPERTY))
            {
                throw new ArgumentException("ConnectionString Or Database property not set");
            }

            this.ConnectionString = config.Properties[DATA_CONNECTION_STRING];
            this.Database         = config.Properties[DATABASE_NAME_PROPERTY];

            this.UseGuidAsStorageKey = !config.Properties.ContainsKey(USE_GUID_AS_STORAGE_KEY) ||
                                       "true".Equals(config.Properties[USE_GUID_AS_STORAGE_KEY],
                                                     StringComparison.OrdinalIgnoreCase);

            DataManager = new GrainStateMongoDataManager(Database, ConnectionString);

            return(TaskDone.Done);
        }
 /// <summary>
 /// Closes the storage provider during silo shutdown.
 /// </summary>
 /// <returns>Completion promise for this operation.</returns>
 public Task Close()
 {
     DataManager = null;
     return TaskDone.Done;
 }
        /// <summary>
        /// Initializes the storage provider.
        /// </summary>
        /// <param name="name">The name of this provider instance.</param>
        /// <param name="providerRuntime">A Orleans runtime object managing all storage providers.</param>
        /// <param name="config">Configuration info for this provider instance.</param>
        /// <returns>Completion promise for this operation.</returns>
        public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config)
        {
            Log = providerRuntime.GetLogger(this.GetType().FullName);

            this.Name = name;

            if (!config.Properties.ContainsKey(DATA_CONNECTION_STRING) ||
                !config.Properties.ContainsKey(DATABASE_NAME_PROPERTY))
            {
                throw new ArgumentException("ConnectionString Or Database property not set");
            }

            this.ConnectionString = config.Properties[DATA_CONNECTION_STRING];
            this.Database = config.Properties[DATABASE_NAME_PROPERTY];

            this.UseGuidAsStorageKey = !config.Properties.ContainsKey(USE_GUID_AS_STORAGE_KEY) ||
                                       "true".Equals(config.Properties[USE_GUID_AS_STORAGE_KEY],
                                           StringComparison.OrdinalIgnoreCase);

            DataManager = new GrainStateMongoDataManager(Database, ConnectionString);

            return TaskDone.Done;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Closes the storage provider during silo shutdown.
 /// </summary>
 /// <returns>Completion promise for this operation.</returns>
 public Task Close()
 {
     DataManager = null;
     return(TaskDone.Done);
 }