Re: Detecting down node with SolrJ

2016-09-13 Thread Shawn Heisey
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



Re: Detecting down node with SolrJ

2016-09-10 Thread Erick Erickson
If you use Zookeeper you'll be fine if (and only if)
the node was shut down gracefully. In that case Zookeeper
should be completely current.

If someone just pulled the plug on a Solr node though,
you'll have to wait until Zookeeper times out when
pinging the Solr node, perhaps minutes.

If you do use Zookeeper, be sure you check
"live_nodes" as the state.json for
any particular collection may or may not be
updated promptly.

Best,
Erick

On Sat, Sep 10, 2016 at 8:03 AM, Rohit Kanchan <rohitkan2...@gmail.com> wrote:
> I think it is better to use zookeeper data. Solr Cloud updates zookeeper
> about node status. If you are using cloud then u can check zookeeper
> cluster api and get status of node from there. Zookeeper cluster state api
> can give you information about your Solr cloud. I hope this helps.
>
> Thanks
> Rohit Kanchan
>
>
> On Fri, Sep 9, 2016 at 3:38 PM, Brent <brent.pear...@gmail.com> wrote:
>
>> Is there a way to tell whether or not a node at a specific address is up
>> using a SolrJ API?
>>
>>
>>
>> --
>> View this message in context: http://lucene.472066.n3.
>> nabble.com/Detecting-down-node-with-SolrJ-tp4295402.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>


Re: Detecting down node with SolrJ

2016-09-10 Thread Rohit Kanchan
I think it is better to use zookeeper data. Solr Cloud updates zookeeper
about node status. If you are using cloud then u can check zookeeper
cluster api and get status of node from there. Zookeeper cluster state api
can give you information about your Solr cloud. I hope this helps.

Thanks
Rohit Kanchan


On Fri, Sep 9, 2016 at 3:38 PM, Brent <brent.pear...@gmail.com> wrote:

> Is there a way to tell whether or not a node at a specific address is up
> using a SolrJ API?
>
>
>
> --
> View this message in context: http://lucene.472066.n3.
> nabble.com/Detecting-down-node-with-SolrJ-tp4295402.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>


Re: Detecting down node with SolrJ

2016-09-09 Thread Shawn Heisey
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. 
You're going to need some exception handling that's not included here:

RequestConfig rc =
RequestConfig.custom().setConnectTimeout(5000).setSocketTimeout(5000)
.build();
HttpClient hc =
HttpClients.custom().setDefaultRequestConfig(rc).disableAutomaticRetries().build();
SolrClient client = new
HttpSolrClient("http://server:8983/solr;, hc);
CollectionAdminRequest.List req = new CollectionAdminRequest.List();
CollectionAdminResponse response = req.process(client);

I am setting the timeouts for HttpClient to five seconds so that the
request will time out relatively quick in the case where the server
isn't up, or where it's up but not functioning correctly.

Thanks,
Shawn



Detecting down node with SolrJ

2016-09-09 Thread Brent
Is there a way to tell whether or not a node at a specific address is up
using a SolrJ API?



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Detecting-down-node-with-SolrJ-tp4295402.html
Sent from the Solr - User mailing list archive at Nabble.com.