Re: Best way to call asynchronously - Custom data import handler
Other than using futures and callables? Runnables ;-) Other than that you will need async request (ie. client). But in case sb else is looking for an easy-recipe for the server-side async: public void handleRequestBody(.) { if (isBusy()) { rsp.add("message", "Batch processing is already running..."); rsp.add("status", "busy"); return; } runAsynchronously(new LocalSolrQueryRequest(req.getCore(), req.getParams())); } private void runAsynchronously(SolrQueryRequest req) { final SolrQueryRequest request = req; thread = new Thread(new Runnable() { public void run() { try { while (queue.hasMore()) { runSynchronously(queue, request); } } catch (Exception e) { log.error(e.getLocalizedMessage()); } finally { request.close(); setBusy(false); } } }); thread.start(); } On Tue, Jul 9, 2013 at 1:10 AM, Learner wrote: > > I wrote a custom data import handler to import data from files. I am trying > to figure out a way to make asynchronous call instead of waiting for the > data import response. Is there an easy way to invoke asynchronously (other > than using futures and callables) ? > > public class CustomFileImportHandler extends RequestHandlerBase implements > SolrCoreAware{ > public void handleRequestBody(SolrQueryRequest arg0, > SolrQueryResponse > arg1){ >indexer a= new indexer(""); // constructor >String status= a.Index(); // method to do indexing, trying to make > it > async > } > } > > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/Best-way-to-call-asynchronously-Custom-data-import-handler-tp4076475.html > Sent from the Solr - User mailing list archive at Nabble.com. >
Re: Best way to call asynchronously - Custom data import handler
On 7/8/2013 11:10 PM, Learner wrote: > > I wrote a custom data import handler to import data from files. I am trying > to figure out a way to make asynchronous call instead of waiting for the > data import response. Is there an easy way to invoke asynchronously (other > than using futures and callables) ? > > public class CustomFileImportHandler extends RequestHandlerBase implements > SolrCoreAware{ > public void handleRequestBody(SolrQueryRequest arg0, SolrQueryResponse > arg1){ >indexer a= new indexer(""); // constructor >String status= a.Index(); // method to do indexing, trying to make it > async > } > } Generally speaking, it's easier to write a separate program than write a Solr plugin, unless you just want to add a tiny tweak to an existing class and not make fundamental changes in how it works. The dataimport handler is designed around a model of starting and frequently checking the status to know whether it's done. For what you want to do, I'd write a subroutine, module, or a separate program using a Solr API for your language that obtains the data from the source and indexes it to Solr directly. This is definitely the preferred method if your code is written in Java, but it's generally the right way to go no matter what language you're using. Thanks, Shawn
Best way to call asynchronously - Custom data import handler
I wrote a custom data import handler to import data from files. I am trying to figure out a way to make asynchronous call instead of waiting for the data import response. Is there an easy way to invoke asynchronously (other than using futures and callables) ? public class CustomFileImportHandler extends RequestHandlerBase implements SolrCoreAware{ public void handleRequestBody(SolrQueryRequest arg0, SolrQueryResponse arg1){ indexer a= new indexer(""); // constructor String status= a.Index(); // method to do indexing, trying to make it async } } -- View this message in context: http://lucene.472066.n3.nabble.com/Best-way-to-call-asynchronously-Custom-data-import-handler-tp4076475.html Sent from the Solr - User mailing list archive at Nabble.com.