On 8/24/2011 3:24 PM, Dyer, James wrote:
Shawn,
I do not know of an easy or a good way to do this. It would be nice if there
were a non-frail, programmatic way to get back DIH status but I don't think
there is one. I have a (monsterous) program that polls a running DIH handler
every so often to get its status. The crux is something like this:
DirectXmlRequest req = new DirectXmlRequest(requestUrl, null);
req.setMethod(METHOD.GET);
req.setParams(params);
NamedList<Object> nl = server.request("/dataimport");
String status = (String) nl.get("status");
String response = (String) nl.get("importResponse");
Map<String, String> msgs = (Map<String, String>) nl.get("statusMessages");
if(msgs!=null)
{
String numReq = (String) msgs.get("Total Requests made to DataSource");
String numRows = (String) msgs.get("Total Documents Processed");
String docsSkipped = (String) msgs.get("Total Documents Skipped");
String timeStarted = (String) msgs.get("Full Dump Started");
String elapsed = (String) msgs.get("Time taken ");
String aborted = (String) msgs.get("Aborted");
String plaintextMsg = (String) msgs.get("");
}
Not sure this is what you're after, but maybe it'd be helpful. Like I say, I
wish [I knew of|there was] a better way to do this...
It might not be the prettiest code, but I'll take it. Thank you. I
paraphrased quite a bit and have ended up with the following:
String numRows = null;
String elapsed = null;
String aborted = null;
String plaintextMsg = null;
SolrRequest req = new DirectXmlRequest("/dataimport", null);
NamedList<Object> nl = solrCore.request(req);
String status = (String) nl.get("status");
@SuppressWarnings("unchecked")
Map<String, String> msgs = (Map<String, String>) nl
.get("statusMessages");
if (msgs != null)
{
numRows = (String) msgs.get("Total Documents Processed");
elapsed = (String) msgs.get("Time taken ");
aborted = (String) msgs.get("Aborted");
plaintextMsg = (String) msgs.get("");
}
I've tried it and it seems to work reliably. If anyone out there knows
a better method to pull this off, I'd certainly like to hear about it.
Thanks,
Shawn