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


Java CoreContainer.Initializer方法代碼示例

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


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

示例1: activateSolr

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Override
public void activateSolr() throws Exception
{
   ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
   Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );

   try
   {
      File directory = new File( fileConfig.dataDirectory(), descriptor.identity().toString() );
      directory.mkdirs();

      System.setProperty( "solr.solr.home", directory.getAbsolutePath() );

      CoreContainer.Initializer initializer = new CoreContainer.Initializer();
      coreContainer = initializer.initialize();
      server = new EmbeddedSolrServer( coreContainer, "" );
      core = coreContainer.getCore( "" );
   } finally
   {
      Thread.currentThread().setContextClassLoader( oldCl );
   }
}
 
開發者ID:apache,項目名稱:polygene-java,代碼行數:23,代碼來源:EmbeddedSolrService.java

示例2: createSolrServer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
private EmbeddedSolrServer createSolrServer(Map<String,String> urlParams) {
    String solrHome = urlParams.get("SOLR_HOME");
    StringBuilder paramStr = new StringBuilder();
    if (solrHome != null) {
        System.setProperty("solr.solr.home", solrHome);
        paramStr.append(";SOLR_HOME=").append(solrHome);
    }
    String dataDir = urlParams.get("DATA_DIR");
    if (dataDir != null) {
        System.setProperty("solr.data.dir", dataDir);
        paramStr.append(";DATA_DIR=").append(dataDir);
    }
    try {
        DriverManager.getConnection("jdbc:solr:s" + paramStr.toString());
    } catch (SQLException e) {
        throw new SQLRuntimeException(e);
    }
    CoreContainer.Initializer initializer = new CoreContainer.Initializer();
    CoreContainer coreContainer = initializer.initialize();
    return new EmbeddedSolrServer(coreContainer, coreContainer.getDefaultCoreName());

}
 
開發者ID:coastland,項目名稱:gsp-dba-maven-plugin,代碼行數:23,代碼來源:SolrDialect.java

示例3: setupContainer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
private void setupContainer(int port, String shard) throws IOException,
    ParserConfigurationException, SAXException {
  File data = new File(dataDir + File.separator + "data_" + port);
  data.mkdirs();
  
  System.setProperty("hostPort", Integer.toString(port));
  System.setProperty("shard", shard);
  Initializer init = new CoreContainer.Initializer();
  System.setProperty("solr.data.dir", data.getAbsolutePath());
  System.setProperty("solr.solr.home", TEST_HOME());
  Set<Integer> ports = shardPorts.get(shard);
  if (ports == null) {
    ports = new HashSet<Integer>();
    shardPorts.put(shard, ports);
  }
  ports.add(port);
  CoreContainer container = init.initialize();
  assertTrue("Container " + port + " has no cores!", container.getCores()
      .size() > 0);
  containerMap.put(port, container);
  System.clearProperty("solr.solr.home");
  System.clearProperty("hostPort");
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:24,代碼來源:LeaderElectionIntegrationTest.java

示例4: TestHarness

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
public TestHarness(String coreName, CoreContainer.Initializer init) {
  try {

    container = init.initialize();
    if (coreName == null)
      coreName = CoreContainer.DEFAULT_DEFAULT_CORE_NAME;

    this.coreName = coreName;

    updater = new UpdateRequestHandler();
    updater.init( null );
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:16,代碼來源:TestHarness.java

示例5: createInitializer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
/** Method to override to change how CoreContainer initialization is performed. */
protected CoreContainer.Initializer createInitializer() {
  return new CoreContainer.Initializer();
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:5,代碼來源:SolrDispatchFilter.java

示例6: setUp

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception {
  super.setUp();
  createTempDir();
  System.setProperty("zkClientTimeout", "3000");

  zkDir = dataDir.getAbsolutePath() + File.separator
      + "zookeeper/server1/data";
  zkServer = new ZkTestServer(zkDir);
  zkServer.run();
  System.setProperty("zkHost", zkServer.getZkAddress());
  AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(), zkServer
      .getZkAddress(), "solrconfig.xml", "schema.xml");
  
  log.info("####SETUP_START " + getTestName());
  dataDir1 = new File(dataDir + File.separator + "data1");
  dataDir1.mkdirs();
  
  dataDir2 = new File(dataDir + File.separator + "data2");
  dataDir2.mkdirs();
  
  dataDir3 = new File(dataDir + File.separator + "data3");
  dataDir3.mkdirs();
  
  dataDir4 = new File(dataDir + File.separator + "data4");
  dataDir4.mkdirs();
  
  // set some system properties for use by tests
  System.setProperty("solr.test.sys.prop1", "propone");
  System.setProperty("solr.test.sys.prop2", "proptwo");
  
  System.setProperty("solr.solr.home", TEST_HOME());
  System.setProperty("hostPort", "1661");
  CoreContainer.Initializer init1 = new CoreContainer.Initializer();
  System.setProperty("solr.data.dir", ClusterStateUpdateTest.this.dataDir1.getAbsolutePath());
  container1 = init1.initialize();
  System.clearProperty("hostPort");
  
  System.setProperty("hostPort", "1662");
  init2 = new CoreContainer.Initializer();
  System.setProperty("solr.data.dir", ClusterStateUpdateTest.this.dataDir2.getAbsolutePath());
  container2 = init2.initialize();
  System.clearProperty("hostPort");
  
  System.setProperty("hostPort", "1663");
  CoreContainer.Initializer init3 = new CoreContainer.Initializer();
 
  System.setProperty("solr.data.dir", ClusterStateUpdateTest.this.dataDir3.getAbsolutePath());
  container3 = init3.initialize();
  System.clearProperty("hostPort");
  System.clearProperty("solr.solr.home");
  
  log.info("####SETUP_END " + getTestName());
  
}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:56,代碼來源:ClusterStateUpdateTest.java

示例7: setUp

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Override
public void setUp() throws Exception {
  super.setUp();
  createTempDir();
  System.setProperty("zkClientTimeout", "3000");

  zkDir = dataDir.getAbsolutePath() + File.separator
      + "zookeeper/server1/data";
  zkServer = new ZkTestServer(zkDir);
  zkServer.run();
  System.setProperty("zkHost", zkServer.getZkAddress());
  AbstractZkTestCase.buildZooKeeper(zkServer.getZkHost(), zkServer
      .getZkAddress(), "solrconfig.xml", "schema.xml");

  log.info("####SETUP_START " + getTestName());
  Map<String, Object> props2 = new HashMap<String, Object>();
  props2.put("configName", "conf1");

  ZkNodeProps zkProps2 = new ZkNodeProps(props2);

  SolrZkClient zkClient = new SolrZkClient(zkServer.getZkAddress(),
      AbstractZkTestCase.TIMEOUT);
  zkClient.makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/testcore",
      ZkStateReader.toJSON(zkProps2), CreateMode.PERSISTENT, true);
  zkClient.makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/testcore/shards",
      CreateMode.PERSISTENT, true);
  zkClient.close();

  dataDir1 = new File(dataDir + File.separator + "data1");
  dataDir1.mkdirs();

  dataDir2 = new File(dataDir + File.separator + "data2");
  dataDir2.mkdirs();

  dataDir3 = new File(dataDir + File.separator + "data3");
  dataDir3.mkdirs();

  // set some system properties for use by tests
  System.setProperty("solr.test.sys.prop1", "propone");
  System.setProperty("solr.test.sys.prop2", "proptwo");

  System.setProperty("solr.solr.home", TEST_HOME());
  System.setProperty("hostPort", "1661");
  CoreContainer.Initializer init1 = new CoreContainer.Initializer();
  System.setProperty("solr.data.dir", SliceStateUpdateTest.this.dataDir1.getAbsolutePath());
  container1 = init1.initialize();

  System.clearProperty("hostPort");

  System.setProperty("hostPort", "1662");
  init2 = new CoreContainer.Initializer();
  System.setProperty("solr.data.dir", SliceStateUpdateTest.this.dataDir2.getAbsolutePath());
  container2 = init2.initialize();
  System.clearProperty("hostPort");

  System.clearProperty("solr.solr.home");

  log.info("####SETUP_END " + getTestName());

}
 
開發者ID:pkarmstr,項目名稱:NYBC,代碼行數:61,代碼來源:SliceStateUpdateTest.java


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