On 9/9/2016 10:11 PM, Shawn Heisey wrote:
> On 9/9/2016 4:38 PM, Brent wrote:
>> Is there a way to tell whether or not a node at a specific address is
>> up using a SolrJ API? 
> Based on your other questions, I think you're running cloud. If that
> assumption is correct, use the Collections API with HttpSolrClient
> (instead of CloudSolrClient) to get a list of collections. Using
> HttpSolrClient will direct the request to that specific server. If it
> doesn't throw an exception, it's up. Here's some SolrJ code.

After reading a reply on a separate thread, I was reminded of the ping
handler.  That might seem like a good solution, but using the ping
handler would require that your code knows about a specific core on the
server, or that it knows the name of one of the SolrCloud collections. 
The collections admin request that I outlined previously will work
without the code needing any knowledge of what the cloud contains, .

SolrCloud can almost guarantee that any collection in the cloud will be
accessible from any node in the cloud if that node is functional ... but
if you want to extremely pedantic in your check, and you have a ping
handler defined in the config for the collection, you could use that
handler to make sure that the collection is functional as well as the
node.  To check that you can access a collection named "foo" from a
specific node, start with the code that I sent previously, and replace
the last two lines of code with these:

  SolrPing ping = new SolrPing().setActionPing();
  ping.process(client, "foo");

The SolrPing object assumes the ping handler is named "/admin/ping".  If
you have a ping handler with a different name/path, you should be able
to use the "setPath" method on the ping object to change it before doing
the "process" method.

Thanks,
Shawn

Reply via email to