Beispiel #1
0
        public ColdStorage(IAbsFileSystem fileSystem, ColdStorageSettings coldStorageSettings, DistributedContentCopier distributedContentCopier)
        {
            _fileSystem = fileSystem;
            _copier     = distributedContentCopier;

            _rootPath = coldStorageSettings.GetAbsoulutePath();

            ConfigurationModel configurationModel
                = new ConfigurationModel(new ContentStoreConfiguration(new MaxSizeQuota(coldStorageSettings.CacheSizeQuotaString !)));

            ContentStoreSettings contentStoreSettings = FromColdStorageSettings(coldStorageSettings);

            _store = new FileSystemContentStore(fileSystem, SystemClock.Instance, _rootPath, configurationModel, null, contentStoreSettings, null);

            HashType hashType;

            if (!Enum.TryParse <HashType>(coldStorageSettings.ConsistentHashingHashType, true, out hashType))
            {
                hashType = HashType.SHA256;
            }
            _contentHasher = HashInfoLookup.GetContentHasher(hashType);

            _copiesQuantity    = coldStorageSettings.ConsistentHashingCopiesQuantity;
            _maxParallelPlaces = coldStorageSettings.MaxParallelPlaces;

            // Starts empty and is created during the first update
            _ring = new RingNode[0];
        }
        /// <summary>
        /// Disposes the hasher to save on memory when the server mode process runs
        /// </summary>
        public static void DisposeAndResetHasher()
        {
            s_hasher?.Dispose();
            s_hasher = HashInfo.CreateContentHasher();

            foreach (var hasher in s_contentHasherByHashType.Values)
            {
                hasher.Dispose();
            }
            s_contentHasherByHashType = new ConcurrentDictionary <HashType, IContentHasher>();
        }
 protected HasherPerformanceTests(ITestOutputHelper output, HashType hashType, PerformanceResultsFixture resultsFixture)
     : base(output)
 {
     _resultsFixture = resultsFixture;
     _hasher         = HashInfoLookup.Find(hashType).CreateContentHasher();
 }
Beispiel #4
0
 /// <summary>
 /// Computes a string representation of a hash for a current machine location.
 /// </summary>
 public string GetContentHashString(IContentHasher hasher)
 {
     return(GetContentHashString(GetContentHash(hasher)));
 }
Beispiel #5
0
        /// <summary>
        /// Computes a hash for a current machine location.
        /// </summary>
        public ContentHash GetContentHash(IContentHasher hasher)
        {
            Contract.Requires(IsValid, "Please do not use default struct instance");

            return(hasher.GetContentHash(Data));
        }
Beispiel #6
0
 public ClearTextContentEncryptor(IContentHasher hasher)
 {
     this.Hasher = hasher;
 }
Beispiel #7
0
 /// <summary>
 /// Disposes the hasher to save on memory when the server mode process runs
 /// </summary>
 public static void DisposeAndResetHasher()
 {
     s_hasher?.Dispose();
     s_hasher = HashInfo.CreateContentHasher();
 }
Beispiel #8
0
 protected ContentDirectoryTests(ILogger logger, MemoryClock clock, Lazy <IAbsFileSystem> fileSystem)
     : base(logger, fileSystem)
 {
     MemoryClock = clock;
     _hasher     = HashInfoLookup.Find(HashType.Vso0).CreateContentHasher();
 }