public IEnumerable <RemoveRequest> ConsumeRemovalReplicationInfo(byte[] hash) { Api.JetSetCurrentIndex(session, replicationRemoval, "by_hash"); Api.MakeKey(session, replicationRemoval, hash, MakeKeyGrbit.NewKey); if (Api.TrySeek(session, replicationRemoval, SeekGrbit.SeekEQ) == false) { yield break; } Api.MakeKey(session, replicationRemoval, hash, MakeKeyGrbit.NewKey); Api.JetSetIndexRange(session, replicationRemoval, SetIndexRangeGrbit.RangeUpperLimit | SetIndexRangeGrbit.RangeInclusive); do { var request = new RemoveRequest { Key = Api.RetrieveColumnAsString(session, replicationRemoval, replicationColumns["key"]), SpecificVersion = ReadVersion(replicationRemoval, replicationRemovalColumns) }; Api.JetDelete(session, replicationRemoval); yield return(request); } while (Api.TryMoveNext(session, replicationRemoval)); }
public bool Remove(RemoveRequest request) { ValueVersion[] versions; bool doesAllVersionsMatch; if (request.SpecificVersion != null) { versions = new[] { request.SpecificVersion }; doesAllVersionsMatch = DoesAllVersionsMatch(request.Key, versions); } else { versions = GatherActiveVersions(request.Key); doesAllVersionsMatch = true; } if (doesAllVersionsMatch) { DeleteAllKeyValuesForVersions(request.Key, versions); foreach (var version in versions) { var copy = version; commitSyncronization.Add(() => cache.Remove(GetKey(request.Key, copy))); } commitSyncronization.Add(() => cache.Remove(GetKey(request.Key))); } return(doesAllVersionsMatch); }
private bool[] RemoveInternal(RemoveRequest[] valuesToRemove, int backupIndex) { var results = new bool[valuesToRemove.Length]; var groupedByEndpoint = from req in valuesToRemove let er = new { OriginalIndex = Array.IndexOf(valuesToRemove, req), Remove = new ExtendedRemoveRequest { Key = req.Key, SpecificVersion = req.SpecificVersion, Segment = GetSegmentFromKey(req.Key), } } group er by GetEndpointByBackupIndex(topology.Segments[er.Remove.Segment], backupIndex) into g select g; foreach (var endpoint in groupedByEndpoint) { if (endpoint.Key == null) throw new NoMoreBackupsException(); var requests = endpoint.ToArray(); var removeRequests = requests.Select(x => x.Remove).ToArray(); var removesResults = GetRemovesResults(endpoint.Key, removeRequests, backupIndex); for (var i = 0; i < removesResults.Length; i++) { results[requests[i].OriginalIndex] = removesResults[i]; } } return results; }
private static void RegisterRemovalForReplication(RemoveRequest request, PersistentHashTableActions actions, ValueVersion version) { foreach (var hash in actions.GetReplicationHashes(request.Key, version)) { actions.AddReplicationRemovalInfo( request.Key, version, hash ); } }
public bool Remove(RemoveRequest request) { var doesAllVersionsMatch = DoesAllVersionsMatch(request.Key, request.ParentVersions); if (doesAllVersionsMatch) { DeleteAllKeyValuesForVersions(request.Key, request.ParentVersions); foreach (var version in request.ParentVersions) { var copy = version; commitSyncronization.Add(() => cache.Remove(GetKey(request.Key, copy))); } commitSyncronization.Add(() => cache.Remove(GetKey(request.Key))); } return doesAllVersionsMatch; }