Java Code Examples for org.apache.solr.update.processor.UpdateRequestProcessor#processCommit()
The following examples show how to use
org.apache.solr.update.processor.UpdateRequestProcessor#processCommit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void commit() throws IOException { // avoid multiple commits and warming searchers commitAndRollbackLock.writeLock().lock(); try { canUpdate(); UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); processor.processCommit(new CommitUpdateCommand(request, false)); } finally { if (processor != null) { processor.finish(); } } } finally { commitAndRollbackLock.writeLock().unlock(); } }
Example 2
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void hardCommit() throws IOException { // avoid multiple commits and warming searchers commitAndRollbackLock.writeLock().lock(); try { UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); CommitUpdateCommand commitUpdateCommand = new CommitUpdateCommand(request, false); commitUpdateCommand.openSearcher = false; commitUpdateCommand.softCommit = false; commitUpdateCommand.waitSearcher = false; processor.processCommit(commitUpdateCommand); } finally { if (processor != null) { processor.finish(); } } } finally { commitAndRollbackLock.writeLock().unlock(); } }
Example 3
Source File: AbstractIngestionHandler.java From chronix.server with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { formatResponseAsJson(req); if (req.getContentStreams() == null) { LOGGER.warn("no content stream"); rsp.add("error", "No content stream"); return; } boolean commit = Boolean.parseBoolean(req.getParams().get("commit", "true")); InputStream stream = req.getContentStreams().iterator().next().getStream(); stream = detectGzip(stream); MetricTimeSeriesConverter converter = new MetricTimeSeriesConverter(); UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(req.getParams()); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); try { for (MetricTimeSeries series : formatParser.parse(stream)) { SolrInputDocument document = new SolrInputDocument(); converter.to(series).getFields().forEach(document::addField); storeDocument(document, processor, req); } if (commit) { LOGGER.debug("Committing transaction..."); processor.processCommit(new CommitUpdateCommand(req, false)); LOGGER.debug("Committed transaction"); } else { LOGGER.debug("Only adding documents."); } } finally { processor.finish(); } }
Example 4
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
@Override public boolean commit(boolean openSearcher) throws IOException { canUpdate(); UpdateRequestProcessor processor = null; boolean searcherOpened = false; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); CommitUpdateCommand command = new CommitUpdateCommand(request, false); if (openSearcher) { RefCounted<SolrIndexSearcher> active = null; RefCounted<SolrIndexSearcher> newest = null; try { active = core.getSearcher(); newest = core.getNewestSearcher(false); if (active.get() == newest.get()) { searcherOpened = command.openSearcher = true; command.waitSearcher = false; } else { searcherOpened = command.openSearcher = false; } } finally { ofNullable(active).ifPresent(RefCounted::decref); ofNullable(newest).ifPresent(RefCounted::decref); } } processor.processCommit(command); } finally { if (processor != null) { processor.finish(); } } return searcherOpened; }
Example 5
Source File: ChronixRetentionHandler.java From chronix.server with Apache License 2.0 | 2 votes |
/** * Triggers a commit to make the deletion visible on the index * * @param processor the update processor do process deletions * @param req the solr query request information * @throws IOException if bad things happen */ private void commitDeletions(UpdateRequestProcessor processor, SolrQueryRequest req) throws IOException { CommitUpdateCommand commit = new CommitUpdateCommand(req, optimizeAfterDeletion); commit.softCommit = softCommit; processor.processCommit(commit); }