Esempio n. 1
0
        public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            var tenantId = -2;

            if (string.IsNullOrEmpty(tenant))
            {
                tenant = DefaultTenantName;
            }
            else
            {
                tenantId = Convert.ToInt32(tenant);
            }

            //Make tenant path
            tenant = TenantPath.CreatePath(tenant);

            var store = DataStoreCache.Get(tenant, module);

            if (store == null)
            {
                var section = GetSection(configpath);
                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }

                var settings = StorageSettings.LoadForTenant(tenantId);

                store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller);
            }
            return(store);
        }
Esempio n. 2
0
        private static IDataStore GetStoreAndCache(string tenant, string module, StorageConfigurationSection section, DataStoreConsumer consumer, IQuotaController controller)
        {
            var store = GetDataStore(tenant, module, section, consumer, controller);

            if (store != null)
            {
                DataStoreCache.Put(store, tenant, module);
            }
            return(store);
        }
Esempio n. 3
0
        private IDataStore GetStoreAndCache(string tenant, string module, DataStoreConsumer consumer, IQuotaController controller)
        {
            var store = GetDataStore(tenant, module, consumer, controller);

            if (store != null)
            {
                DataStoreCache.Put(store, tenant, module);
            }
            return(store);
        }
Esempio n. 4
0
        public void Subscribe()
        {
            if (Subscribed)
            {
                return;
            }

            lock (locker)
            {
                if (Subscribed)
                {
                    return;
                }

                Subscribed = true;
                Cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove);
            }
        }
Esempio n. 5
0
        public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            var tenantId = -2;

            if (string.IsNullOrEmpty(tenant))
            {
                tenant = DefaultTenantName;
            }
            else
            {
                tenantId = Convert.ToInt32(tenant);
            }

            //Make tenant path
            tenant = TenantPath.CreatePath(tenant);

            var store = DataStoreCache.Get(tenant, module);

            if (store == null)
            {
                var sectionKey = "StorageConfigurationSection" + (configpath ?? "").Replace("\\", "").Replace("/", "");
                var section    = AscCache.Memory.Get <StorageConfigurationSection>(sectionKey);

                if (section == null)
                {
                    section = GetSection(configpath);
                    AscCache.Memory.Insert(sectionKey, section, DateTime.MaxValue);
                }

                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }

                var settings = StorageSettings.LoadForTenant(tenantId);

                store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller);
            }
            return(store);
        }
Esempio n. 6
0
        public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            if (tenant == null)
            {
                tenant = DefaultTenantName;
            }

            //Make tennant path
            tenant = TennantPath.CreatePath(tenant);

            var store = DataStoreCache.Get(tenant, module);

            if (store == null)
            {
                var section = GetSection(configpath);
                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }
                store = GetStoreAndCache(tenant, module, section, controller);
            }
            return(store);
        }
Esempio n. 7
0
 static StorageFactory()
 {
     Cache = AscCache.Notify;
     Cache.Subscribe <DataStoreCacheItem>((r, act) => DataStoreCache.Remove(r.TenantId, r.Module));
 }
Esempio n. 8
0
 public StorageFactoryListener(ICacheNotify <DataStoreCacheItem> cache)
 {
     cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove);
 }
 static StorageFactory()
 {
     Cache = new KafkaCache <DataStoreCacheItem>();
     Cache.Subscribe((r) => DataStoreCache.Remove(r.TenantId, r.Module), CacheNotifyAction.Remove);
     Section = new Lazy <Configuration.Storage>(() => CommonServiceProvider.GetService <Configuration.Storage>(), true);
 }