当前位置: 首页>>代码示例>>Java>>正文


Java CoreContainer类代码示例

本文整理汇总了Java中org.apache.solr.core.CoreContainer的典型用法代码示例。如果您正苦于以下问题:Java CoreContainer类的具体用法?Java CoreContainer怎么用?Java CoreContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CoreContainer类属于org.apache.solr.core包,在下文中一共展示了CoreContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activateSolr

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
@Override
public void activateSolr() throws Exception
{
   ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
   Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );

   try
   {
      File directory = new File( fileConfig.dataDirectory(), descriptor.identity().toString() );
      directory.mkdirs();

      System.setProperty( "solr.solr.home", directory.getAbsolutePath() );

      CoreContainer.Initializer initializer = new CoreContainer.Initializer();
      coreContainer = initializer.initialize();
      server = new EmbeddedSolrServer( coreContainer, "" );
      core = coreContainer.getCore( "" );
   } finally
   {
      Thread.currentThread().setContextClassLoader( oldCl );
   }
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:23,代码来源:EmbeddedSolrService.java

示例2: create

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
/**
 *
 * @param solrHome
 *              path to directory where solr.xml lives
 *
 * @param coreName
 *              the name of the core to load
 * @param dataDir
 *              the data dir for the core
 *
 * @return an EmbeddedSolrServer for the given core
 */
public static SolrClient create(String solrHome, String coreHome, String coreName, String dataDir) throws IOException {
    File coreDataDir = new File(dataDir + "/" + coreName);
    if (coreDataDir.exists()) {
       FileUtils.deleteDirectory(coreDataDir);
    }

    CoreContainer coreContainer = new CoreContainer(solrHome);
    coreContainer.load();

    Properties props = new Properties();
    props.setProperty("dataDir", dataDir + "/" + coreName);

    CoreDescriptor descriptor = new CoreDescriptor(coreContainer, coreName,
            new File(coreHome, coreName).getAbsolutePath(), props);

    SolrCore solrCore = coreContainer.create(descriptor);
    //coreContainer.register(solrCore, false);
    return new EmbeddedSolrServer(coreContainer, coreName);
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:32,代码来源:EmbeddedSolrServerFactory.java

示例3: 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

示例4: kill

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
public static void kill(JettySolrRunner jetty) throws Exception {
  FilterHolder filterHolder = jetty.getDispatchFilter();
  if (filterHolder != null) {
    Filter filter = filterHolder.getFilter();
    if (filter != null) {
      CoreContainer cores = ((SolrDispatchFilter) filter).getCores();
      if (cores != null) {
        int zklocalport = ((InetSocketAddress) cores.getZkController()
            .getZkClient().getSolrZooKeeper().getSocketAddress()).getPort();
        IpTables.blockPort(zklocalport);
      }
    }
  }

  IpTables.blockPort(jetty.getLocalPort());
  
  monkeyLog("kill shard! " + jetty.getLocalPort());
  
  jetty.stop();
  
  stop(jetty);
  
  if (!jetty.isStopped()) {
    throw new RuntimeException("could not kill jetty");
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:ChaosMonkey.java

示例5: TestHarness

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
/**
 * @param coreName to initialize
 * @param dataDir path for index data, will not be cleaned up
 * @param solrConfig solrconfig resource name
 * @param indexSchema schema resource name
 */
public TestHarness(String coreName, String dataDir, String solrConfig, String indexSchema) {
  try {
    if (coreName == null)
      coreName = ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME;
    this.coreName = coreName;

    SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
    ConfigSolr config = getTestHarnessConfig(loader, coreName, dataDir, solrConfig, indexSchema);
    container = new CoreContainer(loader, config);
    container.load();

    updater = new UpdateRequestHandler();
    updater.init( null );
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:TestHarness.java

示例6: EmbeddedSolrServer

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
/**
 * Use the other constructor using a CoreContainer and a name.
 * @deprecated use {@link #EmbeddedSolrServer(CoreContainer, String)} instead.
 */
@Deprecated
public EmbeddedSolrServer( SolrCore core )
{
  if ( core == null ) {
    throw new NullPointerException("SolrCore instance required");
  }
  CoreDescriptor dcore = core.getCoreDescriptor();
  if (dcore == null)
    throw new NullPointerException("CoreDescriptor required");
  
  CoreContainer cores = dcore.getCoreContainer();
  if (cores == null)
    throw new NullPointerException("CoreContainer required");
  
  coreName = dcore.getName();
  coreContainer = cores;
  _parser = new SolrRequestParsers( null );
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:EmbeddedSolrServer.java

示例7: LeaderInitiatedRecoveryThread

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
public LeaderInitiatedRecoveryThread(ZkController zkController, 
                                     CoreContainer cc, 
                                     String collection, 
                                     String shardId, 
                                     ZkCoreNodeProps nodeProps,
                                     int maxTries,
                                     String leaderCoreNodeName)
{
  super("LeaderInitiatedRecoveryThread-"+nodeProps.getCoreName());
  this.zkController = zkController;
  this.coreContainer = cc;
  this.collection = collection;
  this.shardId = shardId;    
  this.nodeProps = nodeProps;
  this.maxTries = maxTries;
  this.leaderCoreNodeName = leaderCoreNodeName;
  
  setDaemon(true);
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:LeaderInitiatedRecoveryThread.java

示例8: bootstrapConf

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
/**
 * If in SolrCloud mode, upload config sets for each SolrCore in solr.xml.
 */
public static void bootstrapConf(SolrZkClient zkClient, CoreContainer cc, String solrHome) throws IOException,
    KeeperException, InterruptedException {

  //List<String> allCoreNames = cfg.getAllCoreNames();
  List<CoreDescriptor> cds = cc.getCoresLocator().discover(cc);
  
  log.info("bootstrapping config for " + cds.size() + " cores into ZooKeeper using solr.xml from " + solrHome);

  for (CoreDescriptor cd : cds) {
    String coreName = cd.getName();
    String confName = cd.getCollectionName();
    if (StringUtils.isEmpty(confName))
      confName = coreName;
    String instanceDir = cd.getInstanceDir();
    File udir = new File(instanceDir, "conf");
    log.info("Uploading directory " + udir + " with name " + confName + " for SolrCore " + coreName);
    ZkController.uploadConfigDir(zkClient, udir, confName);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:ZkController.java

示例9: checkForSingleIndex

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
private void checkForSingleIndex(JettySolrRunner jetty) {
  CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter().getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    String ddir = core.getDataDir();
    CachingDirectoryFactory dirFactory = (CachingDirectoryFactory) core.getDirectoryFactory();
    synchronized (dirFactory) {
      Set<String> livePaths = dirFactory.getLivePaths();
      // one for data, one for hte index under data
      assertEquals(livePaths.toString(), 2, livePaths.size());
      // :TODO: assert that one of the paths is a subpath of hte other
    }
    if (dirFactory instanceof StandardDirectoryFactory) {
      System.out.println(Arrays.asList(new File(ddir).list()));
      assertEquals(Arrays.asList(new File(ddir).list()).toString(), 1, indexDirCount(ddir));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestReplicationHandler.java

示例10: setupContainer

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
private void setupContainer(int port, String shard) throws IOException,
    ParserConfigurationException, SAXException {
  File data = createTempDir();
  
  System.setProperty("hostPort", Integer.toString(port));
  System.setProperty("shard", shard);
  System.setProperty("solr.data.dir", data.getAbsolutePath());
  System.setProperty("solr.solr.home", TEST_HOME());
  Set<Integer> ports = shardPorts.get(shard);
  if (ports == null) {
    ports = new HashSet<>();
    shardPorts.put(shard, ports);
  }
  ports.add(port);
  CoreContainer container = new CoreContainer();
  container.load();
  assertTrue("Container " + port + " has no cores!", container.getCores()
      .size() > 0);
  containerMap.put(port, container);
  System.clearProperty("solr.solr.home");
  System.clearProperty("hostPort");
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:LeaderElectionIntegrationTest.java

示例11: checkInstanceDirs

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
private void checkInstanceDirs(JettySolrRunner jetty) {
  CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter()
      .getFilter()).getCores();
  Collection<SolrCore> theCores = cores.getCores();
  for (SolrCore core : theCores) {
    if (!oldStyleSolrXml) {
      // look for core props file
      assertTrue("Could not find expected core.properties file",
          new File((String) core.getStatistics().get("instanceDir"),
              "core.properties").exists());
    }
    
    assertEquals(
       new File(SolrResourceLoader.normalizeDir(jetty.getSolrHome() + File.separator
            + core.getName())).getAbsolutePath(),
        new File(SolrResourceLoader.normalizeDir((String) core.getStatistics().get(
            "instanceDir"))).getAbsolutePath());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:CollectionsAPIDistributedZkTest.java

示例12: createSolrServer

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
private EmbeddedSolrServer createSolrServer(Map<String,String> urlParams) {
    String solrHome = urlParams.get("SOLR_HOME");
    StringBuilder paramStr = new StringBuilder();
    if (solrHome != null) {
        System.setProperty("solr.solr.home", solrHome);
        paramStr.append(";SOLR_HOME=").append(solrHome);
    }
    String dataDir = urlParams.get("DATA_DIR");
    if (dataDir != null) {
        System.setProperty("solr.data.dir", dataDir);
        paramStr.append(";DATA_DIR=").append(dataDir);
    }
    try {
        DriverManager.getConnection("jdbc:solr:s" + paramStr.toString());
    } catch (SQLException e) {
        throw new SQLRuntimeException(e);
    }
    CoreContainer.Initializer initializer = new CoreContainer.Initializer();
    CoreContainer coreContainer = initializer.initialize();
    return new EmbeddedSolrServer(coreContainer, coreContainer.getDefaultCoreName());

}
 
开发者ID:coastland,项目名称:gsp-dba-maven-plugin,代码行数:23,代码来源:SolrDialect.java

示例13: startSolr

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
/**
     * Start up an embedded Solr server.
     *
     * @param home The path to the Solr home directory
     * @return EmbeddedSolrServer: The instantiated server
     * @throws Exception if any errors occur
     */
    private EmbeddedSolrServer startSolr(String home) throws Exception {
        try {
            SolrConfig solrConfig = new SolrConfig(home, SOLR_CONFIG, null);
            IndexSchema schema = new IndexSchema(solrConfig, SOLR_SCHEMA, null);

            solrContainer = new CoreContainer(new SolrResourceLoader(
                    SolrResourceLoader.locateSolrHome()));
            CoreDescriptor descriptor = new CoreDescriptor(solrContainer, "",
                    solrConfig.getResourceLoader().getInstanceDir());
            descriptor.setConfigName(solrConfig.getResourceName());
            descriptor.setSchemaName(schema.getResourceName());

            solrCore = new SolrCore(null, solrConfig.getDataDir(),
                    solrConfig, schema, descriptor);
            solrContainer.register("cheese", solrCore, false);
//            CoreAdminRequest.create
            return new EmbeddedSolrServer(solrContainer, "cheese");
        } catch(Exception ex) {
            log.error("\nFailed to start Solr server\n");
            throw ex;
        }
    }
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:GeonamesIndexGenerator.java

示例14: createEmbeddedSolrServer

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
public static EmbeddedSolrServer createEmbeddedSolrServer(String solrHome, boolean recreateDataDir) {
    logger.info(format("Creating embedded SOLr server. Solr home: %s, recreateDataDir: %s.",
            solrHome, recreateDataDir));

    if (recreateDataDir) {
        File dataDir = new File(solrHome, String.join("/", DEFAULT_CORE_NAME, DEFAULT_DATA_DIR_NAME));
        if (dataDir.exists() && !FileUtils.deleteQuietly(dataDir)) {
            String msg = format("Unable to delete SOLr data dir %s.", dataDir);
            logger.fatal(msg);
            throw new IllegalStateException(msg);
        }
    }


    CoreContainer coreContainer = Value.with(new CoreContainer(solrHome), CoreContainer::load);

    return new EmbeddedSolrServer(coreContainer, DEFAULT_CORE_NAME);
}
 
开发者ID:imCodePartnerAB,项目名称:imcms,代码行数:19,代码来源:SolrServerFactory.java

示例15: setUp

import org.apache.solr.core.CoreContainer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Path carbonHome = Paths.get("target", "test-classes", "carbon-home");
    System.setProperty("carbon.home", carbonHome.toString());
    Path registryPath = IndexingTestUtils.getResourcePath("registry-indexing.xml");
    System.setProperty("wso2.registry.xml", registryPath.toString());
    System.setProperty("carbon.home", registryPath.toString());
    Path resourcePath = IndexingTestUtils.getResourcePath("conf");
    System.setProperty("carbon.config.dir.path", resourcePath.toString());

    CoreContainer coreContainer = mock(CoreContainer.class);
    whenNew(CoreContainer.class).withParameterTypes(String.class).withArguments(anyString())
            .thenReturn(coreContainer);
    server = mock(EmbeddedSolrServer.class);
    whenNew(EmbeddedSolrServer.class).withParameterTypes(CoreContainer.class, String.class).withArguments
            (anyObject(), anyString()).thenReturn(server);
    client = SolrClient.getInstance();
    MessageContext.currentMessageContext.remove();
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:20,代码来源:SolrClientTest.java


注:本文中的org.apache.solr.core.CoreContainer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。