EricssonResearch / calvin-base

Calvin is an application environment that lets things talk to things, among other things.
Apache License 2.0
282 stars 91 forks source link

Issues with the migration of some actors (RecTimer, FileReader, FileWriter) #82

Closed brunodonassolo closed 7 years ago

brunodonassolo commented 7 years ago

Hello again,

Sending patch again...

I'm sending a possible second patch to fix some issues related to actors migration. This is a little bigger than the first one, so please don't hesitate to say me if there are things to improve (probably there is :)).

The errors happen when the actor (RecTimer, FileReader or FileWriter) is migrated from one runtime to another. RecTimer: the shorthander 'timer' is not initialized after migration. The method init() isn't called in a migrated actor, right? FileReader: A little similar, the variables aren't initialized correclty. FileWriter: It was missing the suffix parameter in 'manage' attributes. Also, after a migration the write_line start to fail because it tries to write a unicode string. So, I tried to convert it to utf-8 before writing in the file.

For the tests, I tried to follow the examples with migration but I put them in another file (it wasn't possible to include them because the original one uses some global variables to save the runtimes). They're not very complicated but fail without the changes.

Thanks in advance.

corn3liuz commented 7 years ago

Hi.

I've looked it over and I only had a couple comments:

FileReader: We like Actors to have a setup function which is called from init and did_migrate. FileWriter: Looks fine RecTimer: Looks fine, I just moved the call to calvinsys to the setup function. test_actors_migration: Some missing imports, otherwise fine.

I've made the changes and merged the files to develop.

Thanks Johan