List of usage examples for org.apache.solr.common.params UpdateParams UPDATE_CHAIN
String UPDATE_CHAIN
To view the source code for org.apache.solr.common.params UpdateParams UPDATE_CHAIN.
Click Source Link
From source file:de.qaware.chronix.solr.retention.ChronixRetentionHandler.java
License:Apache License
/** * Gets the processor build from the processor update chain(UpdateParams.UPDATE_CHAIN) * * @param req - the solr query request information * @param rsp - the solr query response information * @return the update request processor//from w w w . j a v a2 s .c o m */ private UpdateRequestProcessor getProcessor(SolrQueryRequest req, SolrQueryResponse rsp) { UpdateRequestProcessorChain processorChain = req.getCore() .getUpdateProcessingChain(req.getParams().get(UpdateParams.UPDATE_CHAIN)); return processorChain.createProcessor(req, rsp); }
From source file:org.codeexample.jeffery.solr.ThreadedUpdateRequestHandler.java
License:Apache License
private ExecutorService importStreamsMultiThreaded(final SolrQueryRequest req, final SolrQueryResponse rsp, List<ContentStream> streams) throws InterruptedException, IOException { ExecutorService executor = null; SolrParams params = req.getParams(); final UpdateRequestProcessorChain processorChain = req.getCore() .getUpdateProcessingChain(params.get(UpdateParams.UPDATE_CHAIN)); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); try {/* w ww . ja v a2 s . c o m*/ Map<String, Object> resultMap = new LinkedHashMap<String, Object>(); resultMap.put("start_time", new Date()); List<Map<String, Object>> details = new ArrayList<Map<String, Object>>(); try { int threads = determineThreadsNumber(params, streams.size()); ThreadFactory threadFactory = new ThreadFactory() { public Thread newThread(Runnable r) { return new Thread(r, "threadedReqeustHandler-" + new Date()); } }; executor = Executors.newFixedThreadPool(threads, threadFactory); String contentType = params.get(CommonParams.STREAM_CONTENTTYPE); Iterator<ContentStream> iterator = streams.iterator(); while (iterator.hasNext()) { ContentStream stream = iterator.next(); iterator.remove(); if (stream instanceof ContentStreamBase) { ((ContentStreamBase) stream).setContentType(contentType); } submitTask(req, rsp, processorChain, executor, stream, details); } executor.shutdown(); boolean terminated = executor.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS); if (!terminated) { throw new RuntimeException("Request takes too much time"); } // Perhaps commit from the parameters RequestHandlerUtils.handleCommit(req, processor, params, false); RequestHandlerUtils.handleRollback(req, processor, params, false); } finally { resultMap.put("end_time", new Date()); // check whether there is error in details for (Map<String, Object> map : details) { Exception ex = (Exception) map.get("exception"); if (ex != null) { rsp.setException(ex); if (ex instanceof SolrException) { rsp.add("status", ((SolrException) ex).code()); } else { rsp.add("status", SolrException.ErrorCode.BAD_REQUEST); } break; } } } resultMap.put("details", details); rsp.add("result", resultMap); return executor; } finally { if (executor != null && !executor.isShutdown()) { executor.shutdownNow(); } // finish the request processor.finish(); } }
From source file:uk.co.flax.biosolr.solr.update.processor.OntologyUpdateProcessorFactoryTest.java
License:Apache License
static void addDoc(String doc, String chain) throws Exception { Map<String, String[]> params = new HashMap<>(); MultiMapSolrParams mmparams = new MultiMapSolrParams(params); params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain }); SolrQueryRequestBase req = new SolrQueryRequestBase(h.getCore(), mmparams) { };//w ww .j a v a 2 s . c om UpdateRequestHandler handler = new UpdateRequestHandler(); handler.init(null); ArrayList<ContentStream> streams = new ArrayList<>(2); streams.add(new ContentStreamBase.StringStream(doc)); req.setContentStreams(streams); handler.handleRequestBody(req, new SolrQueryResponse()); req.close(); }