These are chat archives for akkadotnet/akka.net

15th
Mar 2018
Havret
@Havret
Mar 15 2018 08:34
It seems the right way to address this issue is to properly manipulate snapshot-after flag and Akka keep my db neat and tidy.
I have seen that in Lighthouse project you decided to move Akka hocon configuration from app.config to separate akka.hocon file. Is this the new recommended way of dealing with configuration in Akka project?
Ulimo
@Ulimo
Mar 15 2018 08:51
In DistributedData.Replicator, is there any event for subscribers to know when the durable store have been successfully loaded?
Ondrej Pialek
@ondrejpialek
Mar 15 2018 09:49
@Havret it would stop the child actor. if it did not persist anything this actor won't pollute. if you are worried about shard coordination causing DB issues you might want to look into using distributed data for your shard orchestration, does not persist anything to the DB. Works fine for us :)
Onur Gumus
@OnurGumus
Mar 15 2018 11:20
I have a timer in my PersistentFSM set by using ForMax. However on recovery I cannot find a way to set the state or set the timer again. Any one knows ?
Havret
@Havret
Mar 15 2018 11:22
@OnurGumus You can override OnReplaySuccess()
Onur Gumus
@OnurGumus
Mar 15 2018 11:22
then ?
Havret
@Havret
Mar 15 2018 11:23
And then do what you please based on recovered state, eg. set your timer again.
Onur Gumus
@OnurGumus
Mar 15 2018 11:24
the thing is PersistentFSM doesn't allow me to set the state or timer via its api
Havret
@Havret
Mar 15 2018 11:25
It does. PersistentFSM preserve its state by applying events in ApplyEvent method.
Onur Gumus
@OnurGumus
Mar 15 2018 11:25
it calls AppyEvent for all the events and all state changes on recovery.
I can apply event to restore the "StateData" but I cannot alter the the "State"
As I said I cannot find any API to alter the "State"
this.ApplyState doesn't work
  protected override object ApplyEvent(object domainEvent, object currentData)
        {
            if(domainEvent is RecoveryCompleted)
            {
                this.ApplyState(this.GoTo(new NextState()).ForMax(TimeSpan.FromSeconds(5)));

            }
            return currentData;

        }
I have this code
doesn't work
Havret
@Havret
Mar 15 2018 11:29
And it is a god thing. It would be horrible if you could manipulate state inside ApplyEvent.
Onur Gumus
@OnurGumus
Mar 15 2018 11:30
So where should I do OnReplySuccess?
Havret
@Havret
Mar 15 2018 11:31
It's Persistent FSM base method which you can override and do sth when all events are replayed.
chipdice
@chipdice
Mar 15 2018 11:34
Does anyone have any ideas on how would I go about handling the following? I have actor A, sending messages to Actor B. I want B to distribute processing of the message across multiple children and process the results from them before accepting the next message from actor Actor A.
Onur Gumus
@OnurGumus
Mar 15 2018 11:34
@Havret which FSM Base method you reer to ?
@chipdice just call Ask from B to its children and await the task.
chipdice
@chipdice
Mar 15 2018 11:38
Thanks @Havret, I guess there's no point in having actor B doing anything else until the children process everything is there?
Onur Gumus
@OnurGumus
Mar 15 2018 11:51
@Havret nothing works
Onur Gumus
@OnurGumus
Mar 15 2018 12:15
@Havret I was able to recover the state by below code:
     protected override bool ReceiveRecover(object message)
        {
           switch (message)
            {
                case RecoveryCompleted e:
                    this.OnRecoveryCompleted();
                    break;
                case StateChangeEvent e:
                    this.StartWith(dict[e.StateIdentifier],this.StateData,e.Timeout);
                    break;
                default:
                    this.StartWith(this.StateName, this.ApplyEvent(message,this.StateData));
                    break;

            }
            return true;
        }
however timeout doesn't do anything with StartWith
even used from regular code from ctor.
Havret
@Havret
Mar 15 2018 12:20
But do you know that State is preserved for you transparently and your state machine will be restored in state you left it?
Bartosz Sypytkowski
@Horusiath
Mar 15 2018 12:54

In DistributedData.Replicator, is there any event for subscribers to know when the durable store have been successfully loaded?

@Ulimo durable store is not officially supported at this moment (it's possible to use it, but it's bleeding edge and the binary representation of CRDTs will change in the future).

Ulimo
@Ulimo
Mar 15 2018 12:59
@Horusiath Ok! If I use the DurableDataEnvelope serializer, I wont have problems atleast in the code? Only that the binary data stored have to be cleared later on?
Havret
@Havret
Mar 15 2018 14:57
@Horusiath Is there any way to send a message to all entities which are managed by a certain shard?
Bartosz Sypytkowski
@Horusiath
Mar 15 2018 15:46
@Ulimo you shouldn't at the moment (but I won't guarantee that ;) ), just keep in mind that this serializer format will change
Ulimo
@Ulimo
Mar 15 2018 15:47
@Horusiath okok! It seems to work fine so far anyway so good job with it! :)
Bartosz Sypytkowski
@Horusiath
Mar 15 2018 15:50
@Havret you can send message to are entities managed by a certain shard, which are currently alive - var shardState = await shard.Ask<CurrentShardState>(Shard.GetCurrentShardState.Instance). The response contains list of currently alive shards. Shard actor itself is a Parent of a given entity.
Onur Gumus
@OnurGumus
Mar 15 2018 19:35
@Havret state is not preserved transparently
When I give a timeout to StartWith inPersistentFSM nothing happens. Does anyone know why?
Bartosz Sypytkowski
@Horusiath
Mar 15 2018 19:46
@OnurGumus can you tell, what do you need (not what are you trying to do) and what code are you using so far?
Onur Gumus
@OnurGumus
Mar 15 2018 19:48
I need to use a persistentfsm. If I stay on a particular state for some known duration it should notify me. Also this should be recoverable after a crash
There are two places you can set time out
StartWith s third param and Formax method
StarthWith time out seems to do nothing but Formax Works
However by default if a persistent fsm is crashed after recovery is completed. You end up with startstate but y default
The above code I posted solves that problem. But time out doesn't mean work
Onur Gumus
@OnurGumus
Mar 15 2018 19:54
Strange, my code is same with the original code almost
Bartosz Sypytkowski
@Horusiath
Mar 15 2018 20:05
@OnurGumus are you ever applying SaveStateSnapshot or Applying methods?
Onur Gumus
@OnurGumus
Mar 15 2018 20:07
For my test cases I just switch states with goto
Let's go one by one
StartWith(..., timout) does nothing
Bartosz Sypytkowski
@Horusiath
Mar 15 2018 20:16
  1. State changes won't be stored just by using GoTo - persistent FSM uses eventsourcing for state management, so an event must be emitted (in case of PersistentFSM, using Applying method).
  2. StartWith timeout will send StateTimeout message to an actor itself, when timeout triggers.
Onur Gumus
@OnurGumus
Mar 15 2018 20:17
For 1. I can still see statechangeevents coming to apply
2 Maybe but I can't observe that behavior
Onur Gumus
@OnurGumus
Mar 15 2018 20:33
Do we have symbols for akka on SymbolSource or else ?
Onur Gumus
@OnurGumus
Mar 15 2018 20:55
@Horusiath that timeout never triggers
Onur Gumus
@OnurGumus
Mar 15 2018 21:03
however this works : this.SetStateTimeout(start, TimeSpan.FromSeconds(5));
looks like a bug
it calls startwith once more on initialize and your time is gone forever
oh
it happens because in mycase TEvent is obj
and RecoveryCompleted somehow treated as a regular event
so that's why
I would still think this is a bug. is TEvent check must be done last.
Onur Gumus
@OnurGumus
Mar 15 2018 22:07
okay now it works