/// <summary> /// Enumerates all the hashes with <see cref="ContentLocationEntry"/> from a <paramref name="database"/> for a given <paramref name="currentMachineId"/>. /// </summary> public static IEnumerable <(ShortHash hash, long size)> EnumerateSortedHashesWithContentSizeForMachineId( this ContentLocationDatabase database, OperationContext context, MachineId currentMachineId) { foreach (var(hash, entry) in EnumerateSortedDatabaseEntriesForMachineId(database, context, currentMachineId)) { yield return(hash, entry.ContentSize); } }
/// <summary> /// Enumerates all the hashes with <see cref="ContentLocationEntry"/> from a <paramref name="database"/> for a given <paramref name="currentMachineId"/>. /// </summary> public static IEnumerable <(ShortHash hash, ContentLocationEntry entry)> EnumerateSortedDatabaseEntriesForMachineId( this ContentLocationDatabase database, OperationContext context, MachineId currentMachineId) { foreach (var(key, entry) in database.EnumerateEntriesWithSortedKeys( context.Token, rawValue => database.HasMachineId(rawValue, currentMachineId.Index))) { yield return(key, entry); } }
/// <summary> /// Performs a compare exchange operation on metadata, while ensuring all invariants are kept. If the /// fingerprint is not present, then it is inserted. /// </summary> /// <returns> /// Result providing the call's completion status. True if the replacement was completed successfully, false otherwise. /// </returns> public static Possible <bool> CompareExchange( this ContentLocationDatabase database, OperationContext context, StrongFingerprint strongFingerprint, ContentHashListWithDeterminism expected, ContentHashListWithDeterminism replacement) { return(database.TryUpsert( context, strongFingerprint, replacement, entry => entry.ContentHashListWithDeterminism.Equals(expected))); }
/// <summary> /// Enumerates all the hashes with <see cref="ContentLocationEntry"/> from a <paramref name="database"/> for a given <paramref name="currentMachineId"/>. /// </summary> private static IEnumerable <(ShortHash hash, ContentLocationEntry entry)> EnumerateSortedDatabaseEntriesForMachineId( this ContentLocationDatabase database, OperationContext context, MachineId currentMachineId, ShortHash?startingPoint) { var filter = new ContentLocationDatabase.EnumerationFilter( rawValue => database.HasMachineId(rawValue, currentMachineId.Index), startingPoint); foreach (var(key, entry) in database.EnumerateEntriesWithSortedKeys(context, filter)) { yield return(key, entry); } }
/// <inheritdoc /> public CheckpointManager( ContentLocationDatabase database, ICheckpointRegistry checkpointRegistry, CentralStorage storage, CheckpointConfiguration configuration, CounterCollection <ContentLocationStoreCounters> counters) { _database = database; _checkpointRegistry = checkpointRegistry; _storage = storage; _configuration = configuration; _fileSystem = new PassThroughFileSystem(); _checkpointStagingDirectory = configuration.WorkingDirectory / "staging"; Counters = counters; }
/// <inheritdoc /> public CheckpointManager( ContentLocationDatabase database, ICheckpointRegistry checkpointRegistry, CentralStorage storage, CheckpointConfiguration configuration, CounterCollection <ContentLocationStoreCounters> counters) { _database = database; _checkpointRegistry = checkpointRegistry; _storage = storage; _configuration = configuration; _fileSystem = new PassThroughFileSystem(); _checkpointStagingDirectory = configuration.WorkingDirectory / "staging"; _incrementalCheckpointDirectory = configuration.WorkingDirectory / "incremental"; _lastCheckpointFile = configuration.WorkingDirectory / "lastCheckpoint.txt"; _fileSystem.CreateDirectory(_incrementalCheckpointDirectory); _incrementalCheckpointInfoFile = _incrementalCheckpointDirectory / "checkpointInfo.txt"; Counters = counters; }
/// <inheritdoc /> public CheckpointManager( ContentLocationDatabase database, ICheckpointRegistry checkpointRegistry, CentralStorage storage, CheckpointManagerConfiguration configuration, CounterCollection <ContentLocationStoreCounters> counters, ICheckpointObserver checkpointObserver = null) { Database = database; CheckpointRegistry = checkpointRegistry; Storage = storage; _configuration = configuration; _fileSystem = new PassThroughFileSystem(); _checkpointStagingDirectory = configuration.WorkingDirectory / "staging"; _checkpointObserver = checkpointObserver; Counters = counters; LinkLifetime(Database); LinkLifetime(CheckpointRegistry); LinkLifetime(_checkpointObserver); LinkLifetime(Storage); }
public FlushableCache(ContentLocationDatabaseConfiguration configuration, ContentLocationDatabase database) { _configuration = configuration; _database = database; }