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


Java CoreContainer.createAndLoad方法代碼示例

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


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

示例1: setUp

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
  super.setUp();

  System.setProperty("solr.solr.home", SOLR_HOME.getAbsolutePath());
  System.setProperty("configSetBase", SolrTestCaseJ4.getFile("solrj/solr/configsets").getAbsolutePath());
  System.out.println("Solr home: " + SOLR_HOME.getAbsolutePath());

  //The index is always stored within a temporary directory
  tempDir = createTempDir();
  
  File dataDir = new File(tempDir,"data1");
  File dataDir2 = new File(tempDir,"data2");
  System.setProperty("dataDir1", dataDir.getAbsolutePath());
  System.setProperty("dataDir2", dataDir2.getAbsolutePath());
  System.setProperty("tempDir", tempDir.getAbsolutePath());
  System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
  cores = CoreContainer.createAndLoad(SOLR_HOME.getAbsolutePath(), getSolrXml());
  //cores.setPersistent(false);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:AbstractEmbeddedSolrServerTestCase.java

示例2: solrServerFactoryBean

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Bean(name = "solrClient")
public EmbeddedSolrServer solrServerFactoryBean() {
	String solrCoreName = solrSettings.getSolrCoreName();
	String solrHome = solrSettings.getSolrEmbeddedPath();
	Path path = FileSystems.getDefault().getPath(solrHome);
	CoreContainer container = CoreContainer.createAndLoad(path);
	return new EmbeddedSolrServer(container, solrCoreName);
}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:9,代碼來源:EmbeddedSolrContext.java

示例3: getInstance

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Override
public SolrClient getInstance() {
    try {
        final Path tmpSolrHome = Files.createTempDirectory("solr-home");
        final Path solrHome = FileSystemUtils.toPath(this.getClass().getResource(HOME_PATH));

        Files.walkFileTree(solrHome, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new TreeCopier(solrHome, tmpSolrHome));

        final Path tmpSolrConfig = tmpSolrHome.resolve(SolrXmlConfig.SOLR_XML_FILE);

        // Needed for the tests. For some reason Solr is not replacing the solrConfig.xml ${runtimeLib} property with
        // the system property value but with the defined in the core.properties file.
        final String runtimeLib = System.getProperty("runtimeLib");
        if (Objects.nonNull(runtimeLib) && runtimeLib.equals("false")){
            final Properties properties = new Properties();
            final String corePropertiesFile = String.join("/",tmpSolrHome.toAbsolutePath().toString(),CORE_NAME,CORE_PROPERTIES_FILE);
            final FileInputStream iS = new FileInputStream(corePropertiesFile);
            properties.load(iS);
            iS.close();
            properties.setProperty("runtimeLib", "false");

            final FileOutputStream oS = new FileOutputStream(tmpSolrHome.toAbsolutePath().toString()+ "/core/" + CORE_PROPERTIES_FILE);
            properties.store(oS, null);
            oS.close();
        }

        final CoreContainer container = CoreContainer.createAndLoad(tmpSolrHome, tmpSolrConfig);
        return new SolrClientWrapper(container, CORE_NAME, tmpSolrHome);

    } catch (URISyntaxException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:RBMHTechnology,項目名稱:vind,代碼行數:34,代碼來源:EmbeddedSolrServerProvider.java

示例4: testMultiCoreConfBootstrap

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@Test
public void testMultiCoreConfBootstrap() throws Exception {
  System.setProperty("bootstrap_conf", "true");
  cores = CoreContainer.createAndLoad(home, new File(home, "solr.xml"));
  SolrZkClient zkclient = cores.getZkController().getZkClient();
  // zkclient.printLayoutToStdOut();
  
  assertTrue(zkclient.exists("/configs/core1/solrconfig.xml", true));
  assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
  assertTrue(zkclient.exists("/configs/core0/solrconfig.xml", true));
  assertTrue(zkclient.exists("/configs/core1/schema.xml", true));
  
  zkclient.close();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:15,代碼來源:TestMultiCoreConfBootstrap.java

示例5: initSolrServer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
@BeforeClass
public static void initSolrServer() throws IOException, ParserConfigurationException, SAXException,
		InterruptedException {
	String solrHome = ResourceUtils.getURL("classpath:org/springframework/data/solr").getPath();
	CoreContainer coreContainer = CoreContainer.createAndLoad(solrHome, new File(solrHome + "/solr.xml"));
	solrServer = new EmbeddedSolrServer(coreContainer, "collection1");
}
 
開發者ID:ramaava,項目名稱:spring-data-solr,代碼行數:8,代碼來源:AbstractITestWithEmbeddedSolrServer.java

示例6: SolrSearchServiceImpl

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
public SolrSearchServiceImpl(String solrServer) throws IOException, ParserConfigurationException, SAXException {
    if ("solrhome".equals(solrServer)) {

        final String baseTempPath = System.getProperty("java.io.tmpdir");

        File tempDir = new File(baseTempPath + File.separator + System.getProperty("user.name") + File.separator + "solrhome");
        if (System.getProperty("tmpdir.solrhome") != null) {
            //allow for an override of tmpdir
            tempDir = new File(System.getProperty("tmpdir.solrhome"));
        }
        if (!tempDir.exists()) {
            tempDir.mkdirs();
        }
        
        solrServer = tempDir.getAbsolutePath();
        
        // create the 'lib' directory with a placeholder file that has to exist in Solr's home directory to avoid a
        // warning log message
        String libDir = FilenameUtils.concat(solrServer, "lib");
        LOG.debug("Creating Solr home lib directory: " + libDir);
        new File(libDir).mkdir();
        
        String placeholder = FilenameUtils.concat(libDir, "solrlib_placeholder.deleteme");
        LOG.debug("Creating Solr lib placeholder file: " + placeholder);
        new File(placeholder).createNewFile();
    }
    
    File solrXml = new File(new File(solrServer), "solr.xml");
    if (!solrXml.exists()) {
        copyConfigToSolrHome(this.getClass().getResourceAsStream("/solr-default.xml"), solrXml);
    }

    LOG.debug(String.format("Using [%s] as solrhome", solrServer));
    LOG.debug(String.format("Using [%s] as solr.xml", solrXml.getAbsoluteFile()));
    
    if (LOG.isTraceEnabled()) {
        LOG.trace("Contents of solr.xml:");
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(solrXml));
            String line;
            while ((line = br.readLine()) != null) {
                LOG.trace(line);
            }
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (Throwable e) {
                    //do nothing
                }
            }
        }
        LOG.trace("Done printing solr.xml");
    }

    CoreContainer coreContainer = CoreContainer.createAndLoad(solrServer, solrXml);
    EmbeddedSolrServer primaryServer = new EmbeddedSolrServer(coreContainer, SolrContext.PRIMARY);
    EmbeddedSolrServer reindexServer = new EmbeddedSolrServer(coreContainer, SolrContext.REINDEX);

    SolrContext.setPrimaryServer(primaryServer);
    SolrContext.setReindexServer(reindexServer);
    //NOTE: There is no reason to set the admin server here as the SolrContext will return the primary server
    //if the admin server is not set...
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:66,代碼來源:SolrSearchServiceImpl.java

示例7: SolrSearchServiceImpl

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
public SolrSearchServiceImpl(String solrServer) throws IOException, ParserConfigurationException, SAXException {
    if ("solrhome".equals(solrServer)) {

        final String baseTempPath = System.getProperty("java.io.tmpdir");

        File tempDir = new File(baseTempPath + File.separator + System.getProperty("user.name") + File.separator + "solrhome-4.10.3");
        if (System.getProperty("tmpdir.solrhome") != null) {
            //allow for an override of tmpdir
            tempDir = new File(System.getProperty("tmpdir.solrhome"));
        }
        if (!tempDir.exists()) {
            tempDir.mkdirs();
        }

        solrServer = tempDir.getAbsolutePath();
    }
    solrHomePath = solrServer;

    File solrXml = new File(new File(solrServer), "solr.xml");
    if (!solrXml.exists()) {
        copyConfigToSolrHome(this.getClass().getResourceAsStream("/solr-default.xml"), solrXml);
    }

    buildSolrCoreDirectories(solrServer);

    LOG.debug(String.format("Using [%s] as solrhome", solrServer));
    LOG.debug(String.format("Using [%s] as solr.xml", solrXml.getAbsoluteFile()));
    
    if (LOG.isTraceEnabled()) {
        LOG.trace("Contents of solr.xml:");
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(solrXml));
            String line;
            while ((line = br.readLine()) != null) {
                LOG.trace(line);
            }
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (Throwable e) {
                    //do nothing
                }
            }
        }
        LOG.trace("Done printing solr.xml");
    }

    CoreContainer coreContainer = CoreContainer.createAndLoad(solrServer, solrXml);
    EmbeddedSolrServer primaryServer = new EmbeddedSolrServer(coreContainer, SolrContext.PRIMARY);
    EmbeddedSolrServer reindexServer = new EmbeddedSolrServer(coreContainer, SolrContext.REINDEX);

    SolrContext.setPrimaryServer(primaryServer);
    SolrContext.setReindexServer(reindexServer);
    //NOTE: There is no reason to set the admin server here as the SolrContext will return the primary server
    //if the admin server is not set...
}
 
開發者ID:takbani,項目名稱:blcdemo,代碼行數:59,代碼來源:SolrSearchServiceImpl.java

示例8: createCoreContainer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
/**
 * Create {@link org.apache.solr.core.CoreContainer} for Solr version 4.4+
 * 
 * @param solrHomeDirectory
 * @param solrXmlFile
 * @return
 */
private CoreContainer createCoreContainer(String solrHomeDirectory, File solrXmlFile) {
	return CoreContainer.createAndLoad(solrHomeDirectory, solrXmlFile);
}
 
開發者ID:yiduwangkai,項目名稱:dubbox-solr,代碼行數:11,代碼來源:EmbeddedSolrServerFactory.java

示例9: createCoreContainer

import org.apache.solr.core.CoreContainer; //導入方法依賴的package包/類
/**
 * Create {@link CoreContainer} for Solr version 4.4+
 * 
 * @param solrHomeDirectory
 * @param solrXmlFile
 * @return
 */
private CoreContainer createCoreContainer(String solrHomeDirectory, File solrXmlFile) {
	return CoreContainer.createAndLoad(solrHomeDirectory, solrXmlFile);
}
 
開發者ID:ramaava,項目名稱:spring-data-solr,代碼行數:11,代碼來源:EmbeddedSolrServerFactory.java


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