使用Spring批处理索引30K记录后,Solr连接被拒绝错误

时间:2015-08-28 06:43:42

标签: solr spring-batch spring-data-solr

我有一个Spring批处理作业,它从csv文件中读取数据并将其插入到Solr中。作业运行正常,大约30k记录,但在此之后拒绝Solr连接错误。有人可以建议这里有什么问题吗?我使用的是Solr的5.2.1版本。

org.springframework.dao.DataAccessResourceFailureException: Connection to http://localhost:8983 refused; nested exception is org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8983 refused
    at org.springframework.data.solr.core.SolrExceptionTranslator.translateExceptionIfPossible(SolrExceptionTranslator.java:72)
    at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:143)
    at org.springframework.data.solr.core.SolrTemplate.saveBean(SolrTemplate.java:184)
    at org.springframework.data.solr.core.SolrTemplate.saveBean(SolrTemplate.java:178)
    at com.turvo.batch.carrier.writer.SolrWriter.write(SolrWriter.java:38)
    at org.springframework.batch.item.support.CompositeItemWriter.write(CompositeItemWriter.java:51)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.writeItems(SimpleChunkProcessor.java:175)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.doWrite(SimpleChunkProcessor.java:151)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.write(SimpleChunkProcessor.java:274)
    at org.springframework.batch.core.step.item.SimpleChunkProcessor.process(SimpleChunkProcessor.java:199)
    at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:75)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
    at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:271)
    at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
    at org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate$ExecutingRunnable.run(TaskExecutorRepeatTemplate.java:262)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:8983 refused
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
    at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:640)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
    at org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:448)
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
    at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
    at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:116)
    at org.springframework.data.solr.core.SolrTemplate$4.doInSolr(SolrTemplate.java:187)
    at org.springframework.data.solr.core.SolrTemplate$4.doInSolr(SolrTemplate.java:184)
    at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:141)
    ... 16 more
Caused by: java.net.ConnectException: Cannot assign requested address
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:127)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
    ... 30 more

Solr配置 -

<solr:repositories base-package="com.batch.repository" multicore-support="true"/>
<solr:solr-server id="solrServer" url="${solr.hosts}"/>

<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
    <constructor-arg ref="solrServer" />
    <constructor-arg name="core" value="${solr.core}" />
</bean>

1 个答案:

答案 0 :(得分:0)

从solr文档中,用于批量更新的服务器/客户端是http://lucene.apache.org/solr/5_2_1/solr-solrj/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.html。我在Spring Data中找不到相应的东西。