Invoke and serialization

classic Classic list List threaded Threaded
2 messages Options
Mikael Mikael
Reply | Threaded
Open this post in threaded view
|

Invoke and serialization

Hi!

I use invoke a lot on some caches and the code is not that small, would
it be ok to put some of the code in a static method in some other class
so I don''t need to send it over the network all the time, so the actual
invoke is very small and just call a static method in some other class,
it looks like it working fine and static method should be handled as
transient I guess, but I though I would ask so I don't run into some
nasty problem later.

Mikael


ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Invoke and serialization

Hello!

No.

Actually, invoke is not going to send your code over the network more than once.

However, invoke is going to send all bound variables together with your closure. If it is a lambda, it will often enclose "this", potentially sending a lot of data to server.

To avoid this, consider always using an instance of inner static class (or top-level class) with invoke. Then you can carefully pick which context it needs to carry with it. All the things it can get on the remote node without sending over, should be handled in that fashion.

And no, this won't cause problems. This is the right way to do.

Regards,
--
Ilya Kasnacheev


сб, 23 нояб. 2019 г. в 13:46, Mikael <[hidden email]>:
Hi!

I use invoke a lot on some caches and the code is not that small, would
it be ok to put some of the code in a static method in some other class
so I don''t need to send it over the network all the time, so the actual
invoke is very small and just call a static method in some other class,
it looks like it working fine and static method should be handled as
transient I guess, but I though I would ask so I don't run into some
nasty problem later.

Mikael