List of usage examples for org.apache.solr.core CoreContainer getAllCoreNames
public Collection<String> getAllCoreNames()
From source file:org.warcbase.index.IndexerReducer.java
License:Apache License
private void initEmbeddedServer(int slice) throws IOException { if (solrHome == null) { throw new IOException("Unable to find solr home setting"); }//from w w w .j a v a2s. c om Path outputShardDir = new Path(fs.getHomeDirectory() + "/" + outputDir, SHARD_PREFIX + slice); LOG.info("Creating embedded Solr server with solrHomeDir: " + solrHome + ", fs: " + fs + ", outputShardDir: " + outputShardDir); Path solrDataDir = new Path(outputShardDir, "data"); if (!fs.exists(solrDataDir) && !fs.mkdirs(solrDataDir)) { throw new IOException("Unable to create " + solrDataDir); } String dataDirStr = solrDataDir.toUri().toString(); LOG.info("Attempting to set data dir to: " + dataDirStr); System.setProperty("solr.data.dir", dataDirStr); System.setProperty("solr.home", solrHome.toString()); System.setProperty("solr.solr.home", solrHome.toString()); System.setProperty("solr.hdfs.home", outputDir.toString()); 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", "true"); System.setProperty("solr.hdfs.blockcache.write.enabled", "false"); System.setProperty("solr.autoCommit.maxTime", "600000"); System.setProperty("solr.autoSoftCommit.maxTime", "-1"); LOG.info("Loading the container..."); CoreContainer container = new CoreContainer(); container.load(); for (String s : container.getAllCoreNames()) { LOG.warn("Got core name: " + s); } String coreName = ""; if (container.getCoreNames().size() > 0) { coreName = container.getCoreNames().iterator().next(); } LOG.error("Now firing up the server..."); solrServer = new EmbeddedSolrServer(container, coreName); LOG.error("Server started successfully!"); }