首页 > 代码库 > HttpSolrServer 实例管理参考,来自org.eclipse.smila.solr
HttpSolrServer 实例管理参考,来自org.eclipse.smila.solr
http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/core/org.eclipse.smila.solr/code/为什么要对实例管理?看看wiki文档说明就知道了。
/*
HttpSolrServer is thread-safe and if you are using the following constructor,
you *MUST* re-use the same instance for all requests. If instances are created on
the fly, it can cause a connection leak. The recommended practice is to keep a
static instance of HttpSolrServer per solr server url and share it for all requests.
See https://issues.apache.org/jira/browse/SOLR-861 for more details
*/
HttpSolrServer is thread-safe and if you are using the following constructor,
you *MUST* re-use the same instance for all requests. If instances are created on
the fly, it can cause a connection leak. The recommended practice is to keep a
static instance of HttpSolrServer per solr server url and share it for all requests.
See https://issues.apache.org/jira/browse/SOLR-861 for more details
*/
goole翻译,我理解的大概意思是:HttpSolrServer是线程安全的,保持每台Solr服务器的的URL HttpSolrServer静态实例能防止连接泄漏,性能也有提升,节省了资源开销。
google上找来一个开源代码,虽然他们用的solr不是最新版4.0。但是模式可以借鉴。
看了看这个SolrServer Manager类的代码,我是觉得不错,就拿来使用了
http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/core/org.eclipse.smila.solr/code/src/org/eclipse/smila/solr/SolrManager.java
发链接,不贴代码了,没有格式,太难看了
http://dev.eclipse.org/svnroot/rt/org.eclipse.smila/trunk/core/
这个链接里的东西都是宝物哦,赶紧行动吧!
一个简单问答
stackoverflow - Solr - instantiate HttpSolrServer with Httpclient
HttpSolrServer 实例管理参考,来自org.eclipse.smila.solr
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。