lamber-ken has an open PR (https://github.com/apache/flink/pull/6247) that 
touches AsyncIOExample.java
Do we need a new JIRA for the code cleanup that Chesnay recommends, or it can 
be done as part of the open PR and [FLINK-9730]?

-----Original Message-----
From: Chesnay Schepler [mailto:ches...@apache.org] 
Sent: Friday, July 06, 2018 9:48 AM
To: dev@flink.apache.org; NEKRASSOV, ALEXEI <an4...@att.com>
Subject: Re: AsyncIOExample.SampleAsyncFunction

Correct, either counter must be made static, or both the executorService and 
random non-static (which makes the counter unnecessary).

For an example I would regard the latter as preferable to ensure that instances 
don't interfere with each other.

As for your question, for a given instance open() is only called once.

On 06.07.2018 15:33, NEKRASSOV, ALEXEI wrote:
> Hi,
>
> I'm confused by lines 119-122 in 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_lamber
> -2Dken_flink_blob_master_flink-2Dexamples_flink-2Dexamples-2Dstreaming
> _src_main_java_org_apache_flink_streaming_examples_async_AsyncIOExampl
> e.java&d=DwIC-g&c=LFYZ-o9_HUMeMTSQicvjIg&r=aQRKg6d5fsz42zXkyiSdqg&m=RT
> zuiSDtbxSzoxN4e8SVXe_9P98uwErtCNTsIkmo8mA&s=g3gULphIulq5DR0OQ0DCJ2b7Bf
> 4J57egsNKxqgC2-sA&e=
>
> Why is counter non-static, but executorService and random - static?
>
> It's not clear to me whether open() can be called more than once on a given 
> object, and thus it's not clear whether the intent is to count the number of 
> open's for every object (the current code). Or we really need to make counter 
> static - to count the number of objects that share executorService and 
> random?..
>
> Having executorService and random as static, but counter as instance-specific 
> will not work when someone creates a second instance of SampleAsyncFunction. 
> In second SampleAsyncFunction the counter will be 0 and we will re-intialize 
> static executorService and random, thus interfering with the first 
> SampleAsyncFunction object.
>
> Thanks,
> Alex
>
>
>

Reply via email to