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); }
public static StorageConfiguration GetConfiguration() { StorageConfiguration configuration = null; Platform.GetService <IStorageConfiguration>( s => configuration = s.GetConfiguration(new GetStorageConfigurationRequest()).Configuration); return(configuration); }
public static void UpdateConfiguration(StorageConfiguration configuration) { Platform.GetService <IStorageConfiguration>( s => s.UpdateConfiguration(new UpdateStorageConfigurationRequest { Configuration = configuration })); }
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; } }); }
// 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 }); }
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 } } ; }