Package org.apache.solr.core

Examples of org.apache.solr.core.CoreContainer


    // // a workaround to keep the data import handlers happy since they use a
    // // relative path
    // System.setProperty("solr.data.dir", getDataDir());

    // initialize the core container
    CoreContainer coreContainer = null;
    final CoreContainer.Initializer initializer = new CoreContainer.Initializer();
    try {
      // coreContainer.load(getSolrHome(), solrXml);
      coreContainer = initializer.initialize();
    }
View Full Code Here


    static final String SOLR_HOME_PATH = "/solr";

    public static SolrServer createSolrServer() {
        String homePath = SolrServerProvider.class.getResource(SOLR_HOME_PATH).getFile();
        CoreContainer coreContainer = new CoreContainer(homePath);
        try {
            coreContainer.load();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
        return new EmbeddedSolrServer(coreContainer, "oak");
    }
View Full Code Here

                return new HttpWithJettySolrServer(SolrServerConfigurationDefaults.LOCAL_BASE_URL + ':' + httpPort + context + '/' + coreName, jettySolrRunner);
            } else {
                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(CoreContainer.class.getClassLoader());

                CoreContainer coreContainer = new CoreContainer(solrHomePath);
                try {
                    coreContainer.load();
                } finally {
                    Thread.currentThread().setContextClassLoader(classLoader);
                }

                EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer, coreName);
View Full Code Here

  @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"));

    for (SolrCore core : coreContainer.getCores()) {
      core.addCloseHook(new CloseHook() {
        @Override
        public void preClose(SolrCore core) {}

        @Override
View Full Code Here

   * @see DATASOLR-203
   */
  @Test
  public void cloningEmbeddedSolrServerShouldReuseCoreContainer() {

    CoreContainer coreContainer = Mockito.mock(CoreContainer.class);
    EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, null);

    EmbeddedSolrServer clone = SolrServerUtils.clone(solrServer, "core1");
    Assert.assertThat(clone.getCoreContainer(), IsSame.sameInstance(coreContainer));
  }
View Full Code Here

            throw new IllegalArgumentException("missing test solrconfig.xml file");
        }
        IOUtils.copy(is, new FileOutputStream(solrConfigFile));

        // create the embedded server
        CoreContainer coreContainer = new CoreContainer(solrFolder.getAbsolutePath(), solrFile);
        return new EmbeddedSolrServer(coreContainer, coreId);
    }
View Full Code Here

                    "Unable to copy default configuration for the manages Solr " +
                    "Directory to the configured path '%s'!",
                     managedSolrDir.getAbsoluteFile()), e);
            }
        }
        server = new CoreContainer(managedSolrDir.getAbsolutePath());
        File solrXml = new File(managedSolrDir,"solr.xml");
        try {
            server.load(managedSolrDir.getAbsolutePath(), solrXml);
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException("Unable to initialise XML parsers for parsing 'solr.xml'",e);
View Full Code Here

    final File solrHome = findSolrHome(context);

    final File dataDir = findSolrDataDir(env);

    final Map<String, String> coreDefs = new LinkedHashMap<String, String>();
    CoreContainer cores = new CoreContainer(solrHome.getAbsolutePath()) {
      @Override
      public SolrCore create(final CoreDescriptor coreDescriptor) {
        String coreName = coreDescriptor.getName();
        if (coreName.length() == 0) {
          coreName = getDefaultCoreName();
        }

        Properties properties = new Properties();
        String coreDataDir = new File(dataDir, coreName).getAbsolutePath();
        coreDefs.put(coreName, coreDataDir);
        // default data dir
        properties.setProperty(CoreDescriptor.CORE_DATADIR, coreDataDir);

        return super.create(new CoreDescriptor(coreDescriptor.getCoreContainer(), coreDescriptor
            .getName(), coreDescriptor.getInstanceDir(), properties));
      }
    };
    // Initialize cores
    cores.load();

    logger.info("Solr home directory: {}", solrHome);
    for (Entry<String, String> core : coreDefs.entrySet()) {
      logger.info("  core: {}, dataDir: {}", core.getKey(), core.getValue());
    }
View Full Code Here

  public void runFixtures() {
    Environment env = applicationContext.getEnvironment();
    boolean runFixtures = env.getProperty(SOLR_FIXTURES, boolean.class, true);
    if (runFixtures) {
      Map<String, SolrServer> servers = applicationContext.getBeansOfType(SolrServer.class);
      CoreContainer cores = applicationContext.getBean(CoreContainer.class);
      String solrHome = cores.getSolrHome();

      boolean async = env.getProperty(SOLR_FIXTURES_ASYNC, boolean.class, true);

      for (Entry<String, SolrServer> server : servers.entrySet()) {
        String coreName = server.getKey();
View Full Code Here

    isTrue(solrXml.exists(), "File not found: {}", solrXml);

    final File dataDir = findSolrDataDir(env);

    final Map<String, String> coreDefs = new LinkedHashMap<String, String>();
    CoreContainer cores = new CoreContainer(solrHome.getAbsolutePath(), solrXml) {
      @Override
      public SolrCore create(final CoreDescriptor coreDescriptor)
          throws ParserConfigurationException, IOException, SAXException {
        coreDescriptor.getDataDir();
        String coreName = coreDescriptor.getName();
        if (coreName.length() == 0) {
          coreName = getDefaultCoreName();
        }
        // Set the core data directory.
        String coreDataDir = new File(dataDir, coreName).getAbsolutePath();
        coreDefs.put(coreName, coreDataDir);
        coreDescriptor.setDataDir(coreDataDir);
        return super.create(coreDescriptor);
      }
    };
    // Initialize cores
    cores.load(solrHome.getAbsolutePath(), solrXml);

    logger.info("Solr home directory: {}", solrHome);
    for (Entry<String, String> core : coreDefs.entrySet()) {
      logger.info("  core: {}, dataDir: {}", core.getKey(), core.getValue());
    }
View Full Code Here

TOP

Related Classes of org.apache.solr.core.CoreContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.