private static void Publish(SystemSnapshotStreamReader reader, IRingBuffer <BootstrapItem> ring) { foreach (var memento in reader.Read()) { var next = ring.Next(); var claimed = ring[next]; claimed.AsSnapshot(memento.Item1, memento.Item2, memento.Item3); ring.Publish(next); } }
private static bool Replay(BootstrapInfo info, IRingBuffer <TransformationItem> transformRing, JournaledMessage message) { if (message.Sequence <= info.SnapshotSequence) { return(false); } var next = transformRing.Next(); var claimed = transformRing[next]; claimed.AsJournaledMessage(message.Sequence, message.SerializedBody, message.SerializedType, message.SerializedHeaders); transformRing.Publish(next); return(true); }
private void TryTakeSystemSnapshot(IRepository repository, IRingBuffer <SnapshotItem> ringBuffer, BootstrapInfo info) { if ((info.JournaledSequence - info.SnapshotSequence) <= this.snapshotFrequency) { return; } var items = repository.Items; var remaining = items.Count; foreach (var hydratable in items) { var next = ringBuffer.Next(); var claimed = ringBuffer[next]; claimed.AsPartOfSystemSnapshot(info.JournaledSequence, --remaining, hydratable.Key, hydratable.Memento, hydratable.MementoType); ringBuffer.Publish(next); } }
private static void TakePublicSnapshot(IRepository repository, IRingBuffer <SnapshotItem> ringBuffer) { var count = 0; var hydratables = repository.Accessed; foreach (var pair in hydratables) { var hydratable = pair.Key; if (!hydratable.IsPublicSnapshot) { continue; } count++; var claimed = ringBuffer.Next(); var item = ringBuffer[claimed]; item.AsPublicSnapshot(hydratable.Key, hydratable.Memento, hydratable.MementoType, pair.Value); ringBuffer.Publish(claimed); } Log.InfoFormat("{0} public hydratables snapshots taken.", count); hydratables.TryClear(); }
private void Dispatch(BootstrapInfo info, IRingBuffer <JournalItem> journalRing, JournaledMessage message) { if (message.Sequence <= info.DispatchSequence) { return; // already dispatched } if (message.ForeignId != Guid.Empty) { return; // only re-dispatch messages which originated here } if (this.internalTypes.Contains(message.SerializedType)) { return; } var next = journalRing.Next(); var claimed = journalRing[next]; claimed.AsBootstrappedDispatchMessage(message.Sequence, message.SerializedBody, message.SerializedType, message.SerializedHeaders); journalRing.Publish(next); }