Hi all,

I agree with Sachin.

It makes sense to break out some logic into separate classes, but you need to 
be careful not to leak state from different threads or tasks into each other. 
The easiest way to do this is to just instantiate your utilities in the 
Processor init. Then, you’ll be sure that each processor instance has its own 
independent scope, and you’ll also have the stores available. Don’t forget to 
clean up your utilities in the Processor close if necessary. Processors will be 
closed and re-initialized some times, and need to be able to have a clean slate 
in that case. 

Hope this helps!
-john

On Tue, Mar 10, 2020, at 01:38, Sachin Mittal wrote:
> Well I can suggest is that you can access state store via processor's
> context.
> Once you have the reference of the state store it can be passed to
> different classes via the same reference.
> 
> 
> On Tue, Mar 10, 2020 at 8:57 AM Navneeth Krishnan <reachnavnee...@gmail.com>
> wrote:
> 
> > Hi John,
> >
> > I'm using PAPI to create my topology which has 5 process functions. Out
> > which 3 are large functions (more than 1000 lines of code) and they have
> > about 2 KV stores each. Since the code is fairly large per function, I have
> > them split into classes by functionalities. and some method in the call
> > stack would need to access this state. What do you recommend in such
> > scenarios?
> >
> > Thanks
> >
> > On Mon, Mar 9, 2020 at 6:41 PM John Roesler <vvcep...@apache.org> wrote:
> >
> > > Hi Navneeth,
> > >
> > > This sounds like an unusual use case. Can you provide more information on
> > > why this is required?
> > >
> > > Thanks,
> > > John
> > >
> > > On Mon, Mar 9, 2020, at 12:48, Navneeth Krishnan wrote:
> > > > Hi All,
> > > >
> > > > Any suggestions?
> > > >
> > > > Thanks
> > > >
> > > > On Sat, Mar 7, 2020 at 10:13 AM Navneeth Krishnan <
> > > reachnavnee...@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi All,
> > > > >
> > > > > Is there a recommended way of passing state stores around across
> > > different
> > > > > classes? The problem is state store can be fetched only if you have
> > > access
> > > > > to the context and in most of the scenarios look up to state store
> > > > > somewhere inside another class. I can think of two options. Either
> > add
> > > > > state store to thread local and access it or split the logic into
> > > multiple
> > > > > functions to fit everything inside an operator. But I wanted to check
> > > if
> > > > > there is any better or recommended approach.
> > > > >
> > > > > Thanks
> > > > >
> > > >
> > >
> >
>

Reply via email to