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


Java SolrCore.getDirectoryFactory方法代碼示例

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


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

示例1: checkForSingleIndex

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
private void checkForSingleIndex(JettySolrRunner jetty) {
  CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter().getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    String ddir = core.getDataDir();
    CachingDirectoryFactory dirFactory = (CachingDirectoryFactory) core.getDirectoryFactory();
    synchronized (dirFactory) {
      Set<String> livePaths = dirFactory.getLivePaths();
      // one for data, one for hte index under data
      assertEquals(livePaths.toString(), 2, livePaths.size());
      // :TODO: assert that one of the paths is a subpath of hte other
    }
    if (dirFactory instanceof StandardDirectoryFactory) {
      System.out.println(Arrays.asList(new File(ddir).list()));
      assertEquals(Arrays.asList(new File(ddir).list()).toString(), 1, indexDirCount(ddir));
    }
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:19,代碼來源:TestReplicationHandler.java

示例2: createEmbeddedSolrServer

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public static EmbeddedSolrServer createEmbeddedSolrServer(Path solrHomeDir, FileSystem fs, Path outputShardDir)
    throws IOException {

  if (solrHomeDir == null) {
    throw new IOException("Unable to find solr home setting");
  }
  LOG.info("Creating embedded Solr server with solrHomeDir: " + solrHomeDir + ", fs: " + fs + ", outputShardDir: " + outputShardDir);

  Path solrDataDir = new Path(outputShardDir, "data");

  String dataDirStr = solrDataDir.toUri().toString();

  SolrResourceLoader loader = new SolrResourceLoader(solrHomeDir.toString(), null, null);

  LOG.info(String
      .format(Locale.ENGLISH, 
          "Constructed instance information solr.home %s (%s), instance dir %s, conf dir %s, writing index to solr.data.dir %s, with permdir %s",
          solrHomeDir, solrHomeDir.toUri(), loader.getInstanceDir(),
          loader.getConfigDir(), dataDirStr, outputShardDir));

  // TODO: This is fragile and should be well documented
  System.setProperty("solr.directoryFactory", HdfsDirectoryFactory.class.getName()); 
  System.setProperty("solr.lock.type", "hdfs"); 
  System.setProperty("solr.hdfs.nrtcachingdirectory", "false");
  System.setProperty("solr.hdfs.blockcache.enabled", "false");
  System.setProperty("solr.autoCommit.maxTime", "600000");
  System.setProperty("solr.autoSoftCommit.maxTime", "-1");
  
  CoreContainer container = new CoreContainer(loader);
  container.load();
  
  Properties props = new Properties();
  props.setProperty(CoreDescriptor.CORE_DATADIR, dataDirStr);
  
  CoreDescriptor descr = new CoreDescriptor(container, "core1", solrHomeDir.toString(), props);
  
  SolrCore core = container.create(descr);
  
  if (!(core.getDirectoryFactory() instanceof HdfsDirectoryFactory)) {
    throw new UnsupportedOperationException(
        "Invalid configuration. Currently, the only DirectoryFactory supported is "
            + HdfsDirectoryFactory.class.getSimpleName());
  }

  EmbeddedSolrServer solr = new EmbeddedSolrServer(container, "core1");
  return solr;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:48,代碼來源:SolrRecordWriter.java

示例3: UpdateHandler

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public UpdateHandler(SolrCore core, UpdateLog updateLog)  {
  this.core=core;
  idField = core.getLatestSchema().getUniqueKeyField();
  idFieldType = idField!=null ? idField.getType() : null;
  parseEventListeners();
  PluginInfo ulogPluginInfo = core.getSolrConfig().getPluginInfo(UpdateLog.class.getName());
  

  if (updateLog == null && ulogPluginInfo != null && ulogPluginInfo.isEnabled()) {
    String dataDir = (String)ulogPluginInfo.initArgs.get("dir");
    
    String ulogDir = core.getCoreDescriptor().getUlogDir();
    if (ulogDir != null) {
      dataDir = ulogDir;
    }
    if (dataDir == null || dataDir.length()==0) {
      dataDir = core.getDataDir();
    }
         
    if (dataDir != null && dataDir.startsWith("hdfs:/")) {
      DirectoryFactory dirFactory = core.getDirectoryFactory();
      if (dirFactory instanceof HdfsDirectoryFactory) {
        ulog = new HdfsUpdateLog(((HdfsDirectoryFactory)dirFactory).getConfDir());
      } else {
        ulog = new HdfsUpdateLog();
      }
      
    } else {
      ulog = new UpdateLog();
    }
    
    if (!core.isReloaded() && !core.getDirectoryFactory().isPersistent()) {
      ulog.clearLog(core, ulogPluginInfo);
    }
    
    ulog.init(ulogPluginInfo);

    ulog.init(this, core);
  } else {
    ulog = updateLog;
  }
  // ulog.init() when reusing an existing log is deferred (currently at the end of the DUH2 constructor

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


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