private void HandleSnapshotOffer(SnapshotOffer offer) { if (offer.Snapshot is PersistenceState persistenceState) { state = persistenceState; } }
/// <summary> /// Restores the last snapshot /// </summary> private void HandleSnapshotOffer(SnapshotOffer offer) { if (offer.Snapshot is ReadingPersistenceState state) { _state = state; } }
private void OnRecover(SnapshotOffer snapshot) { _eventLog.Add("OnRecover(SnapshotOffer)"); var state = (NotepadState)snapshot.Snapshot; if (state != null) _state = state; }
private bool Recover(SnapshotOffer offer) { if (offer.Snapshot is SchedulerState <TJob, TIdentity> state) { State = state; } return(true); }
private void RecoverFromSnapshot(SnapshotOffer snapshot) { // recover state from snapshot if (snapshot.Snapshot is List <Message> message) { _messages = message; } }
private bool LoadState(SnapshotOffer @event) { var snapshot = ((SnapshotOffer)@event).Snapshot as TState; if (snapshot == null) { return(false); } _state = snapshot; return(true); }
private void OnRecover(SnapshotOffer snapshot) { _eventLog.Add("OnRecover(SnapshotOffer)"); var state = (NotepadState)snapshot.Snapshot; if (state != null) { _state = state; } }
public static T ToObject <T>(this SnapshotOffer snapshot) { if (snapshot.Snapshot is JObject) { return((snapshot.Snapshot as JObject).ToObject <T>()); } else { return(default(T)); } }
private void ProcessSnapshot(SnapshotOffer snapshotOffer) { try { Newtonsoft.Json.Linq.JObject jo = (Newtonsoft.Json.Linq.JObject)snapshotOffer.Snapshot; _ActorState = jo.ToObject <UserState>(); } catch (Exception e) { _logger.Error($"Failed to parse JSON snapshot for id:{PersistenceId} - exception message:{e.Message}"); } }
private void ProcessSnapshot(SnapshotOffer offer) { Monitor(); //var snap = ((Newtonsoft.Json.Linq.JArray) offer.Snapshot).ToObject<string[]>(); var snap = (string[])offer.Snapshot; foreach (var portfolio in snap) { _portfolios.Add(portfolio, null); _log.Info($"[ProcessSnapshot]: {Self.Path.Name} Snapshot recovered portfolio: {portfolio}."); } }
private void RecoverSnapshot(SnapshotOffer offer) { Acc = (Account)offer.Snapshot; if (Acc == null) { _log.Error("ERROR in RecoverSnapshot. PersistenceId = {0}", AccountId); } else { AccountId = Acc.AccountID; _log.Debug("Finished Processing RecoverSnapshot, ID={0}", Acc.AccountID); } }
protected virtual bool Recover(SnapshotOffer aggregateSnapshotOffer) { try { State = aggregateSnapshotOffer.Snapshot as TState; } catch { return(false); } return(true); }
private void ProcessSnapshot(SnapshotOffer offer) { Monitor(); _porfolioState = (PorfolioState)offer.Snapshot; //Clear out the old address reference _porfolioState.SupervizedAccounts.ForEach(x => x.Value.AccountActorRef = null); //clear out the billed amount _porfolioState.SupervizedAccounts.ForEach(x => x.Value.LastBilledAmount = 0.0); _log.Info($"{Self.Path.Name} Snapshot recovered. {_porfolioState.SupervizedAccounts.Count} accounts."); }
protected virtual bool Recover(SnapshotOffer aggregateSnapshotOffer) { try { State = aggregateSnapshotOffer.Snapshot as TSagaState; } catch (Exception exception) { Logger.Error($"Recovering with snapshot of type [{aggregateSnapshotOffer.Snapshot.GetType().PrettyPrint()}] caused an exception {exception.GetType().PrettyPrint()}"); return(false); } return(true); }
protected override void OnRecover(object message) { logger.Info($"Actor OnRecovery:{GetType()} - Message:{message}"); // handle recovery here try { SnapshotOffer snapshot = message as SnapshotOffer; _value = Convert.ToInt32(snapshot.Snapshot); logger.Info($"Value recovered:{_value}"); } catch (Exception) { } }
private void MutateInternalState(SnapshotOffer snapshotOffer) { AtomFeedState savedState; if (!(snapshotOffer.Snapshot is AtomFeedState)) return; savedState = (AtomFeedState)snapshotOffer.Snapshot; this.CurrentFeedHeadDocument = savedState.CurrentFeedHeadDocument; this.AtomFeedId = savedState.AtomFeedId; this.FeedAuthor = savedState.FeedAuthor; this.FeedTitle = savedState.FeedTitle; this.LastHeadDocument = savedState.LastHeadDocument; this.numberOfEventsInCurrentHeadDocument = savedState.NumberOfEventsInCurrentHeadDocument; this.currentDocumentId = savedState.CurrentHeadDocumentIndex; }
protected virtual bool Recover(SnapshotOffer aggregateSnapshotOffer) { try { Log.Debug("AggregateSaga of Name={0}, and Id={1}; has received a SnapshotOffer of Type={2}.", Name, Id, aggregateSnapshotOffer.Snapshot.GetType().PrettyPrint()); var comittedSnapshot = aggregateSnapshotOffer.Snapshot as CommittedSnapshot <TAggregateSaga, TIdentity, IAggregateSnapshot <TAggregateSaga, TIdentity> >; HydrateSnapshot(comittedSnapshot.AggregateSnapshot, aggregateSnapshotOffer.Metadata.SequenceNr); } catch (Exception exception) { Log.Error(exception, "AggregateSaga of Name={0}, Id={1}; recovering with snapshot of Type={2} caused an exception.", Name, Id, aggregateSnapshotOffer.Snapshot.GetType().PrettyPrint()); return(false); } return(true); }
protected virtual bool Recover(SnapshotOffer aggregateSnapshotOffer) { Logger.Info($"Aggregate [{Name}] With Id={Id} has received a SnapshotOffer of type {aggregateSnapshotOffer.Snapshot.GetType().PrettyPrint()}"); try { var comittedSnapshot = aggregateSnapshotOffer.Snapshot as ComittedSnapshot <TAggregate, TIdentity, IAggregateSnapshot <TAggregate, TIdentity> >; HydrateSnapshot(comittedSnapshot.AggregateSnapshot, aggregateSnapshotOffer.Metadata.SequenceNr); } catch (Exception exception) { Logger.Error($"Recovering with snapshot of type [{aggregateSnapshotOffer.Snapshot.GetType().PrettyPrint()}] caused an exception {exception.GetType().PrettyPrint()}"); return(false); } return(true); }
protected override bool ReceiveRecover(object message) { if (message is JObject) { UpdateState(((JObject)message).ToObject <Event>()); } else if (message is SnapshotOffer) { SnapshotOffer so = (SnapshotOffer)message; Newtonsoft.Json.Linq.JObject jo = (Newtonsoft.Json.Linq.JObject)so.Snapshot; State = jo.ToObject <ExampleState>(); } else { return(false); } return(true); }
/// <summary> /// This command handler attempts to instantiate the child UserActor and add it to the Admin's UserItem list. /// </summary> /// <param name="cLIC">User list item command. Contains the UserItem</param> /// <returns>True if ok. False otherwise.</returns> #endregion Insert Command #region Helper Methods #endregion Helper Methods #region Snapshots private void ProcessSnapshot(SnapshotOffer snapshotOffer) { _logger.Debug($"Recovering snapshot for ActorId:{_ActorState.Id} UserName:{_ActorState.Name}"); try { Newtonsoft.Json.Linq.JObject jo = (Newtonsoft.Json.Linq.JObject)snapshotOffer.Snapshot; var temp = jo.ToObject <UserListState>(); foreach (KeyValuePair <string, Object> o in temp.Items) { JObject itemJO = o.Value as JObject; _ActorState[o.Key] = itemJO.ToObject <UserListItem>(); } } catch (Exception e) { _logger.Debug($"Recovering snapshot failed for ActorId:{_ActorState.Id} UserName:{_ActorState?.Name??"No name"} exception:{e.Message}"); } }
private void MutateInternalState(SnapshotOffer snapshotOffer) { AtomFeedState savedState; if (!(snapshotOffer.Snapshot is AtomFeedState)) { return; } savedState = (AtomFeedState)snapshotOffer.Snapshot; this.CurrentFeedHeadDocument = savedState.CurrentFeedHeadDocument; this.AtomFeedId = savedState.AtomFeedId; this.FeedAuthor = savedState.FeedAuthor; this.FeedTitle = savedState.FeedTitle; this.LastHeadDocument = savedState.LastHeadDocument; this.numberOfEventsInCurrentHeadDocument = savedState.NumberOfEventsInCurrentHeadDocument; this.currentDocumentId = savedState.CurrentHeadDocumentIndex; }
private void OnRecover(SnapshotOffer snapshot) { _state = (GreeterState)snapshot.Snapshot; }
private void ProcessSnapshot(SnapshotOffer offer) { this.Monitor(); _accounts = (Dictionary <string, IActorRef>)offer.Snapshot; _log.Info($"Snapshot recovered."); }
private void OnSnapshotOffer(SnapshotOffer offer) { OnRecoveredSnapshot(offer.Snapshot); }
/// <summary> /// When we are asked to recover from a snapshot, it should be our state object. /// </summary> /// <param name="offer">Offer.</param> private void OnRecoverSnapshotOffer(SnapshotOffer offer) { _heldValue = offer.Snapshot as string; }
private void ApplySnapShot(SnapshotOffer offer) { _accountState = (AccountState)offer.Snapshot; _log.Debug($"Snapshot recovered."); }
private void SnapshotOffered(SnapshotOffer snapshotOffer) { SetDeliverySnapshot((Akka.Persistence.AtLeastOnceDeliverySnapshot)snapshotOffer.Snapshot); }
private void RecoverSnapshot(SnapshotOffer offer) { _log.Debug("AccountGenerator - Processing RecoverSnapshot"); AccountList = (List <string>)offer.Snapshot; }
private void ApplySnapShot(SnapshotOffer offer) { _accountState = (AccountState)offer.Snapshot; //_log.Info($"{Self.Path.Name} Snapshot recovered."); }
private void SnapshotOffered(SnapshotOffer snapshotOffer) { retailSaleProcessState = (RetailSaleProcessState)snapshotOffer.Snapshot; }
private void SnapshotOffered(SnapshotOffer snapshotOffer) { Document = (Document)snapshotOffer.Snapshot; }