ProcessingComponent life cycle

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

ProcessingComponent life cycle

eishay
I am using the ExecutorService using getExecutorService from ProcessingComponentBase. My application needs to ingrate with carrot lifecycle in order to clean up resources like the ExecutorService (I understand it will invoke the ExecutorServiceShutdownListener).

Can you please point me to how I can do that?

Thanks, Eishay
Reply | Threaded
Open this post in threaded view
|

Re: ProcessingComponent life cycle

Stanislaw Osinski
Administrator
Hi Eishay,

I am using the ExecutorService using getExecutorService from
ProcessingComponentBase. My application needs to ingrate with carrot
lifecycle in order to clean up resources like the ExecutorService (I
understand it will invoke the ExecutorServiceShutdownListener).

Can you please point me to how I can do that?

Looking quickly through the code, I think you don't need to worry about shutting down the executor service as such, this will be done automatically when the controller is disposed. If you need to do some custom clean-up in your component, just implement:

for component instance scope clean-up:
http://download.carrot2.org/stable/javadoc/org/carrot2/core/IProcessingComponent.html#dispose()

for request scope clean-up:
http://download.carrot2.org/stable/javadoc/org/carrot2/core/IProcessingComponent.html#afterProcessing()

Please let me know if this addresses your problem.

Cheers,

S.



------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: ProcessingComponent life cycle

eishay
Thanks Stanislaw, this is what I need. But looking at the code, STCClusteringAlgorithm extends ProcessingComponentBase and the both dispose() & afterProcessing() in the latter are not implemented so I wonder if and how the ExecutorService called by getSharedExecutor is being shutdown.
In other words I don't see how by calling IProcessingComponent.html#dispose() ControllerContextImpl#dispose() is called since this is the one that eventually shuts down the ExecutorService.

Thanks, Eishay
Reply | Threaded
Open this post in threaded view
|

Re: ProcessingComponent life cycle

Stanislaw Osinski
Administrator
Hi Eishay,
 
Thanks Stanislaw, this is what I need. But looking at the code,
STCClusteringAlgorithm extends ProcessingComponentBase and the both
dispose() & afterProcessing() in the latter are not implemented so I wonder
if and how the ExecutorService called by getSharedExecutor is being
shutdown.
In other words I don't see how by calling
IProcessingComponent.html#dispose() ControllerContextImpl#dispose() is
called since this is the one that eventually shuts down the ExecutorService.

ControllerContextImpl#dispose() is called when the controller itself is disposed (when your code calls IController#dispose()) and is not coupled in any way with IProcessingComponent.html#dispose(). The latter is for component-specific clean-up, but so far we don't have components that actually need this method for their specific clean-up tasks.

The main message is that you don't need to worry about shutting down the executor obtained from ProcessingComponentBase#getSharedExecutor() as long as you properly dispose of the controller you're using by calling IController#dispose() whenever appropriate.

Cheers,

S.

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers