本文整理汇总了Java中org.apache.solr.client.solrj.response.UpdateResponse.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateResponse.getStatus方法的具体用法?Java UpdateResponse.getStatus怎么用?Java UpdateResponse.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.response.UpdateResponse
的用法示例。
在下文中一共展示了UpdateResponse.getStatus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performUpdate
import org.apache.solr.client.solrj.response.UpdateResponse; //导入方法依赖的package包/类
private void performUpdate(Delete obj) throws TranslatorException {
Table table = obj.getTable().getMetadataObject();
KeyRecord pk = table.getPrimaryKey();
final String id = getRecordName(pk.getColumns().get(0));
if (obj.getParameterValues() != null) {
throw new TranslatorException(SolrPlugin.Event.TEIID20008, SolrPlugin.Util.gs(SolrPlugin.Event.TEIID20008));
}
SolrQueryExecution query = new SolrQueryExecution(ef, obj, this.executionContext, this.metadata, this.connection);
query.execute();
final UpdateRequest request = new UpdateRequest();
query.walkDocuments(new SolrDocumentCallback() {
@Override
public void walk(SolrDocument doc) {
SolrUpdateExecution.this.updateCount++;
request.deleteById(doc.getFieldValue(id).toString());
}
});
UpdateResponse response = this.connection.update(request);
if (response.getStatus() != 0) {
throw new TranslatorException(SolrPlugin.Event.TEIID20005, SolrPlugin.Util.gs(SolrPlugin.Event.TEIID20005, response.getStatus()));
}
}
示例2: writeToIndex
import org.apache.solr.client.solrj.response.UpdateResponse; //导入方法依赖的package包/类
/**
* @param doc
* @return Error message, if occurred; null otherwise.
* @throws FatalIndexerException
* @should write doc correctly
*/
public boolean writeToIndex(SolrInputDocument doc) throws FatalIndexerException {
boolean success = false;
int tries = RETRY_ATTEMPTS;
while (!success && tries > 0) {
tries--;
try {
UpdateResponse ur = server.add(doc);
switch (ur.getStatus()) {
case 0:
success = true;
break;
default:
logger.error("Update status: {}", ur.getStatus());
}
return true;
} catch (SolrServerException | IOException e) {
logger.error(e.getMessage(), e);
}
}
if (!success) {
logger.error("Could not write document after {} attempts. Check the Solr server connection. Exiting...", RETRY_ATTEMPTS);
rollback();
throw new FatalIndexerException("Solr connection error");
}
return false;
}
示例3: index
import org.apache.solr.client.solrj.response.UpdateResponse; //导入方法依赖的package包/类
@Override
public void index() throws IOException, SolrServerException {
if (documents == null || documents.isEmpty()) {
LOGGER.warn("No input documents to index.");
return;
}
int totalCount = documents.size();
LOGGER.info("Handling {} documents", totalCount);
SolrClient solrClient = getSolrClient();
if (solrClient instanceof ConcurrentUpdateSolrClient) {
LOGGER.info("Detected ConcurrentUpdateSolrClient. Split up batch update.");
splitDocuments();
//for statistics:
documents.clear();
return;
}
UpdateResponse updateResponse;
try {
UpdateRequest updateRequest = getUpdateRequest(MCRSolrConstants.UPDATE_PATH);
updateRequest.add(documents);
updateResponse = updateRequest.process(getSolrClient());
} catch (Throwable e) {
LOGGER.warn("Error while indexing document collection. Split and retry.");
splitDocuments();
return;
}
if (updateResponse.getStatus() != 0) {
LOGGER.error("Error while indexing document collection. Split and retry: {}", updateResponse.getResponse());
splitDocuments();
} else {
LOGGER.info("Sending {} documents was successful in {} ms.", totalCount, updateResponse.getElapsedTime());
}
}
示例4: index
import org.apache.solr.client.solrj.response.UpdateResponse; //导入方法依赖的package包/类
@Override
public void index() throws IOException, SolrServerException {
int totalCount = contentMap.size();
LOGGER.info("Handling {} documents", totalCount);
//multithread processing will result in too many http request
UpdateResponse updateResponse;
try {
Iterator<SolrInputDocument> documents = MCRSolrInputDocumentFactory.getInstance().getDocuments(contentMap);
SolrClient solrClient = getSolrClient();
if (solrClient instanceof ConcurrentUpdateSolrClient) {
//split up to speed up processing
splitup(documents);
return;
}
if (LOGGER.isDebugEnabled()) {
ArrayList<SolrInputDocument> debugList = new ArrayList<>();
while (documents.hasNext()) {
debugList.add(documents.next());
}
LOGGER.debug("Sending these documents: {}", debugList);
//recreate documents interator;
documents = debugList.iterator();
}
if (solrClient instanceof HttpSolrClient) {
updateResponse = solrClient.add(documents);
} else {
ArrayList<SolrInputDocument> docs = new ArrayList<>(totalCount);
while (documents.hasNext()) {
docs.add(documents.next());
}
updateResponse = solrClient.add(docs);
}
} catch (Throwable e) {
LOGGER.warn("Error while indexing document collection. Split and retry.", e);
splitup();
return;
}
if (updateResponse.getStatus() != 0) {
LOGGER.error("Error while indexing document collection. Split and retry: {}", updateResponse.getResponse());
splitup();
} else {
LOGGER.info("Sending {} documents was successful in {} ms.", totalCount, updateResponse.getElapsedTime());
}
}
示例5: evaluate
import org.apache.solr.client.solrj.response.UpdateResponse; //导入方法依赖的package包/类
private static boolean evaluate(UpdateResponse response) {
LOGGER.debug("Response returned: Status code {}, Elapsed time {}, QTime {}", response.getStatus(), response.getElapsedTime(), response.getQTime());
//any other status code means 'there was an error'
return response.getStatus() == 0;
}
示例6: run
import org.apache.solr.client.solrj.response.UpdateResponse; //导入方法依赖的package包/类
@Override
public void run() {
SolrTestCaseJ4.log.info(String.format(Locale.ROOT, "Starting indexing thread: " + getId()));
while (Indexer.stopTime > System.currentTimeMillis()) {
int myId = Indexer.idUnique.incrementAndGet();
Indexer.docsThisCycle.incrementAndGet();
String core = OCCST.getRandomCore(random);
OCCST.incrementCoreCount(core);
Indexer.progress(myId, core);
for (int idx = 0; idx < 3; ++idx) {
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "id" + Integer.toString(myId));
doc.addField("text", "text " + Integer.toString(myId));
UpdateRequest update = new UpdateRequest();
update.add(doc);
try {
server.setBaseURL(baseUrl + core);
UpdateResponse response = server.add(doc, OpenCloseCoreStressTest.COMMIT_WITHIN);
if (response.getStatus() != 0) {
SolrTestCaseJ4.log.warn("Failed to index a document to core " + core + " with status " + response.getStatus());
} else {
Indexer.qTimesAccum.addAndGet(response.getQTime());
Indexer.updateCounts.incrementAndGet();
break; // retry loop.
}
server.commit(true, true);
Thread.sleep(100L); // Let's not go crazy here.
} catch (Exception e) {
if (e instanceof InterruptedException) return;
Indexer.errors.incrementAndGet();
if (idx == 2) {
SolrTestCaseJ4.log.warn("Could not reach server while indexing for three tries, quitting " + e.getMessage());
} else {
SolrTestCaseJ4.log.info("Indexing thread " + Thread.currentThread().getId() + " swallowed one exception " + e.getMessage());
try {
Thread.sleep(100);
} catch (InterruptedException tex) {
return;
}
}
}
}
}
SolrTestCaseJ4.log.info("Leaving indexing thread " + getId());
}