List of usage examples for org.apache.solr.core SolrCore getConfigResource
public String getConfigResource()
From source file:com.searchbox.engine.solr.EmbeddedSolr.java
License:Apache License
@Override public void register(Collection collection) { String coreInstanceDir = this.solrHome; Properties properties = new Properties(); if (this.dataDir != null) { File dataDir = new File(this.dataDir); if (dataDir.exists()) { try { FileUtils.deleteDirectory(dataDir); } catch (IOException e) { LOGGER.error("Could not delete DataDir: " + dataDir); }//from www . j a v a 2 s . co m } properties.setProperty("dataDir", this.dataDir); } else { properties.setProperty("dataDir", coreInstanceDir + "/" + collection.getName() + "/data/"); } CoreDescriptor dcore = new CoreDescriptor(coreContainer, collection.getName(), coreInstanceDir, properties); try { SolrCore core = coreContainer.create(dcore); coreContainer.register(core, false); LOGGER.info("Solr Core config: " + core.getConfigResource()); LOGGER.info("Solr SchemaResource: " + core.getSchemaResource()); LOGGER.info("Solr Data dir: " + core.getDataDir()); } catch (Exception e) { LOGGER.warn(e.getMessage()); } }
From source file:org.xwiki.search.solr.internal.EmbeddedSolrInstanceInitializationTest.java
License:Open Source License
/** * TODO DOCUMENT ME!//from w w w . java 2s .c o m * * @param expected * @throws ComponentLookupException * @throws Exception */ private void getInstanceAndAssertHomeDirectory(String expected) throws ComponentLookupException, Exception { SolrInstance instance = mocker.getInstance(SolrInstance.class, "embedded"); Assert.assertNotNull(instance); EmbeddedSolrInstance implementation = ((EmbeddedSolrInstance) instance); CoreContainer container = implementation.getContainer(); if (expected == null) { expected = implementation.getDefaultHomeDirectory(); } Assert.assertEquals(expected + File.separator, container.getSolrHome()); Assert.assertEquals(1, container.getCores().size()); SolrCore core = container.getCores().iterator().next(); File coreBaseDirectory = new File(container.getSolrHome(), core.getName()); File configDirectory = new File(coreBaseDirectory, DefaultSolrConfiguration.CONF_DIRECTORY); Assert.assertTrue(new File(configDirectory, core.getSchemaResource()).exists()); Assert.assertTrue(new File(configDirectory, core.getConfigResource()).exists()); }