In my long-running build system that uses SolrJ, I have been looking
into reusing HttpClient and connection managers. This snippet is the
latest iteration of my initialization code for an individual core, based
on what I've been able to figure out with Google:
_mgr = new MultiThreadedHttpConnectionManager();
_mgr.getParams().setTcpNoDelay(true);
_client = new HttpClient();
_solrServer = new CommonsHttpSolrServer(serverBaseUrl, _client);
_solrCore = new CommonsHttpSolrServer(coreBaseUrl, _client);
I am not reusing these objects, so there are copies every one of my core
objects, of which I have 28. Half of those are build cores that only
get used during a full rebuild, leaving 14 of them that get used regularly.
Three questions: 1) Is it safe to reuse a single _mgr and _client
across all 28 cores? The cores are not all on the same machine. 2)
Would you recommend any other explicit options to make it more efficient
in terms of memory and/or speed?
I think the answer to question 1 is yes, just looking for absolute
confirmation.
Thanks,
Shawn