On 2/12/2013 12:27 PM, Chris Hostetter wrote:
: The problem is at program startup -- when 'new HttpSolrServer(url)' is called, : it goes and makes sure that the server is up and responsive. If any of those : 56 object creation calls fails, then my app won't even start. What exactly is the exception are you getting? i don't think anything in HttpSolrServer explicitly tries to test the server on creation. : Someone on the IRC channel brought up the possibility of initializing the : HttpClient myself instead of letting the Solr object do it. If the health : check is actually in HttpClient, this might work, if there's a way to : initialize the HttpClient without a health check. I've actually been : wondering if it makes any sense to re-use a single HttpClient object across : all 56 server objects. It probably would make sense for you to create a single HttpClient object that you re-use in all of your HttpSolrServer instances -- but i'm not sure how that would help your problem, since the HttpClient constructed implicitly by HttpSolrServer(String) doesn't know anything about the baseUrl. HttpClient literally can not test the health of the URL when it is created, because it doesn't know anything about any URLs until a request is executed.
I gathered up the exception, looked it over very closely ... and it's all my fault! User error all the way on this one.
In my code, as soon as I create the object, I make a call that gets the dataDir and instanceDir. I initially wrote this code so long ago that I had forgotten this fact.
I have now changed it so this query is only made when the information is requested, not when the object initializes. Aside: it turns out that nothing in my code actually USES those getter methods! Now my program will start up even if Solr is down. I'll look into re-using an http client on all objects.
Thanks for the prodding, Hoss! Shawn