本文整理匯總了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 );
}
}
示例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());
}
示例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");
}
示例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);
}
}
示例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();
}
示例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());
}
示例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());
}