Esempio n. 1
0
 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;
        }
Esempio n. 4
0
 private bool Recover(SnapshotOffer offer)
 {
     if (offer.Snapshot is SchedulerState <TJob, TIdentity> state)
     {
         State = state;
     }
     return(true);
 }
Esempio n. 5
0
 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));
     }
 }
Esempio n. 9
0
 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}");
     }
 }
Esempio n. 10
0
        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}.");
            }
        }
Esempio n. 11
0
 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);
     }
 }
Esempio n. 12
0
        protected virtual bool Recover(SnapshotOffer aggregateSnapshotOffer)
        {
            try
            {
                State = aggregateSnapshotOffer.Snapshot as TState;
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Esempio n. 13
0
        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.");
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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)
            {
            }
        }
Esempio n. 16
0
        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;
        }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
 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);
 }
Esempio n. 20
0
        /// <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}");
            }
        }
Esempio n. 21
0
        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;
 }
Esempio n. 23
0
 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);
 }
Esempio n. 25
0
 /// <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;
 }
Esempio n. 26
0
 private void ApplySnapShot(SnapshotOffer offer)
 {
     _accountState = (AccountState)offer.Snapshot;
     _log.Debug($"Snapshot recovered.");
 }
Esempio n. 27
0
 private void SnapshotOffered(SnapshotOffer snapshotOffer)
 {
     SetDeliverySnapshot((Akka.Persistence.AtLeastOnceDeliverySnapshot)snapshotOffer.Snapshot);
 }
Esempio n. 28
0
 private void RecoverSnapshot(SnapshotOffer offer)
 {
     _log.Debug("AccountGenerator - Processing RecoverSnapshot");
     AccountList = (List <string>)offer.Snapshot;
 }
Esempio n. 29
0
 private void ApplySnapShot(SnapshotOffer offer)
 {
     _accountState = (AccountState)offer.Snapshot;
     //_log.Info($"{Self.Path.Name} Snapshot recovered.");
 }
Esempio n. 30
0
 private void SnapshotOffered(SnapshotOffer snapshotOffer)
 {
     retailSaleProcessState = (RetailSaleProcessState)snapshotOffer.Snapshot;
 }
 private void OnRecover(SnapshotOffer snapshot)
 {
     _state = (GreeterState)snapshot.Snapshot;
 }
Esempio n. 32
0
 private void SnapshotOffered(SnapshotOffer snapshotOffer)
 {
     Document = (Document)snapshotOffer.Snapshot;
 }