use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project jackrabbit-oak by apache.
the class RemoteSolrServerProvider method getIndexingSolrServer.
@CheckForNull
@Override
public SolrClient getIndexingSolrServer() throws Exception {
SolrClient server = getSolrServer();
if (server instanceof HttpSolrClient) {
String url = ((HttpSolrClient) server).getBaseURL();
ConcurrentUpdateSolrClient concurrentUpdateSolrServer = new ConcurrentUpdateSolrClient(url, 1000, Runtime.getRuntime().availableProcessors());
concurrentUpdateSolrServer.setConnectionTimeout(remoteSolrServerConfiguration.getConnectionTimeout());
concurrentUpdateSolrServer.setSoTimeout(remoteSolrServerConfiguration.getSocketTimeout());
concurrentUpdateSolrServer.blockUntilFinished();
server = concurrentUpdateSolrServer;
}
return server;
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project solr-cmd-utils by tblsoft.
the class SolrFeeder method doFeed.
public void doFeed() throws Exception {
this.server = new ConcurrentUpdateSolrClient(serverUrl, queueSize, threads);
if (threads == 1 && queueSize == 1) {
this.server = new HttpSolrClient(serverUrl);
}
if (deleteIndex) {
System.out.println("Delete the index.");
server.deleteByQuery("*:*");
}
parse();
server.commit();
server.optimize();
server.close();
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project mycore by MyCoRe-Org.
the class MCRSolrMCRContentMapIndexHandler method index.
@Override
public void index() throws IOException, SolrServerException {
int totalCount = contentMap.size();
LOGGER.info("Handling {} documents", totalCount);
// multithread processing will result in too many http request
UpdateResponse updateResponse;
try {
Iterator<SolrInputDocument> documents = MCRSolrInputDocumentFactory.getInstance().getDocuments(contentMap);
SolrClient solrClient = getSolrClient();
if (solrClient instanceof ConcurrentUpdateSolrClient) {
// split up to speed up processing
splitup(documents);
return;
}
if (LOGGER.isDebugEnabled()) {
ArrayList<SolrInputDocument> debugList = new ArrayList<>();
while (documents.hasNext()) {
debugList.add(documents.next());
}
LOGGER.debug("Sending these documents: {}", debugList);
// recreate documents interator;
documents = debugList.iterator();
}
if (solrClient instanceof HttpSolrClient) {
updateResponse = solrClient.add(documents);
} else {
ArrayList<SolrInputDocument> docs = new ArrayList<>(totalCount);
while (documents.hasNext()) {
docs.add(documents.next());
}
updateResponse = solrClient.add(docs);
}
} catch (Throwable e) {
LOGGER.warn("Error while indexing document collection. Split and retry.", e);
splitup();
return;
}
if (updateResponse.getStatus() != 0) {
LOGGER.error("Error while indexing document collection. Split and retry: {}", updateResponse.getResponse());
splitup();
} else {
LOGGER.info("Sending {} documents was successful in {} ms.", totalCount, updateResponse.getElapsedTime());
}
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project lucene-solr by apache.
the class SolrExampleStreamingTest method createNewSolrClient.
@Override
public SolrClient createNewSolrClient() {
try {
// setup the server...
String url = jetty.getBaseUrl().toString() + "/collection1";
// smaller queue size hits locks more often
ConcurrentUpdateSolrClient concurrentClient = new ErrorTrackingConcurrentUpdateSolrClient(url, 2, 5);
concurrentClient.setParser(new XMLResponseParser());
concurrentClient.setRequestWriter(new RequestWriter());
return concurrentClient;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project lucene-solr by apache.
the class StreamingSolrClients method getSolrClient.
public synchronized SolrClient getSolrClient(final SolrCmdDistributor.Req req) {
String url = getFullUrl(req.node.getUrl());
ConcurrentUpdateSolrClient client = solrClients.get(url);
if (client == null) {
// NOTE: increasing to more than 1 threadCount for the client could cause updates to be reordered
// on a greater scale since the current behavior is to only increase the number of connections/Runners when
// the queue is more than half full.
client = new ErrorReportingConcurrentUpdateSolrClient(url, httpClient, 100, runnerCount, updateExecutor, true, req);
// minimize connections created
client.setPollQueueTime(Integer.MAX_VALUE);
client.setParser(new BinaryResponseParser());
client.setRequestWriter(new BinaryRequestWriter());
Set<String> queryParams = new HashSet<>(2);
queryParams.add(DistributedUpdateProcessor.DISTRIB_FROM);
queryParams.add(DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM);
client.setQueryParams(queryParams);
solrClients.put(url, client);
}
return client;
}
Aggregations