当前位置: 首页>>代码示例>>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;未经允许,请勿转载。