use of org.apache.solr.client.solrj.SolrServerException in project mamute by caelum.
the class SolrQuestionIndex method indexQuestion.
@Override
public void indexQuestion(Question question) {
try {
SolrInputDocument doc = toDoc(question);
server.add(doc);
server.commit();
LOGGER.info("Question synced or updated: " + question);
} catch (IOException | SolrServerException e) {
throw new IndexException("Could not index Question [" + question.getId() + "]", e);
}
}
use of org.apache.solr.client.solrj.SolrServerException in project RecordManager2 by moravianlibrary.
the class SolrServerFacadeImpl method indexLazyFulltext.
private void indexLazyFulltext(Collection<SolrInputDocument> documents, int commitWithinMs) throws SolrServerException {
for (SolrInputDocument document : documents) {
boolean carryOn = true;
while (carryOn) {
try {
LazyFulltextFieldImpl fulltext = (LazyFulltextFieldImpl) document.getFieldValue(SolrFieldConstants.FULLTEXT_FIELD);
document.setField(SolrFieldConstants.FULLTEXT_FIELD, fulltext.getContent());
server.add(document, commitWithinMs);
exceptionHandler.ok();
carryOn = false;
} catch (SolrException | SolrServerException | IOException ex) {
carryOn = exceptionHandler.handle(ex, Collections.singletonList(document)) == Action.RETRY;
} finally {
// to enable garbage collection
document.removeField(SolrFieldConstants.FULLTEXT_FIELD);
}
}
}
}
use of org.apache.solr.client.solrj.SolrServerException in project RecordManager2 by moravianlibrary.
the class SolrServerFacadeImpl method fallbackIndex.
private void fallbackIndex(Collection<SolrInputDocument> documents, int commitWithinMs) throws SolrServerException {
for (SolrInputDocument document : documents) {
boolean carryOn = true;
while (carryOn) {
try {
server.add(document, commitWithinMs);
exceptionHandler.ok();
carryOn = false;
} catch (SolrException | SolrServerException | IOException ex) {
Action action = exceptionHandler.handle(ex, documents);
carryOn = action == Action.RETRY;
}
}
}
}
use of org.apache.solr.client.solrj.SolrServerException in project RecordManager2 by moravianlibrary.
the class SolrServerFacadeImpl method query.
public QueryResponse query(SolrQuery query) throws SolrServerException {
if (requestPath == null) {
return server.query(query);
} else {
SolrRequest request = new QueryRequest(query);
request.setPath(requestPath);
NamedList<Object> req;
try {
req = server.request(request);
} catch (IOException ioe) {
throw new SolrServerException(ioe);
}
return new QueryResponse(req, server);
}
}
use of org.apache.solr.client.solrj.SolrServerException in project RecordManager2 by moravianlibrary.
the class AbstractKrameriusTest method initSolrServerWithException.
protected void initSolrServerWithException() throws Exception {
reset(solrServerFactory);
expect(solrServerFactory.create(eq(SOLR_URL), eq(Mode.KRAMERIUS))).andReturn(mockedSolrServer).anyTimes();
replay(solrServerFactory);
reset(mockedSolrServer);
Capture<SolrQuery> capturedQueryRequest = EasyMock.newCapture();
SolrDocumentList documents = new SolrDocumentList();
SolrDocument doc1 = new SolrDocument();
doc1.addField("PID", "uuid:00931210-02b6-11e5-b939-0800200c9a66");
SolrDocument doc2 = new SolrDocument();
doc2.addField("PID", "uuid:0095bca0-614f-11e2-bcfd-0800200c9a66");
documents.add(doc1);
documents.add(doc2);
NamedList<Object> solrResponse1 = new NamedList<Object>();
solrResponse1.add("response", documents);
// 1st response - SolrServerExceptions
expect(mockedSolrServer.query(and(capture(capturedQueryRequest), anyObject(SolrQuery.class)))).andThrow(new SolrServerException("Bad status code: 500"));
// 2nd response - SolrServerException
expect(mockedSolrServer.query(and(capture(capturedQueryRequest), anyObject(SolrQuery.class)))).andThrow(new SolrServerException("Something bad happened to poor SOLR"));
// 3rd response - OK
expect(mockedSolrServer.query(and(capture(capturedQueryRequest), anyObject(SolrQuery.class)))).andReturn(new QueryResponse(solrResponse1, null));
replay(mockedSolrServer);
}
Aggregations