private CoreContainer createCoreContainer(String solrHomeDirectory, File solrXmlFile) { return CoreContainer.createAndLoad(Paths.get(solrHomeDirectory), solrXmlFile.toPath()); }
@Override public SolrClient create(String spec) { Path solrHome = SolrResourceLoader.locateSolrHome(); Path configFile = solrHome.resolve(SolrXmlConfig.SOLR_XML_FILE); return new EmbeddedSolrServer(CoreContainer.createAndLoad(solrHome, configFile), "embedded"); } }
@Override public SolrClient create(String spec) { String solrHome = SolrResourceLoader.locateSolrHome(); File configFile = new File(solrHome, SolrXmlConfig.SOLR_XML_FILE); return new EmbeddedSolrServer(CoreContainer.createAndLoad(solrHome, configFile), "embedded"); } }
/** * Instantiates a new embedded index. * * @param solrHomePath the solr home path * @param coreName the core name * */ public SolrEmbeddedIndex(final String solrHomePath, final String coreName) { final File solrHome = new File(solrHomePath); final File solrBaseFile = new File(solrHome, "solr.xml"); ClassLoader classLoader = CoreContainer.class.getClassLoader(); ClassLoader originalClassLoader = ClassUtils.overrideThreadContextClassLoader(classLoader); try { container = CoreContainer.createAndLoad(solrHome.getPath(), solrBaseFile); } catch (RuntimeException e) { final String msg = "Failed to load embedded server configuration (Parsing error): " + solrBaseFile.getAbsolutePath(); LOG.warn(msg, e); throw new GeneralServiceException(msg, e); } finally { if (originalClassLoader != null) { Thread.currentThread().setContextClassLoader(originalClassLoader); } } final EmbeddedSolrServer server = new EmbeddedSolrServer(container, coreName); searchServer = server; }
coreContainer = CoreContainer.createAndLoad(solrHome, solrXml);
@Override public void start() { try { coreContainer = (CoreContainer) getHelped().getContext() .getAttributes().get("CoreContainer"); if (coreContainer == null) { String directory = getHelped().getContext().getParameters() .getFirstValue("directory"); String configFile = getHelped().getContext().getParameters() .getFirstValue("configFile"); if (directory != null && configFile != null) { File config = new File(configFile); if (!config.exists()) { config = new File(new URI(configFile)); } coreContainer = CoreContainer.createAndLoad(directory, config); } } if (coreContainer == null) { throw new RuntimeException( "Could not initialize core container"); } } catch (Exception e) { throw new RuntimeException("Could not initialize core container", e); } }
/** * Creates the Solr core container.<p> * * @return the created core container */ private CoreContainer createCoreContainer() { CoreContainer container = null; try { // get the core container // still no core container: create it container = CoreContainer.createAndLoad( Paths.get(m_solrConfig.getHome()), m_solrConfig.getSolrFile().toPath()); if (CmsLog.INIT.isInfoEnabled()) { CmsLog.INIT.info( Messages.get().getBundle().key( Messages.INIT_SOLR_CORE_CONTAINER_CREATED_2, m_solrConfig.getHome(), m_solrConfig.getSolrFile().getName())); } } catch (Exception e) { LOG.error( Messages.get().getBundle().key( Messages.ERR_SOLR_CORE_CONTAINER_NOT_CREATED_1, m_solrConfig.getSolrFile().getAbsolutePath()), e); } return container; }