You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ka...@nokia.com on 2011/12/20 13:19:13 UTC

Solr plugin component resource cleanup?

Is there a preferred time/manner for a Solr component (e.g. a SearchComponent) to clean up resources that have been allocated during the time of its existence, other than via a finalizer?  There seems to be nothing for this in the NamedListInitializedPlugin interface, and yet if you allocate a resource the test framework warns you about it.

Karl

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Solr plugin component resource cleanup?

Posted by ka...@nokia.com.
Thanks, Erik, this is not ideal but it will work for my purposes.  But it seems a shame that the whole SolrCoreAware setup as it was designed turned out to be so problematic.

Karl

-----Original Message-----
From: ext Erik Hatcher [mailto:erik.hatcher@gmail.com] 
Sent: Wednesday, January 11, 2012 3:53 AM
To: dev@lucene.apache.org
Subject: Re: Solr plugin component resource cleanup?

Karl - you can get the core from SolrQueryRequest#getCore(), with SolrQueryRequest being passed into QParserPlugin#createParser.

	Erik


On Jan 11, 2012, at 01:29 , <ka...@nokia.com> <ka...@nokia.com> wrote:

> "SolrCoreAware" and "CloseHook" are related in that you need a SolrCore object in order to call SolrCore.addCloseHook().  Indeed, the javadoc for the CloseHook interface states that the expected way you are supposed to use this in a plugin is via something like this:
> 
> public void inform(SolrCore core)
> {
>  core.addCloseHook(new MyCloseHookInstance()); }
> 
> If you have another way I can get hold of the right SolrCore object from within a QParserPlugin, please let me know.  I've opened SOLR-3015 to track this issue.
> 
> Karl
> 
> ________________________________________
> From: ext Chris Hostetter [hossman_lucene@fucit.org]
> Sent: Tuesday, January 03, 2012 12:55 PM
> To: dev@lucene.apache.org
> Subject: RE: Solr plugin component resource cleanup?
> 
> : This works fine for a SearchComponent, but if I try this for a QParserPlugin I get the following:
> :
> :     [junit] org.apache.solr.common.SolrException: Invalid 'Aware'
> : object: org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 --
> : org.apache.solr.util.plugin.SolrCoreAware must be an instance of:
> 
> ...that seems like an orthoginal problem to what i suggested...
> 
> : take a look at the "CloseHook" API and SolrCore.addCloseHook(...)
> :
> : : Is there a preferred time/manner for a Solr component (e.g. a
> : : SearchComponent) to clean up resources that have been allocated 
> during
> : : the time of its existence, other than via a finalizer?  There 
> seems to
> 
> 
> ...any object can call SolrCore.addCloseHook, regardless of wether or 
> not that class implements SolrCoreAware (two ideas are unrelated).  
> The list of classes that implement SolrCoreAware has always been 
> limited to prevent circular lifecycle problems.
> 
> what type of resouces are you trying to clean up?  are they really 
> specific to the initialization of the QParserPlugin (which shoulds 
> *VERY* unusual), or to the QParsers that it creates? because you can 
> always call addCloseHook in the createParser method.
> 
> 
> 
> -Hoss
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For 
> additional commands, e-mail: dev-help@lucene.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For 
> additional commands, e-mail: dev-help@lucene.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Solr plugin component resource cleanup?

Posted by Erik Hatcher <er...@gmail.com>.
Karl - you can get the core from SolrQueryRequest#getCore(), with SolrQueryRequest being passed into QParserPlugin#createParser.

	Erik


On Jan 11, 2012, at 01:29 , <ka...@nokia.com> <ka...@nokia.com> wrote:

> "SolrCoreAware" and "CloseHook" are related in that you need a SolrCore object in order to call SolrCore.addCloseHook().  Indeed, the javadoc for the CloseHook interface states that the expected way you are supposed to use this in a plugin is via something like this:
> 
> public void inform(SolrCore core)
> {
>  core.addCloseHook(new MyCloseHookInstance());
> }
> 
> If you have another way I can get hold of the right SolrCore object from within a QParserPlugin, please let me know.  I've opened SOLR-3015 to track this issue.
> 
> Karl
> 
> ________________________________________
> From: ext Chris Hostetter [hossman_lucene@fucit.org]
> Sent: Tuesday, January 03, 2012 12:55 PM
> To: dev@lucene.apache.org
> Subject: RE: Solr plugin component resource cleanup?
> 
> : This works fine for a SearchComponent, but if I try this for a QParserPlugin I get the following:
> :
> :     [junit] org.apache.solr.common.SolrException: Invalid 'Aware'
> : object: org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 --
> : org.apache.solr.util.plugin.SolrCoreAware must be an instance of:
> 
> ...that seems like an orthoginal problem to what i suggested...
> 
> : take a look at the "CloseHook" API and SolrCore.addCloseHook(...)
> :
> : : Is there a preferred time/manner for a Solr component (e.g. a
> : : SearchComponent) to clean up resources that have been allocated during
> : : the time of its existence, other than via a finalizer?  There seems to
> 
> 
> ...any object can call SolrCore.addCloseHook, regardless of wether or not
> that class implements SolrCoreAware (two ideas are unrelated).  The list
> of classes that implement SolrCoreAware has always been limited
> to prevent circular lifecycle problems.
> 
> what type of resouces are you trying to clean up?  are they really
> specific to the initialization of the QParserPlugin (which shoulds *VERY*
> unusual), or to the QParsers that it creates? because you can always call
> addCloseHook in the createParser method.
> 
> 
> 
> -Hoss
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Solr plugin component resource cleanup?

Posted by ka...@nokia.com.
"SolrCoreAware" and "CloseHook" are related in that you need a SolrCore object in order to call SolrCore.addCloseHook().  Indeed, the javadoc for the CloseHook interface states that the expected way you are supposed to use this in a plugin is via something like this:

public void inform(SolrCore core)
{
  core.addCloseHook(new MyCloseHookInstance());
}

If you have another way I can get hold of the right SolrCore object from within a QParserPlugin, please let me know.  I've opened SOLR-3015 to track this issue.

Karl

________________________________________
From: ext Chris Hostetter [hossman_lucene@fucit.org]
Sent: Tuesday, January 03, 2012 12:55 PM
To: dev@lucene.apache.org
Subject: RE: Solr plugin component resource cleanup?

: This works fine for a SearchComponent, but if I try this for a QParserPlugin I get the following:
:
:     [junit] org.apache.solr.common.SolrException: Invalid 'Aware'
: object: org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 --
: org.apache.solr.util.plugin.SolrCoreAware must be an instance of:

...that seems like an orthoginal problem to what i suggested...

: take a look at the "CloseHook" API and SolrCore.addCloseHook(...)
:
: : Is there a preferred time/manner for a Solr component (e.g. a
: : SearchComponent) to clean up resources that have been allocated during
: : the time of its existence, other than via a finalizer?  There seems to


...any object can call SolrCore.addCloseHook, regardless of wether or not
that class implements SolrCoreAware (two ideas are unrelated).  The list
of classes that implement SolrCoreAware has always been limited
to prevent circular lifecycle problems.

what type of resouces are you trying to clean up?  are they really
specific to the initialization of the QParserPlugin (which shoulds *VERY*
unusual), or to the QParsers that it creates? because you can always call
addCloseHook in the createParser method.



-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Solr plugin component resource cleanup?

Posted by Chris Hostetter <ho...@fucit.org>.
: This works fine for a SearchComponent, but if I try this for a QParserPlugin I get the following:
: 
:     [junit] org.apache.solr.common.SolrException: Invalid 'Aware' 
: object: org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 -- 
: org.apache.solr.util.plugin.SolrCoreAware must be an instance of: 

...that seems like an orthoginal problem to what i suggested...

: take a look at the "CloseHook" API and SolrCore.addCloseHook(...)
: 
: : Is there a preferred time/manner for a Solr component (e.g. a
: : SearchComponent) to clean up resources that have been allocated during
: : the time of its existence, other than via a finalizer?  There seems to


...any object can call SolrCore.addCloseHook, regardless of wether or not 
that class implements SolrCoreAware (two ideas are unrelated).  The list 
of classes that implement SolrCoreAware has always been limited  
to prevent circular lifecycle problems.

what type of resouces are you trying to clean up?  are they really 
specific to the initialization of the QParserPlugin (which shoulds *VERY* 
unusual), or to the QParsers that it creates? because you can always call 
addCloseHook in the createParser method.



-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Solr plugin component resource cleanup?

Posted by ka...@nokia.com.
I created a ticket for this: SOLR-3015.  I hope there's a simple solution and I can just close it, but if not I will experiment and try to produce a patch.

Karl

________________________________________
From: Wright Karl (Nokia-LC/Boston)
Sent: Monday, January 02, 2012 11:02 AM
To: dev@lucene.apache.org
Subject: RE: Solr plugin component resource cleanup?

This works fine for a SearchComponent, but if I try this for a QParserPlugin I get the following:

    [junit] org.apache.solr.common.SolrException: Invalid 'Aware' object: org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 -- org.apache.solr.util.plugin.SolrCoreAware must be an instance of: [org.apache.solr.request.SolrRequestHandler]
[org.apache.solr.response.QueryResponseWriter] [org.apache.solr.handler.component.SearchComponent] [org.apache.solr.update.processor.UpdateRequestProcessorFactory] [org.apache.solr.handler.component.ShardHandlerFactory]

Any further suggestions?

Karl

________________________________________
From: ext Chris Hostetter [hossman_lucene@fucit.org]
Sent: Tuesday, December 27, 2011 7:19 PM
To: dev@lucene.apache.org
Subject: Re: Solr plugin component resource cleanup?

take a look at the "CloseHook" API and SolrCore.addCloseHook(...)

: Is there a preferred time/manner for a Solr component (e.g. a
: SearchComponent) to clean up resources that have been allocated during
: the time of its existence, other than via a finalizer?  There seems to
: be nothing for this in the NamedListInitializedPlugin interface, and yet
: if you allocate a resource the test framework warns you about it.


-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


RE: Solr plugin component resource cleanup?

Posted by ka...@nokia.com.
This works fine for a SearchComponent, but if I try this for a QParserPlugin I get the following:

    [junit] org.apache.solr.common.SolrException: Invalid 'Aware' object: org.apache.solr.mcf.ManifoldCFQParserPlugin@18941f7 -- org.apache.solr.util.plugin.SolrCoreAware must be an instance of: [org.apache.solr.request.SolrRequestHandler]
[org.apache.solr.response.QueryResponseWriter] [org.apache.solr.handler.component.SearchComponent] [org.apache.solr.update.processor.UpdateRequestProcessorFactory] [org.apache.solr.handler.component.ShardHandlerFactory]

Any further suggestions?

Karl

________________________________________
From: ext Chris Hostetter [hossman_lucene@fucit.org]
Sent: Tuesday, December 27, 2011 7:19 PM
To: dev@lucene.apache.org
Subject: Re: Solr plugin component resource cleanup?

take a look at the "CloseHook" API and SolrCore.addCloseHook(...)

: Is there a preferred time/manner for a Solr component (e.g. a
: SearchComponent) to clean up resources that have been allocated during
: the time of its existence, other than via a finalizer?  There seems to
: be nothing for this in the NamedListInitializedPlugin interface, and yet
: if you allocate a resource the test framework warns you about it.


-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Re: Solr plugin component resource cleanup?

Posted by Chris Hostetter <ho...@fucit.org>.
take a look at the "CloseHook" API and SolrCore.addCloseHook(...)

: Is there a preferred time/manner for a Solr component (e.g. a 
: SearchComponent) to clean up resources that have been allocated during 
: the time of its existence, other than via a finalizer?  There seems to 
: be nothing for this in the NamedListInitializedPlugin interface, and yet 
: if you allocate a resource the test framework warns you about it.


-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org