How to find whether solr server is running or not

半城伤御伤魂 提交于 2021-01-21 14:43:38

问题


I am running an application that get search results from solr server. But when server is not running i get no response from the server. Is there any way i can found that my server is not running so that i can give proper error message regarding it


回答1:


You could periodically ping your server (e.g. http://localhost:8983/solr/admin/ping) and in case of an error pass that message on to the frontend...




回答2:


If you have SolrServer object, just call SolrServer.ping() it throws exception if can't establish connection.




回答3:


If the server is not responding in a timely manner (solr) then you should consider representing it being down and present the error message regardless of whether it is or not (ie its taking a long time because its overloaded). If it takes forever to load its down to the user :)

Most solr clients have a timeout and an error callback of some sort. If the timeout happens then you show the error.

If you want to know very quickly that the server is down you can put a JSP on solr that does nothing but print out a message. Then do a HTTP GET to the JSP and if it doesn't come up very quickly then the server is down.




回答4:


You should probably use something like Nagios to monitor your hardware status. Nagios also has a nice plugin for solr that can help you.




回答5:


Seems like there should be a simple way to do this via HTTP, a generic on/off response from the server would be ideal. Short of that, one thing you could do is just GET host:port/solr and if you get any response other than 200 then assume it's down.



来源:https://stackoverflow.com/questions/6744747/how-to-find-whether-solr-server-is-running-or-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!