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:[email protected]] Sent: Wednesday, January 11, 2012 3:53 AM To: [email protected] 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 , <[email protected]> <[email protected]> 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 [[email protected]] > Sent: Tuesday, January 03, 2012 12:55 PM > To: [email protected] > 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: [email protected] For > additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] For > additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
