Re: Apache Flink - Question about thread safety for stateful collections (MapState)

2017-11-12 Thread Kien Truong
Hello M Singh, If you check the comment at the beginning of the file, it said Forwarding elements, watermarks, or status status elements must be protected by synchronizing * on the given lock object. This ensures that we don't call methods on a * {@link OneInputStreamOperator} conc

Re: Apache Flink - Question about thread safety for stateful collections (MapState)

2017-11-12 Thread M Singh
Thanks Kien/Jorn:   I see the code for processElement being called with a lock but did not see that the timer based invocation is synchronized by the same lock.  Does that mean that I should use synchonization in my code and how will that impact the performance ?  Please let me know if you have

Re: Apache Flink - Question about thread safety for stateful collections (MapState)

2017-11-12 Thread Jörn Franke
Be careful though with racing conditions . > On 12. Nov 2017, at 02:47, Kien Truong wrote: > > Hi Mans, > > They're not executed in the same thread, but the methods that called them are > synchronized[1] and therefore thread-safe. > > Best regards, > > Kien > > [1] > https://github.com/apa

Re: Apache Flink - Question about thread safety for stateful collections (MapState)

2017-11-11 Thread Kien Truong
Hi Mans, They're not executed in the same thread, but the methods that called them are synchronized[1] and therefore thread-safe. Best regards, Kien [1] https://github.com/apache/flink/blob/1cd3ba3f2af454bc33f2c880163c014d1738/flink-streaming-java/src/main/java/org/apache/flink/streamin

Apache Flink - Question about thread safety for stateful collections (MapState)

2017-11-11 Thread M Singh
Hi: I am working on a project and need to save MapState in a process function and register a timer to check for updates.  I wanted to find out if it is safe to access and modify the state in the processElement function as well as the time  onTimer methods.   The example  https://ci.apache.org/pro