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


Java SolrCore.getNewestSearcher方法代碼示例

本文整理匯總了Java中org.apache.solr.core.SolrCore.getNewestSearcher方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrCore.getNewestSearcher方法的具體用法?Java SolrCore.getNewestSearcher怎麽用?Java SolrCore.getNewestSearcher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.core.SolrCore的用法示例。


在下文中一共展示了SolrCore.getNewestSearcher方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: replay

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
private Future<RecoveryInfo> replay(SolrCore core)
    throws InterruptedException, ExecutionException {
  Future<RecoveryInfo> future = core.getUpdateHandler().getUpdateLog().applyBufferedUpdates();
  if (future == null) {
    // no replay needed\
    log.info("No replay needed. core=" + coreName);
  } else {
    log.info("Replaying buffered documents. core=" + coreName);
    // wait for replay
    RecoveryInfo report = future.get();
    if (report.failed) {
      SolrException.log(log, "Replay failed");
      throw new SolrException(ErrorCode.SERVER_ERROR, "Replay failed");
    }
  }
  
  // solrcloud_debug
  if (log.isDebugEnabled()) {
    try {
      RefCounted<SolrIndexSearcher> searchHolder = core
          .getNewestSearcher(false);
      SolrIndexSearcher searcher = searchHolder.get();
      try {
        log.debug(core.getCoreDescriptor().getCoreContainer()
            .getZkController().getNodeName()
            + " replayed "
            + searcher.search(new MatchAllDocsQuery(), 1).totalHits);
      } finally {
        searchHolder.decref();
      }
    } catch (Exception e) {
      throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
    }
  }
  
  return future;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:38,代碼來源:RecoveryStrategy.java

示例2: replicate

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
private void replicate(String nodeName, SolrCore core, ZkNodeProps leaderprops)
    throws SolrServerException, IOException {

  ZkCoreNodeProps leaderCNodeProps = new ZkCoreNodeProps(leaderprops);
  String leaderUrl = leaderCNodeProps.getCoreUrl();
  
  log.info("Attempting to replicate from " + leaderUrl + ". core=" + coreName);
  
  // send commit
  commitOnLeader(leaderUrl);
  
  // use rep handler directly, so we can do this sync rather than async
  SolrRequestHandler handler = core.getRequestHandler(REPLICATION_HANDLER);
  if (handler instanceof LazyRequestHandlerWrapper) {
    handler = ((LazyRequestHandlerWrapper) handler).getWrappedHandler();
  }
  ReplicationHandler replicationHandler = (ReplicationHandler) handler;
  
  if (replicationHandler == null) {
    throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
        "Skipping recovery, no " + REPLICATION_HANDLER + " handler found");
  }
  
  ModifiableSolrParams solrParams = new ModifiableSolrParams();
  solrParams.set(ReplicationHandler.MASTER_URL, leaderUrl);
  
  if (isClosed()) return; // we check closed on return
  boolean success = replicationHandler.doFetch(solrParams, false);
  
  if (!success) {
    throw new SolrException(ErrorCode.SERVER_ERROR,
        "Replication for recovery failed.");
  }
  
  // solrcloud_debug
  if (log.isDebugEnabled()) {
    try {
      RefCounted<SolrIndexSearcher> searchHolder = core
          .getNewestSearcher(false);
      SolrIndexSearcher searcher = searchHolder.get();
      Directory dir = core.getDirectoryFactory().get(core.getIndexDir(), DirContext.META_DATA, null);
      try {
        log.debug(core.getCoreDescriptor().getCoreContainer()
            .getZkController().getNodeName()
            + " replicated "
            + searcher.search(new MatchAllDocsQuery(), 1).totalHits
            + " from "
            + leaderUrl
            + " gen:"
            + core.getDeletionPolicy().getLatestCommit().getGeneration()
            + " data:" + core.getDataDir()
            + " index:" + core.getIndexDir()
            + " newIndex:" + core.getNewIndexDir()
            + " files:" + Arrays.asList(dir.listAll()));
      } finally {
        core.getDirectoryFactory().release(dir);
        searchHolder.decref();
      }
    } catch (Exception e) {
      throw new SolrException(ErrorCode.SERVER_ERROR, null, e);
    }
  }

}
 
開發者ID:europeana,項目名稱:search,代碼行數:65,代碼來源:RecoveryStrategy.java


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