當前位置: 首頁>>代碼示例>>Java>>正文


Java UpdateResponse.getStatus方法代碼示例

本文整理匯總了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()));
	}		
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:27,代碼來源:SolrUpdateExecution.java

示例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;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-indexer,代碼行數:36,代碼來源:SolrHelper.java

示例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());
    }
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:34,代碼來源:MCRSolrInputDocumentsHandler.java

示例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());
    }

}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:46,代碼來源:MCRSolrMCRContentMapIndexHandler.java

示例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;
}
 
開發者ID:ChronixDB,項目名稱:chronix.server,代碼行數:6,代碼來源:SolrAddingService.java

示例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());
}
 
開發者ID:europeana,項目名稱:search,代碼行數:48,代碼來源:OpenCloseCoreStressTest.java


注:本文中的org.apache.solr.client.solrj.response.UpdateResponse.getStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。