예제 #1
0
        public static ICrossModuleTransferUtility GetCrossModuleTransferUtility(string srcConfigPath, int srcTenant, string srcModule,
                                                                                string destConfigPath, int destTenant, string destModule)
        {
            var srcConfigSection  = GetSection(srcConfigPath);
            var descConfigSection = GetSection(destConfigPath);

            var srcModuleConfig  = srcConfigSection.Modules.GetModuleElement(srcModule);
            var destModuleConfig = descConfigSection.Modules.GetModuleElement(destModule);

            var srcHandlerConfig  = srcConfigSection.Handlers.GetHandler(srcModuleConfig.Type);
            var destHandlerConfig = descConfigSection.Handlers.GetHandler(destModuleConfig.Type);

            if (!string.Equals(srcModuleConfig.Type, destModuleConfig.Type, StringComparison.OrdinalIgnoreCase))
            {
                throw new InvalidOperationException("Can't instance transfer utility for modules with different storage types");
            }

            if (string.Equals(srcModuleConfig.Type, "disc", StringComparison.OrdinalIgnoreCase))
            {
                return(new DiscCrossModuleTransferUtility(TennantPath.CreatePath(srcTenant.ToString()), srcModuleConfig, srcHandlerConfig.GetProperties(),
                                                          TennantPath.CreatePath(destTenant.ToString()), destModuleConfig, destHandlerConfig.GetProperties()));
            }

            if (string.Equals(srcModuleConfig.Type, "s3", StringComparison.OrdinalIgnoreCase))
            {
                return(new S3CrossModuleTransferUtility(TennantPath.CreatePath(srcTenant.ToString()), srcModuleConfig, srcHandlerConfig.GetProperties(),
                                                        TennantPath.CreatePath(destTenant.ToString()), destModuleConfig, destHandlerConfig.GetProperties()));
            }

            return(null);
        }
예제 #2
0
        public 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 tennant path
            tenant = TennantPath.CreatePath(tenant);

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

            if (store == null)
            {
                var section = StorageFactoryConfig.Section;
                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }

                var settings = SettingsManager.LoadForTenant <StorageSettings>(tenantId);

                store = GetStoreAndCache(tenant, module, StorageSettingsHelper.DataStoreConsumer(settings), controller);
            }
            return(store);
        }
예제 #3
0
        internal static void ClearCache()
        {
            var tenantId = CoreContext.TenantManager.GetCurrentTenant().TenantId.ToString();
            var path     = TennantPath.CreatePath(tenantId);

            foreach (var module in GetModuleList("", true))
            {
                Cache.Publish(DataStoreCacheItem.Create(path, module), CacheNotifyAction.Remove);
            }
        }
예제 #4
0
        public IDataStore GetStorageFromConsumer(string configpath, string tenant, string module, DataStoreConsumer consumer)
        {
            if (tenant == null)
            {
                tenant = DefaultTenantName;
            }

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

            var section = StorageFactoryConfig.Section;

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

            int.TryParse(tenant, out var tenantId);
            return(GetDataStore(tenant, module, consumer, new TennantQuotaController(tenantId, TenantManager)));
        }
예제 #5
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);
        }