我正在使用Hortonworks Distribution,并使用ambari服务器安装了solr Solr版本5.5.2
我使用创建了收藏
/opt/lucidworks-hdpsearch/solr/bin/solr create_collection -p 8983 -d data_driven_schema_configs -c eim_log -s 2 -rf 1
我使用下面的Java代码创建客户端并添加文档:
SolrClient solr = new CloudSolrClient("server1:2181,serve2:2181,server3:2181/solr");
SolrInputDocument doc = new SolrInputDocument();
doc.setField(field.message, event.getMessage());
doc.setField(field.stacktrace, formatBody(event));
doc.setField(field.applicationName, getApplicationName());
doc.setField(field.applicationId, getApplicationId());
UpdateResponse ur = solr.add(collectionName,doc,5000);
但是在将文档添加到集合时,它失败并显示以下错误:
19/01/15 00:33:38 INFO SolrZkClient: Using default ZkCredentialsProvider
Exception in thread "main" java.lang.StackOverflowError
at sun.util.locale.provider.LocaleProviderAdapter.getAdapter(LocaleProviderAdapter.java:243)
at java.text.DateFormatSymbols.getProviderInstance(DateFormatSymbols.java:357)
at java.text.DateFormatSymbols.getInstance(DateFormatSymbols.java:335)
at java.util.Calendar.getDisplayName(Calendar.java:2110)
at java.text.SimpleDateFormat.subFormat(SimpleDateFormat.java:1125)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:966)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)
at java.text.DateFormat.format(DateFormat.java:345)
at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:443)
at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:65)
at org.apache.log4j.PatternLayout.format(PatternLayout.java:506)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:310)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:305)
at org.apache.solr.common.cloud.SolrZkClient.createZkCredentialsToAddAutomatically(SolrZkClient.java:211)
at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:133)
at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:115)
at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:105)
at org.apache.solr.common.cloud.ZkStateReader.<init>(ZkStateReader.java:200)
at org.apache.solr.client.solrj.impl.CloudSolrClient.connect(CloudSolrClient.java:466)
at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:823)
at org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:806)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at com.hilton.eim.logger.solr.appender.SolrAppender.append(SolrAppender.java:108)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:305)
at org.apache.solr.common.cloud.SolrZkClient.createZkCredentialsToAddAutomatically(SolrZkClient.java:211)
at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:133)
at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:115)
at org.apache.solr.common.cloud.SolrZkClient.<init>(SolrZkClient.java:105)
at org.apache.solr.common.cloud.ZkStateReader.<init>(ZkStateReader.java:200)
at org.apache.solr.client.solrj.impl.CloudSolrClient.connect(CloudSolrClient.java:466)
at org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:823)
at org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:806)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:173)
at com.hilton.eim.logger.solr.appender.SolrAppender.append(SolrAppender.java:108)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
当我如下更改solr客户端时,相同的代码正在工作:
SolrClient solr = new HttpSolrClient(host)
非常感谢您的帮助。