Package org.apache.solr.core

Examples of org.apache.solr.core.SolrResourceLoader


public final class SolrConsumerTestCase {

    private SolrServer solr;

    public SolrConsumerTestCase() throws ParserConfigurationException, IOException, SAXException {
        SolrResourceLoader loader = new SolrResourceLoader("solr");
        CoreContainer container = new CoreContainer(loader);
        CoreDescriptor descriptor = new CoreDescriptor(container, "cname", ".");
        SolrCore core = container.create(descriptor);
        container.register(core.getName(), core, false);
        this.solr = new EmbeddedSolrServer(container, core.getName());
View Full Code Here


                //TODO: add support for ZooKeeper managed cores
                return super.create(dcore);
            } else {
                File idir = new File(dcore.getInstanceDir());
                String instanceDir = idir.getPath();
                SolrResourceLoader loader = new OsgiSolrResourceLoader(context, instanceDir,
                    CoreContainer.class.getClassLoader());
                SolrConfig config;
                try {
                    config = new SolrConfig(loader, dcore.getConfigName(), null);
                } catch (Exception e) {
                    log.error("Failed to load file {}", new File(instanceDir, dcore.getConfigName()).getAbsolutePath());
                    throw new SolrException(ErrorCode.SERVER_ERROR, "Could not load config for " + dcore.getConfigName(), e);
                }
                IndexSchema schema = null;
                //indexSchemaCache is now protected (Solr 4.4)
                if (indexSchemaCache != null) {
                  final String resourceNameToBeUsed = IndexSchemaFactory.getResourceNameToBeUsed(dcore.getSchemaName(), config);
                  File schemaFile = new File(resourceNameToBeUsed);
                  if (!schemaFile.isAbsolute()) {
                    schemaFile = new File(loader.getConfigDir(), schemaFile.getPath());
                  }
                  if (schemaFile.exists()) {
                    String key = schemaFile.getAbsolutePath()
                        + ":"
                        + new SimpleDateFormat("yyyyMMddHHmmss", Locale.ROOT).format(new Date(
View Full Code Here

        File solrCof = new File(solrDir,parsedServerProperties.getSolrXml());
        ClassLoader classLoader = updateContextClassLoader();
        CoreContainer container;
        try {
            log.info("   ... create OSGI enabled SolrCore (conf: {}",solrCof);
            SolrResourceLoader loader = new OsgiSolrResourceLoader(context, solrDir.getAbsolutePath(),
                SolrServerAdapter.class.getClassLoader());
            container = new OsgiCoreContainer(loader, context,solrCof);
        } finally {
            Thread.currentThread().setContextClassLoader(classLoader);
        }
View Full Code Here

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

        // create the embedded server
        SolrResourceLoader loader = new SolrResourceLoader(solrFolder.getAbsolutePath());
        CoreContainer coreContainer = new CoreContainer(loader);
        //NOTE: with Solr 4.4 we need to call coreContainer.load() otherwise we
        //would be affected by the issue stated at
        //http://mail-archives.apache.org/mod_mbox/lucene-solr-user/201301.mbox/%3CB7B8B36F1A0BE24F842758C318E56E925EB334%40EXCHDB2.na1.ad.group%3E
        //while this was introduced with 4.1 this only affects this code with 4.4
View Full Code Here

  public static Dictionary getDict(String dicPath, ResourceLoader loader) {
    Dictionary dic = null;
    if(dicPath != null) {
      File f = new File(dicPath);
      if(!f.isAbsolute() && loader instanceof SolrResourceLoader) {  //相对目录
        SolrResourceLoader srl = (SolrResourceLoader) loader;
        dicPath = srl.getInstanceDir()+dicPath;
        f = new File(dicPath);
      }

      dic = Dictionary.getInstance(f);
    } else {
View Full Code Here

  @Override
  public void setUp() throws Exception {
    super.setUp();

    SolrResourceLoader loader = new SolrResourceLoader(getSolrHome());
    CoreContainer container = new CoreContainer(loader);
    CoreDescriptor descriptor = new CoreDescriptor(container, "cname", ".");
    SolrCore core = container.create(descriptor);
    container.register(core.getName(), core, false);
View Full Code Here

        }
      }
     
      LOG.debug("SolrLocator loading IndexSchema from dir {}", mySolrHomeDir);
      try {
        SolrResourceLoader loader = new SolrResourceLoader(mySolrHomeDir);
        SolrConfig solrConfig = new SolrConfig(loader, "solrconfig.xml", null);
       
        IndexSchema schema = IndexSchemaFactory.buildIndexSchema("schema.xml", solrConfig);
        validateSchema(schema);
        return schema;
View Full Code Here

      }
    }
   
    LOG.debug("SolrLocator loading IndexSchema from dir {}", mySolrHomeDir);
    try {
      SolrResourceLoader loader = new SolrResourceLoader(mySolrHomeDir);
      SolrConfig solrConfig = new SolrConfig(loader, "solrconfig.xml", null);
      InputSource is = new InputSource(loader.openSchema("schema.xml"));
      is.setSystemId(SystemIdResolver.createSystemIdFromResourceName("schema.xml"));
     
      IndexSchema schema = new IndexSchema(solrConfig, "schema.xml", is);
      validateSchema(schema);
      return schema;
View Full Code Here

      FileUtils.copyDirectory(new File(unpackedSolrHome, "conf"), confDir);

      Properties props = new Properties();
      props.setProperty("solr.data.dir", dataDir);
      props.setProperty("solr.home", solrHome.toString());
      SolrResourceLoader loader = new SolrResourceLoader(solrHome.toString(), null, props);
      LOG.info(String
          .format(
              "Constructed instance information solr.home %s (%s), instance dir %s, conf dir %s, writing index to temporary directory %s, with permdir %s",
              solrHome, solrHome.toUri(), loader.getInstanceDir(), loader.getConfigDir(), dataDir, perm));
      CoreContainer container = new CoreContainer(loader);
      CoreDescriptor descr = new CoreDescriptor(container, "core1", solrHome.toString());
      descr.setDataDir(dataDir);
      descr.setCoreProperties(props);
      core = container.create(descr);
View Full Code Here

      FileUtils.copyDirectory(new File(unpackedSolrHome, "conf"), confDir);

      Properties props = new Properties();
      props.setProperty("solr.data.dir", dataDir);
      props.setProperty("solr.home", solrHome.toString());
      SolrResourceLoader loader = new SolrResourceLoader(solrHome.toString(), null, props);
      LOG.info(String
          .format(
              "Constructed instance information solr.home %s (%s), instance dir %s, conf dir %s, writing index to temporary directory %s, with permdir %s",
              solrHome, solrHome.toUri(), loader.getInstanceDir(), loader.getConfigDir(), dataDir, perm));
      CoreContainer container = new CoreContainer(loader);
      CoreDescriptor descr = new CoreDescriptor(container, "core1", solrHome.toString());
      descr.setDataDir(dataDir);
      descr.setCoreProperties(props);
      core = container.create(descr);
View Full Code Here

TOP

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

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.