Re: [akka-user] Implementation of Persistent Actor with initial state

2016-10-15 Thread Patrik Nordwall
I think fsm has something similar to recovery completed

lör 15 okt. 2016 kl. 11:34 skrev Jakub Liska :

> Yes, that's what I meant.
>
> Perfect, it would work in Persistent Actor... What about PersistentFSM ?
> I guess that I will have to introduce an initial FSMState where I would
> check whether the persistent state is empty or it was recovered and act on
> that.
>
> Cool, thanks a lot Patrik !
>
>
>
> On Saturday, October 15, 2016 at 8:14:22 AM UTC+2, Patrik Nordwall wrote:
>
> I'm not sure I understand. You want to read the old data if the persistent
> actor doesn't have any events of its own?
>
> You can check the state when you get RecoveryCompleted. You can also count
> the events/snapshot in receiveRecover and act on that when
> RecoveryCompleted.
>
> /Patrik
>
> fre 14 okt. 2016 kl. 22:11 skrev Jakub Liska :
>
> Hey,
>
> what is the best practice to do in this hypothetical scenario :
> 1) Say you have a time series pipeline that started at 2014 and created
> persistent state on S3 and other DB systems
> 2) You can introspect these storages and know what partitions already
> exists in all of them
> 3) The persistent actor's job would be scheduling tasks for newly added
> partitions (next minute/hour/day, etc.)
> 3) Now at 2016 you deploy a persistent Actor that will hold state about
> completness (existing partitions) of these storages and keep up with their
> progress
>
> The way I see it, when this persistent Actor boots up, it will have 2
> choices :
> a) either it starts for the very first time, it will have to replay all
> DomainEvents for all historical partitions from 2014 to itself to
> initialize it's state to the current view of the world in 2016
> b) or it restarts or crashes and its state is replayed from the journal
> implicitly
>
> Now I cannot find any reference of how this should be done. The only
> solution that comes to mind is to use persistence-query and obtaining
> Journal :
>
>readJournal.currentPersistenceIds()
>readJournal.eventsByPersistenceId("user-us-1337")
>1.
>And if the result is empty, then it will reconstructs the history.
>
> Is this a way to go?
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+...@googlegroups.com.
> To post to this group, send email to akka...@googlegroups.com.
>
>
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Implementation of Persistent Actor with initial state

2016-10-15 Thread Jakub Liska
Yes, that's what I meant. 

Perfect, it would work in Persistent Actor... What about PersistentFSM ? 
I guess that I will have to introduce an initial FSMState where I would 
check whether the persistent state is empty or it was recovered and act on 
that.

Cool, thanks a lot Patrik !



On Saturday, October 15, 2016 at 8:14:22 AM UTC+2, Patrik Nordwall wrote:
>
> I'm not sure I understand. You want to read the old data if the persistent 
> actor doesn't have any events of its own?
>
> You can check the state when you get RecoveryCompleted. You can also count 
> the events/snapshot in receiveRecover and act on that when 
> RecoveryCompleted.
>
> /Patrik
>
> fre 14 okt. 2016 kl. 22:11 skrev Jakub Liska  >:
>
>> Hey,
>>
>> what is the best practice to do in this hypothetical scenario : 
>> 1) Say you have a time series pipeline that started at 2014 and created 
>> persistent state on S3 and other DB systems
>> 2) You can introspect these storages and know what partitions already 
>> exists in all of them
>> 3) The persistent actor's job would be scheduling tasks for newly added 
>> partitions (next minute/hour/day, etc.)
>> 3) Now at 2016 you deploy a persistent Actor that will hold state about 
>> completness (existing partitions) of these storages and keep up with their 
>> progress
>>
>> The way I see it, when this persistent Actor boots up, it will have 2 
>> choices :
>> a) either it starts for the very first time, it will have to replay all 
>> DomainEvents for all historical partitions from 2014 to itself to 
>> initialize it's state to the current view of the world in 2016 
>> b) or it restarts or crashes and its state is replayed from the journal 
>> implicitly
>>
>> Now I cannot find any reference of how this should be done. The only 
>> solution that comes to mind is to use persistence-query and obtaining 
>> Journal : 
>>
>>readJournal.currentPersistenceIds()
>>readJournal.eventsByPersistenceId("user-us-1337")
>>1. 
>>And if the result is empty, then it will reconstructs the history.
>>
>> Is this a way to go?
>>
>> -- 
>> >> Read the docs: http://akka.io/docs/
>> >> Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >> Search the archives: https://groups.google.com/group/akka-user
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to akka-user+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Implementation of Persistent Actor with initial state

2016-10-15 Thread Patrik Nordwall
I'm not sure I understand. You want to read the old data if the persistent
actor doesn't have any events of its own?

You can check the state when you get RecoveryCompleted. You can also count
the events/snapshot in receiveRecover and act on that when
RecoveryCompleted.

/Patrik

fre 14 okt. 2016 kl. 22:11 skrev Jakub Liska :

> Hey,
>
> what is the best practice to do in this hypothetical scenario :
> 1) Say you have a time series pipeline that started at 2014 and created
> persistent state on S3 and other DB systems
> 2) You can introspect these storages and know what partitions already
> exists in all of them
> 3) The persistent actor's job would be scheduling tasks for newly added
> partitions (next minute/hour/day, etc.)
> 3) Now at 2016 you deploy a persistent Actor that will hold state about
> completness (existing partitions) of these storages and keep up with their
> progress
>
> The way I see it, when this persistent Actor boots up, it will have 2
> choices :
> a) either it starts for the very first time, it will have to replay all
> DomainEvents for all historical partitions from 2014 to itself to
> initialize it's state to the current view of the world in 2016
> b) or it restarts or crashes and its state is replayed from the journal
> implicitly
>
> Now I cannot find any reference of how this should be done. The only
> solution that comes to mind is to use persistence-query and obtaining
> Journal :
>
>readJournal.currentPersistenceIds()
>readJournal.eventsByPersistenceId("user-us-1337")
>1.
>And if the result is empty, then it will reconstructs the history.
>
> Is this a way to go?
>
> --
> >> Read the docs: http://akka.io/docs/
> >> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.