Task slot data

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

Task slot data

Govindarajan Srinivasaraghavan
Hi,

I have a complex algorithm running on a flatmap operator and it requires cache and metrics instances to be passed to various classes. Since the task slots run on the same JVM, I'm not sure if I will be able to use static members or singleton classes. Can I use ThreadLocal variables to isolate the data on a task slot or is there any other approach? Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Task slot data

Till Rohrmann
Hi Govindarajan,

evert task is executed by exactly one thread. Thus, it should be fine to use Thread local variables. However be aware that a single Task can execute multiple operators if they are chained.

Cheers,
Till

On Wed, Aug 9, 2017 at 6:49 AM, Govindarajan Srinivasaraghavan <[hidden email]> wrote:
Hi,

I have a complex algorithm running on a flatmap operator and it requires cache and metrics instances to be passed to various classes. Since the task slots run on the same JVM, I'm not sure if I will be able to use static members or singleton classes. Can I use ThreadLocal variables to isolate the data on a task slot or is there any other approach? Thanks.