Hi,

I have a question regarding the backup of a Solr collection using SolrJ. I
use Solr 7.
I want to do a JAR for that and launch it into a cron job.

So far, no problem for the request using
CollectionAdminRequest.backupCollection then I use the processAsync method.

The command is well transmitted to Solr.

My problem is for parsing the response and manage the different cases in
the code for a failure.

Let's say that the Solr response is the following after sending the
asynchronous backup request (the request id is "backupsolr")  :

{
"responseHeader": {
"status": 0,
"QTime": 1
},
"success": {
"IP:8983_solr": {
"responseHeader": {
"status": 0,
"QTime": 0
}
},
"IP:8983_solr": {
"responseHeader": {
"status": 0,
"QTime": 0
}
}
},
"solrbackup5704378348890743": {
"responseHeader": {
"status": 0,
"QTime": 0
},
"STATUS": "failed",
"Response": "Failed to backup core=Test_shard1_replica1 because
java.io.IOException: Aucun espace disponible sur le périphérique"
},
"status": {
"state": "completed",
"msg": "found [solrbackup] in completed tasks"
}
}
If I use the code :
System.out.println(CollectionAdminRequest.requestStatus("solrbackup
").process(solr).getRequestStatus());

The output is : "COMPLETED".
But it is not enough to check if the backup was well done or not. For
example in this case the task is completed but the backup was not
successful because there was not enough space left on the disk.
So the interesting part is into the solrbackup5704378348890743 section of
the response.

My first question is why some numbers are added to the request-id name ?

Because if I write :
CollectionAdminRequest.requestStatus("solrbackup").getRequestId() the
response is : "solrbackup" and not solrbackup5704378348890743.
So retrieving the section related to solrbackup5704378348890743 in the
response is not very easy.
I cannot directly use (NamedList<Object>)
CollectionAdminRequest.requestStatus("solrbackup").process(solr).getResponse().get("solrbackup")
but instead I have to use an iterator into the entire Solr response and
check the beginning of each String for retrieving the section that begins
by solrbackup. And finally get the elements that I want.

Am I correct to do this, maybe there is a simpler way to do that ?

Thanks,
Olivier Tavard

Reply via email to