private static void UpdateMountPoint(StorageConfiguration storageConfiguration, Client.ServerWide.Operations.MountPointUsage mountPointUsage, string databaseName, DrivesUsage drivesUsage) { var mountPoint = mountPointUsage.DiskSpaceResult.DriveName; var usage = drivesUsage.Items.FirstOrDefault(x => x.MountPoint == mountPoint); if (usage == null) { usage = new MountPointUsage { MountPoint = mountPoint, }; drivesUsage.Items.Add(usage); } usage.VolumeLabel = mountPointUsage.DiskSpaceResult.VolumeLabel; usage.FreeSpace = mountPointUsage.DiskSpaceResult.TotalFreeSpaceInBytes; usage.TotalCapacity = mountPointUsage.DiskSpaceResult.TotalSizeInBytes; usage.IsLowSpace = StorageSpaceMonitor.IsLowSpace(new Size(usage.FreeSpace, SizeUnit.Bytes), new Size(usage.TotalCapacity, SizeUnit.Bytes), storageConfiguration, out string _); var existingDatabaseUsage = usage.Items.FirstOrDefault(x => x.Database == databaseName); if (existingDatabaseUsage == null) { existingDatabaseUsage = new DatabaseDiskUsage { Database = databaseName }; usage.Items.Add(existingDatabaseUsage); } existingDatabaseUsage.Size += mountPointUsage.UsedSpace; existingDatabaseUsage.TempBuffersSize += mountPointUsage.UsedSpaceByTempBuffers; }
/// <summary> /// Provides registration dependencies for Sea Battle application. /// </summary> public static IServiceCollection AddSeaBattleApplication(this IServiceCollection services, IConfiguration configuration) { services .AddSingleton <IValidationService, ValidationService>() .AddSingleton <IModelValidator, BoardCreationModelValidator>() .AddSingleton <IModelValidator, ShipsCreationModelValidator>() .AddSingleton <IModelValidator, ShotModelValidator>() .AddSingleton <IModelsMapper, ModelsMapper>(); services .AddScoped <ISeeBattleGameService, SeaBattleGameService>() .AddSingleton <ICoordinatesParser, CoordinatesParser>(); StorageConfiguration useMemoryStorage = configuration .GetSection(nameof(StorageConfiguration)) .Get <StorageConfiguration>(); if (useMemoryStorage?.UseMemoryStorage ?? false) { services.AddMemoryDataAccess(); } else { services.AddPostgreDataAccess(); } services .Decorate <ISeeBattleGameService, SeaBattleGameValidationService>(); return(services); }
public static CmsBuilder ConfigureCosmosDB(this CmsBuilder builder, Func <StorageConfiguration> storageConfigFunc) { var Configuration = builder.Configuration; var services = builder.Services; services.Configure <CosmosConfig>(Configuration.GetSection(nameof(CosmosConfig))); StorageConfiguration storageConfig = storageConfigFunc(); services.AddTransient <CosmosService>(); if (storageConfig.ReadCmsItems) { services.AddTransient <IReadCmsItem, CosmosWrapperService>(); } if (storageConfig.WriteCmsItems) { services.AddTransient <IWriteCmsItem, CosmosWrapperService>(); } var cosmosConfig = new CosmosConfig(); Configuration.GetSection(nameof(CosmosConfig)).Bind(cosmosConfig); var cosmosConfigOptions = Options.Create <CosmosConfig>(cosmosConfig); var cosmosService = new CosmosService(cosmosConfigOptions, Options.Create(new CmsConfiguration())); cosmosService.InitializeContainer(); return(builder); }
protected TestMappingConfiguration() { ProviderCollection <StorageProviderDefinition> storageProviderDefinitionCollection = StorageProviderDefinitionObjectMother.CreateTestDomainStorageProviders(); _storageConfiguration = new StorageConfiguration( storageProviderDefinitionCollection, storageProviderDefinitionCollection[MappingReflectionTestBase.DefaultStorageProviderID]); _storageConfiguration.StorageGroups.Add(new StorageGroupElement(new TestDomainAttribute(), MappingReflectionTestBase.c_testDomainProviderID)); _storageConfiguration.StorageGroups.Add( new StorageGroupElement(new StorageProviderStubAttribute(), MappingReflectionTestBase.c_unitTestStorageProviderStubID)); _storageConfiguration.StorageGroups.Add( new StorageGroupElement(new TableInheritanceTestDomainAttribute(), TableInheritanceMappingTest.TableInheritanceTestDomainProviderID)); _mappingLoaderConfiguration = new MappingLoaderConfiguration(); _queryConfiguration = new QueryConfiguration("QueriesForStandardMapping.xml"); DomainObjectsConfiguration.SetCurrent( new FakeDomainObjectsConfiguration(_mappingLoaderConfiguration, _storageConfiguration, _queryConfiguration)); var typeDiscoveryService = GetTypeDiscoveryService(); _mappingConfiguration = new MappingConfiguration( MappingReflectorObjectMother.CreateMappingReflector(typeDiscoveryService), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))); MappingConfiguration.SetCurrent(_mappingConfiguration); _domainObjectIDs = new DomainObjectIDs(); }
protected void RegenerateFileMetadata() { //_metadataPersister.CreateCollection("FileMetadata"); //ITransaction regenTransaction = _metadataPersister.BeginTransaction(null, false); //ITransaction iterationTransaction = _MetadataPersistner.Provider.BeginTransaction(null, true); IDataReader <string, byte[]> dataReader = _metadataPersister.GetAllDocuments <string, byte[]>("FileMetadata"); while (dataReader.MoveNext()) { KeyValuePair <string, byte[]> kvp = dataReader.Current(); //inMemory StoreKeyMetadata FileMetadata <long, byte[]> fileMetadata = (FileMetadata <long, byte[]>)CompactBinaryFormatter.FromByteBuffer(kvp.Value, ""); fileMetadata.Provider = ProviderFactory.CreateProvider(fileMetadata.ProviderType); StorageConfiguration clone = (StorageConfiguration)_userConfig.Clone(); clone.StorageProvider.DatabaseId = fileMetadata.DatabaseId; clone.StorageProvider.DatabasePath = _userConfig.StorageProvider.DatabasePath + _userConfig.StorageProvider.DatabaseId; clone.StorageProvider.DatabasePath += "\\"; //clone.StorageProvider.DatabasePath = fileMetadata.FilePath; fileMetadata.Provider.Initialize(clone); _dbIndex++; _fileMetadataDictionary[kvp.Key] = fileMetadata; } dataReader.Dispose(); //_metadataPersister.Commit(regenTransaction); }
StorageConfiguration GetStorageConfiguration() { var files = _driveInfo.RootDirectory.GetFiles("conf.papa"); if (files.Length > 0) { var jsonConf = File.ReadAllText(files[0].FullName); var st = jsonConf.Deserialize <StorageConfiguration>(); st.SetDriveInfo(_driveInfo); return(st); } else { var st = new StorageConfiguration(_driveInfo); if (Directory.Exists(Path.Combine(_driveInfo.RootDirectory.FullName, "MUSIC"))) { st.MusicDirectory = "MUSIC"; st.PlaylistDirectory = "MUSIC"; st.Name = "NW-AXX WALKMAN"; } else { st.Name = "GENERIC USB STORAGE"; } st.Save(); return(st); } }
internal static bool IsLowSpace(Size totalFreeSpace, Size diskSpace, StorageConfiguration config, out string reason, bool simulateLowDiskSpace = false) { if (config.FreeSpaceAlertThresholdInMb != null && totalFreeSpace < config.FreeSpaceAlertThresholdInMb.Value) { reason = $"has {totalFreeSpace} of free space which is below the configured threshold ({config.FreeSpaceAlertThresholdInMb.Value})"; return(true); } var availableInPercentages = totalFreeSpace.GetValue(SizeUnit.Bytes) * 100f / diskSpace.GetValue(SizeUnit.Bytes); if (config.FreeSpaceAlertThresholdInPercentages != null && availableInPercentages < config.FreeSpaceAlertThresholdInPercentages.Value) { reason = $"has {availableInPercentages:#.#}% of free space which is below the configured threshold ({config.FreeSpaceAlertThresholdInPercentages}%). " + $"Total free space: {totalFreeSpace}"; return(true); } if (simulateLowDiskSpace) { reason = "low disk space simulation"; return(true); } reason = null; return(false); }
public static void AddApiAuthentication(this IServiceCollection services, StorageConfiguration storageConfiguration) { services.AddAuthentication(options => { options.DefaultScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultAuthenticateScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; options.DefaultForbidScheme = IdentityServerAuthenticationDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.BackchannelHttpHandler = storageConfiguration.JwtBackChannelHandler; options.Audience = "Vnr-StorageServer-API"; options.Authority = storageConfiguration.IdentityServerBaseUrl; options.RequireHttpsMetadata = storageConfiguration.RequireHttpsMetadata; // https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/1214 if (options.SecurityTokenValidators.FirstOrDefault() is JwtSecurityTokenHandler jwtSecurityTokenHandler) { jwtSecurityTokenHandler.MapInboundClaims = false; } options.SaveToken = true; }); }
public RavenConfiguration() { _configBuilder = new ConfigurationBuilder(); AddEnvironmentVariables(_configBuilder); AddJsonConfigurationVariables(); Settings = _configBuilder.Build(); Core = new CoreConfiguration(); Replication = new ReplicationConfiguration(); SqlReplication = new SqlReplicationConfiguration(); Storage = new StorageConfiguration(); Encryption = new EncryptionConfiguration(); Indexing = new IndexingConfiguration(() => DatabaseName, () => Core.RunInMemory, () => Core.DataDirectory); WebSockets = new WebSocketsConfiguration(); Monitoring = new MonitoringConfiguration(); Queries = new QueryConfiguration(); Patching = new PatchingConfiguration(); DebugLog = new DebugLoggingConfiguration(); BulkInsert = new BulkInsertConfiguration(); Server = new ServerConfiguration(); Memory = new MemoryConfiguration(this); Expiration = new ExpirationBundleConfiguration(); Studio = new StudioConfiguration(); Databases = new DatabaseConfiguration(); Licensing = new LicenseConfiguration(); Quotas = new QuotasBundleConfiguration(); Tombstones = new TombstoneConfiguration(); }
public static CmsBuilder ConfigureSiaSkynet(this CmsBuilder builder, Func <StorageConfiguration> storageConfigFunc) { var services = builder.Services; var Configuration = builder.Configuration; services.Configure <SkynetConfig>(Configuration.GetSection(nameof(SkynetConfig))); StorageConfiguration storageConfig = storageConfigFunc(); if (storageConfig.ReadFiles) { services.AddTransient <IReadFile, CmsFileStorageService>(); } if (storageConfig.WriteFiles) { services.AddTransient <IWriteFile, CmsFileStorageService>(); } if (storageConfig.ReadCmsItems) { services.AddSingleton <IReadCmsItem, CmsItemStorageService>(); } if (storageConfig.WriteCmsItems) { services.AddSingleton <IWriteCmsItem, CmsItemStorageService>(); } return(builder); }
protected BaseConfiguration() { ProviderCollection <StorageProviderDefinition> storageProviderDefinitionCollection = StorageProviderDefinitionObjectMother.CreateTestDomainStorageProviders(); _storageConfiguration = new StorageConfiguration( storageProviderDefinitionCollection, storageProviderDefinitionCollection[DatabaseTest.DefaultStorageProviderID]); _storageConfiguration.StorageGroups.Add( new StorageGroupElement( new TestDomainAttribute(), DatabaseTest.c_testDomainProviderID)); _storageConfiguration.StorageGroups.Add( new StorageGroupElement( new StorageProviderStubAttribute(), DatabaseTest.c_unitTestStorageProviderStubID)); _storageConfiguration.StorageGroups.Add( new StorageGroupElement( new TableInheritanceTestDomainAttribute(), TableInheritanceMappingTest.TableInheritanceTestDomainProviderID)); _mappingLoaderConfiguration = new MappingLoaderConfiguration(); _queryConfiguration = new QueryConfiguration("QueriesForStandardMapping.xml"); var typeDiscoveryService = GetTypeDiscoveryService(GetType().Assembly); _mappingConfiguration = new MappingConfiguration( MappingReflectorObjectMother.CreateMappingReflector(typeDiscoveryService), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(_storageConfiguration))); }
protected void CreateNextFile(ITransaction metadataTransaction) { StorageConfiguration cloneConfig = (StorageConfiguration)_userConfig.Clone(); cloneConfig.StorageProvider.DatabasePath = cloneConfig.StorageProvider.DatabasePath + _userConfig.StorageProvider.DatabaseId + "\\"; bool createFile = false; if (!_fileMetadataDictionary.ContainsKey(GetFullDbId(_dbIndex))) { createFile = true; } else { //if provider does exist i.e. already loaded probably due to regenration of metadata // then check for if it is full or expansion possible if (_fileMetadataDictionary[GetFullDbId(_dbIndex)].Provider.IsDatabaseFull()) { createFile = true; } } if (createFile) { _dbIndex++; cloneConfig.StorageProvider.DatabaseId = GetFullDbId(_dbIndex); if (LoggerManager.Instance.StorageLogger != null && LoggerManager.Instance.StorageLogger.IsInfoEnabled) { LoggerManager.Instance.StorageLogger.Info("StorageProvider.CreateNextFile", "Creating File " + cloneConfig.StorageProvider.DatabasePath + cloneConfig.StorageProvider.DatabaseId); } FileMetadata <long, byte[]> fMetadata = new FileMetadata <long, byte[]>(ProviderFactory.CreateProvider(cloneConfig.StorageProvider.StorageProviderType), cloneConfig); PersistFileMetadata(cloneConfig.StorageProvider.DatabaseId, fMetadata, metadataTransaction); } }
public MeetupRepository(StorageConfiguration storageConfiguration) { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConfiguration.ConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); _container = blobClient.GetContainerReference(storageConfiguration.MasterDataSetContainerName); }
public static void Initialize() { ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition("PerformanceTestDomain", new SqlStorageObjectFactory(), ConnectionString)); StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["PerformanceTestDomain"]); DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration)); var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(StandardConfiguration).Assembly, true)); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder); MappingConfiguration mappingConfiguration = new MappingConfiguration( new MappingReflector( typeDiscoveryService, new ClassIDProvider(), new ReflectionBasedMemberInformationNameResolver(), new PropertyMetadataReflector(), new DomainModelConstraintProvider(), MappingReflector.CreateDomainObjectCreator()), new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))); MappingConfiguration.SetCurrent(mappingConfiguration); }
public RavenConfiguration(string resourceName, ResourceType resourceType, string customConfigPath = null) { ResourceName = resourceName; ResourceType = resourceType; _configBuilder = new ConfigurationBuilder(); AddEnvironmentVariables(); AddJsonConfigurationVariables(customConfigPath); Settings = _configBuilder.Build(); Core = new CoreConfiguration(); Http = new HttpConfiguration(); Replication = new ReplicationConfiguration(); Cluster = new ClusterConfiguration(); Etl = new EtlConfiguration(); Storage = new StorageConfiguration(); Security = new SecurityConfiguration(); PerformanceHints = new PerformanceHintsConfiguration(); Indexing = new IndexingConfiguration(this); Monitoring = new MonitoringConfiguration(); Queries = new QueryConfiguration(); Patching = new PatchingConfiguration(); Logs = new LogsConfiguration(); Server = new ServerConfiguration(); Testing = new TestingConfiguration(); Databases = new DatabaseConfiguration(); Memory = new MemoryConfiguration(); Studio = new StudioConfiguration(); Licensing = new LicenseConfiguration(); Tombstones = new TombstoneConfiguration(); Subscriptions = new SubscriptionConfiguration(); }
private static void BindStorageConfiguration(this IServiceCollection services, IConfiguration configuration) { var storageConfiguration = new StorageConfiguration(); storageConfiguration = JsonConvert.DeserializeObject <StorageConfiguration>(File.ReadAllText(ConfigurationLocations.GetStorageConfigurationFile())); services.AddSingleton(storageConfiguration); }
public NginxGatewayService(StatelessServiceContext serviceContext, IUnityContainer container, ILoggerFactory factory, StorageConfiguration storage, ConfigurationPackage configurationPackage) : base(new KestrelHostingServiceOptions { GatewayOptions = new GatewayOptions { Key = "NGINX-MANAGER", ReverseProxyLocation = configurationPackage.Settings.Sections["Gateway"].Parameters["ReverseProxyLocation"].Value, ServerName = configurationPackage.Settings.Sections["Gateway"].Parameters["ServerName"].Value, Ssl = JsonConvert.DeserializeObject <SslOptions>(configurationPackage.Settings.Sections["Gateway"].Parameters["SslOptions"].Value), Properties = JsonConvert.DeserializeObject <Dictionary <string, object> >(configurationPackage.Settings.Sections["Gateway"].Parameters["Properties"].Value) }, //AdditionalGateways = new GatewayOptions[] //{ // new GatewayOptions // { // Key ="NGINX-MANAGER-LOCAL", // ReverseProxyLocation = "/manage/", // ServerName = "local.earthml.com", // Ssl = new SslOptions // { // Enabled = true, // SignerEmail = "*****@*****.**", // // UseHttp01Challenge = true // }, // Properties = new Dictionary<string, object> { {"CloudFlareZoneId", "ac1d153353eebc8508f7bb31ef1ab46c" } } // } //} }, serviceContext, factory, container) { Storage = storage; _logger = factory.CreateLogger <NginxGatewayService>(); }
/// <summary> Construct a migration stream from a configuration. </summary> public MigrationStream(StorageConfiguration config) : this(config.Connect()) { if (config.ReadOnly) { throw new ArgumentException("Expected writable storage."); } }
public static void AddSwaggerGen(this IServiceCollection services, StorageConfiguration storageConfiguration) { services.AddSwaggerGen(options => { options.SwaggerDoc(storageConfiguration.ApiVersion, new OpenApiInfo { Title = storageConfiguration.ApiName, Version = storageConfiguration.ApiVersion }); options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme { Type = SecuritySchemeType.OAuth2, Flows = new OpenApiOAuthFlows { AuthorizationCode = new OpenApiOAuthFlow { AuthorizationUrl = new Uri($"{storageConfiguration.IdentityServerBaseUrl}/connect/authorize"), TokenUrl = new Uri($"{storageConfiguration.IdentityServerBaseUrl}/connect/token"), Scopes = new Dictionary <string, string> { { storageConfiguration.OidcApiName, storageConfiguration.ApiName }, } } } }); options.OperationFilter <AuthorizeCheckOperationFilter>(); }).AddSwaggerGenNewtonsoftSupport(); }
public void SetUp() { try { var providers = new ProviderCollection <StorageProviderDefinition>(); providers.Add(new RdbmsProviderDefinition("TheStorageProvider", new SqlStorageObjectFactory(), TestDomainConnectionString)); var storageConfiguration = new StorageConfiguration(providers, providers["TheStorageProvider"]); DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration)); SqlConnection.ClearAllPools(); var scriptGenerator = new ScriptGenerator( pd => pd.Factory.CreateSchemaScriptBuilder(pd), new RdbmsStorageEntityDefinitionProvider(), new ScriptToStringConverter()); var scripts = scriptGenerator.GetScripts(MappingConfiguration.Current.GetTypeDefinitions()).Single(); var masterAgent = new DatabaseAgent(MasterConnectionString); masterAgent.ExecuteBatchFile("Database\\CreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary()); var databaseAgent = new DatabaseAgent(TestDomainConnectionString); databaseAgent.ExecuteBatchString(scripts.SetUpScript, true); } catch (Exception e) { Console.WriteLine("SetUpFixture failed: " + e); Console.WriteLine(); throw; } }
protected BaseDataStore(ICosmosDbClientFactory factory, StorageConfiguration configuration, IMapper mapper) { Mapper = mapper; Configuration = configuration; Client = factory.CreateClient(); CollectionName = typeof(TModel).Name; }
private bool HasDiskUsageChanged(StorageConfiguration old, StorageConfiguration @new) { //We don't want to cause updates when the disk usage has changed non-significantly. return(old == null || Math.Abs(old.FileStoreDiskSpace.UsedSpacePercent - @new.FileStoreDiskSpace.UsedSpacePercent) > 0.0001 || old.FileStoreDiskSpace.TotalSpace != @new.FileStoreDiskSpace.TotalSpace); }
public Configuration() { UsingChannelShuffler <DefaultChannelShuffler>(); UsingRouterInterceptor <NullRouterInterceptor>(); UsingBusInterceptor <NullBusInterceptor>(); UsingSagaStorage <NullSagaStorage>(); UsingMessageStorage <NullMessageStorage>(); UsingChannelManager <NullChannelManager>(); UsingPointToPointChannel <NullPointToPointChannel>(); UsingPublishSubscribeChannel <NullPublishSubscribeChannel>(); UsingRequestReplyChannel <NullRequestReplyChannel>(); UsingMessageSerializer <NullMessageSerializer>(); UsingMessageAdapter <NullMessageAdapter>(); InboundMiddlewareTypes = new List <Type>(); RouterLoggerTypes = new List <Type>(); MonitoringTaskTypes = new List <TaskMetadata>(); StartupTaskTypes = new List <Type>(); ShutdownTaskTypes = new List <Type>(); LoggerTypes = new Dictionary <Type, IList <Type> >(); OutboundMiddlewareTypes = new List <Type>(); AddLogger <HeartBeatLogger, HeartBeat>(); AddLogger <StartupBeatLogger, StartupBeat>(); AddLogger <ShutdownBeatLogger, ShutdownBeat>(); AddStartupTask <StartupTask>(); AddStartupTask <HandlerAndEndpointStartupTask>(); AddStartupTask <ChannelStartupTask>(); AddStartupTask <ListenerStartupTask>(); AddShutdownTask <ListenerShutdownTask>(); AddShutdownTask <ShutdownTask>(); UsingShutdownWatcher <ShutdownNullWatcher>(); Storage = new StorageConfiguration(); Identity = new IdentityConfiguration(); ApplicationName = "[Empty]"; ChannelProviderName = "[Empty]"; }
public PlaylistModel(StorageConfiguration storageConfiguration, string file, IList <SongModel> songLibrary) { _storageConfiguration = storageConfiguration; Name = Path.GetFileNameWithoutExtension(file); FilePath = file; var lines = File.ReadAllLines(file); var basePath = _storageConfiguration.RootDirectory; if (_storageConfiguration.PlaylistDirectory != null) { basePath = Path.Combine(basePath, _storageConfiguration.PlaylistDirectory); } foreach (var line in lines) { if (line.StartsWith("#EXTM3U") || line.StartsWith("#EXTINF") || line.StartsWith("#EXT")) { continue; } var filePath = Path.Combine(basePath, line); var song = songLibrary.FirstOrDefault(x => Path.GetFullPath(x.FilePath) == Path.GetFullPath(filePath)); if (song != null) { Songs.Add(song); } } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, StorageConfiguration storageConfiguration) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(storageConfiguration); } app.UseHttpsRedirection(); app.Use(async(context, next) => { context.Request.EnableBuffering(); await next(); }); app.UseStaticFiles(); app.UseFileServer(new FileServerOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, ArchiveConstants.PhysicalFileProviderPath)), RequestPath = ArchiveConstants.ArchiveRequestPath, EnableDirectoryBrowsing = true, }); app.UseRouting(); app.UseCors(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public void TestDriveNotSet() { var configuration = new StorageConfiguration { FileStoreDirectory = @"c:\filestore" }; var maxUsedSpace = configuration.MaximumUsedSpaceBytes; }
private void AreEqual(StorageConfiguration exp, StorageConfiguration act) { if (exp != null) { AreEqual(exp.LoggingConfiguration, act.LoggingConfiguration); AreEqual(exp.MetricConfiguration, act.MetricConfiguration); } }
public static void Reset() { Configuration = new StorageConfiguration { FileStoreDirectory = @"c:\filestore", MinimumFreeSpaceBytes = 5 * 1024L * 1024L * 1024L }; }
public StorageService(CloudAuthenticator authenticator) : base(authenticator) { if (authenticator == null) throw new ArgumentNullException(nameof(authenticator)); _config = new StorageConfiguration(); }
public override bool Initialize(StorageConfiguration configuration, StatsIdentity statsIdentity) { if (!configuration.StorageProvider.IsMultiFileStore) { configuration.StorageProvider.MaxFileSize = 3221225472;//3GB//MiscUtil.MAX_FILE_SIZE; } return(base.Initialize(configuration, statsIdentity)); }
public static void UpdateConfiguration(StorageConfiguration configuration) { Platform.GetService<IStorageConfiguration>( s => s.UpdateConfiguration(new UpdateStorageConfigurationRequest { Configuration = configuration })); }
public void FeedConfigurationConstructorTest() { StorageConfiguration config = FeedConfiguration.StorageConfiguration; FeedFileStorage storage = config.GetProvider() as FeedFileStorage; Assert.IsNotNull(storage); }
public Bucket(string bucketId, CloudAuthenticator authenticator, StorageConfiguration configuration) { this._bucketId = bucketId; this._authenticator = authenticator; this._config = configuration; _authenticator.GetInitializer().GZipEnabled = _config.EnableGzip; _googleStorageService = new Google.Apis.Storage.v1.StorageService(_authenticator.GetInitializer()); }
public void TestSetMinUsedSpace_InvalidPercent() { var diskSpace = new Diskspace { TotalSpace = _petaByte, FreeSpace = _halfGig }; var configuration = new StorageConfiguration { FileStoreDirectory = @"c:\filestore", FileStoreDiskSpace = diskSpace }; configuration.MinimumFreeSpacePercent = 110; }
public void TestMinimumFreeSpaceBytes() { var diskSpace = new Diskspace { TotalSpace = _petaByte, FreeSpace = _halfGig }; var configuration = new StorageConfiguration { FileStoreDirectory = @"c:\filestore", FileStoreDiskSpace = diskSpace }; configuration.MinimumFreeSpacePercent = 90; Assert.AreEqual(1013309916158361, configuration.MinimumFreeSpaceBytes); }
private const long _storageConfigurationCacheExpiry = 10000; // really short timeout, we're just mitigating against access in tight loops public static void UpdateConfiguration(StorageConfiguration configuration) { Platform.GetService<IStorageConfiguration>(s => { s.UpdateConfiguration(new UpdateStorageConfigurationRequest {Configuration = configuration}); lock (_syncLock) { // we don't actually just update the cache, because the database is shared and may be updated by other processes _storageConfigurationCache = null; } }); }
public void TestSetMinUsedSpace_Auto() { var diskSpace = new Diskspace { TotalSpace = _petaByte, FreeSpace = _halfGig }; var configuration = new StorageConfiguration { FileStoreDirectory = @"c:\filestore", FileStoreDiskSpace = diskSpace }; configuration.MinimumFreeSpacePercent = -10; Assert.AreEqual(configuration.MinimumFreeSpacePercent, StorageConfiguration.AutoMinimumFreeSpace); }
// TODO (CR Jun 2012): Move to a helper class? #region Implementation of IStorageConfiguration public GetStorageConfigurationResult GetConfiguration(GetStorageConfigurationRequest request) { var storageSettings = new StorageSettings(); var deletionSettings = new StudyDeletionSettings(); var configuration = new StorageConfiguration { FileStoreDirectory = storageSettings.FileStoreDirectory, MinimumFreeSpacePercent = storageSettings.MinimumFreeSpacePercent, DefaultDeletionRule = new StorageConfiguration.DeletionRule { Enabled = deletionSettings.Enabled, TimeUnit = deletionSettings.TimeUnit, TimeValue = deletionSettings.TimeValue } }; Complete(configuration); return new GetStorageConfigurationResult {Configuration = configuration}; }
public static StorageConfiguration GetConfiguration(bool forceReload) { if (!forceReload) { lock (_syncLock) { if (_storageConfigurationCache != null && _storageConfigurationCacheTime > Environment.TickCount - _storageConfigurationCacheExpiry) { return _storageConfigurationCache.Clone(); } } } StorageConfiguration configuration = null; Platform.GetService<IStorageConfiguration>(s => { configuration = s.GetConfiguration(new GetStorageConfigurationRequest()).Configuration; if (configuration != null) { lock (_syncLock) { _storageConfigurationCache = configuration.Clone(); _storageConfigurationCacheTime = Environment.TickCount; } } }); return configuration; }
/// <summary> /// Constructor. /// </summary> /// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param> /// <param name="configuration">Storage configuration. </param> /// <param name="hostname">The IP Address the remote app is connecting with.</param> /// <param name="auditSource">The source of the request for auditing purposes </param> public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource) { _monitor = WorkItemActivityMonitor.Create(false); _monitor.WorkItemsChanged += WorkItemsChanged; var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE); if (serverList.Count == 1) _dicomServerNode = CollectionUtils.FirstElement(serverList); _hostname = hostname; }
public void TestFileStoreDirectoryValid() { var configuration = new StorageConfiguration { FileStoreDirectory = @"c:\filestore" }; Assert.IsTrue(configuration.IsFileStoreDriveValid); configuration.FileStoreDirectory = @"A:\\"; Assert.IsTrue(configuration.IsFileStoreDriveValid); configuration.FileStoreDirectory = @"\"; Assert.IsFalse(configuration.IsFileStoreDriveValid); configuration.FileStoreDirectory = @"\\"; Assert.IsFalse(configuration.IsFileStoreDriveValid); configuration.FileStoreDirectory = @"\\test\testing"; Assert.IsFalse(configuration.IsFileStoreDriveValid); }
/// <summary> /// Constructor. /// </summary> /// <param name="sourceAE">The local AE title of the application importing the studies.</param> /// <param name="configuration">The storage configuration. </param> /// <param name="auditSource">The source of the import. </param> public ImportStudyContext(string sourceAE, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource) {}
private void Complete(StorageConfiguration configuration) { if (String.IsNullOrEmpty(configuration.FileStoreDirectory)) configuration.FileStoreDirectory = DefaultFileStoreLocation; if (configuration.AutoCalculateMinimumFreeSpacePercent) configuration.MinimumFreeSpaceBytes = ComputeMinimumFreeSpaceBytes(configuration.FileStoreDirectory); if (configuration.DefaultDeletionRule == null) configuration.DefaultDeletionRule = new StorageConfiguration.DeletionRule { Enabled = false, TimeUnit = TimeUnit.Weeks, TimeValue = 1 }; }
/// <summary> /// Creates an instance of <see cref="ImportFilesContext"/> to be used /// by <see cref="ImportFilesUtility"/> /// </summary> protected ImportFilesContext(string sourceAE, StorageConfiguration configuration, EventSource auditSource) { StudyWorkItems = new ObservableDictionary<string, WorkItem>(); FailedStudyAudits = new Dictionary<string, string>(); SourceAE = sourceAE; StorageConfiguration = configuration; AuditSource = auditSource; ExpirationDelaySeconds = WorkItemServiceSettings.Default.ExpireDelaySeconds; }
private bool HasStorageConfigurationChanged(StorageConfiguration old, StorageConfiguration @new) { return old == null || old.FileStoreDirectory != @new.FileStoreDirectory || Math.Abs(old.MinimumFreeSpacePercent - @new.MinimumFreeSpacePercent) > 0.0001; }
private bool HasDiskUsageChanged(StorageConfiguration old, StorageConfiguration @new) { //We don't want to cause updates when the disk usage has changed non-significantly. return old == null || Math.Abs(old.FileStoreDiskSpace.UsedSpacePercent - @new.FileStoreDiskSpace.UsedSpacePercent) > 0.0001 || old.FileStoreDiskSpace.TotalSpace != @new.FileStoreDiskSpace.TotalSpace; }
public StorageService(CloudAuthenticator authenticator, StorageConfiguration config) : this(authenticator) { _config = config; }
private void NotifyDiskUsageChanged(StorageConfiguration storageConfiguration) { if (_refreshTimer == null) return; //We still reassign this value, even if it's only the disk usage that's changed because //the DiskSpace class caches its values, so we need to swap it out for a new one. _storageConfiguration = storageConfiguration; EventsHelper.Fire(DiskSpaceUsageChanged, this, EventArgs.Empty); }
private void NotifyStorageConfigurationChanged(StorageConfiguration storageConfiguration) { if (_refreshTimer == null) return; _storageConfiguration = storageConfiguration; EventsHelper.Fire(StudyStorageConfigurationChanged, this, EventArgs.Empty); //The file store directory may have changed, so just update this, too. EventsHelper.Fire(DiskSpaceUsageChanged, this, EventArgs.Empty); }
public void TestDriveNotSet() { var configuration = new StorageConfiguration {FileStoreDirectory = @"c:\filestore"}; var maxUsedSpace = configuration.MaximumUsedSpaceBytes; }
protected StorageConfiguration GetPersistenceConfiguration() { StorageConfiguration storageConfiguration = DomainObjectsConfiguration.Current.Storage; if (storageConfiguration.DefaultStorageProviderDefinition == null) { ProviderCollection<StorageProviderDefinition> storageProviderDefinitionCollection = new ProviderCollection<StorageProviderDefinition> (); RdbmsProviderDefinition providerDefinition = new RdbmsProviderDefinition ("Default", new SqlStorageObjectFactory (), "Initial Catalog=DatabaseName;"); storageProviderDefinitionCollection.Add (providerDefinition); storageConfiguration = new StorageConfiguration (storageProviderDefinitionCollection, providerDefinition); } return storageConfiguration; }
public void Refresh() { _dicomServerConfiguration = DicomServer.GetConfiguration(); _storageConfiguration = StudyStore.GetConfiguration(); }
public UpdateStorageConfigurationResult UpdateConfiguration(UpdateStorageConfigurationRequest request) { Configuration = request.Configuration; return new UpdateStorageConfigurationResult(); }