/** * Initalize CoreContainer directly from the constructor * * @param dir * @param configFile * @throws ParserConfigurationException * @throws IOException * @throws SAXException */ public CoreContainer(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException { this.load(dir, configFile); }
@Override public void initialize() { File solrHome = new File(this.environment.getPermanentDirectory().getAbsolutePath(), "solr"); this.cores = new CoreContainer(solrHome.getAbsolutePath()); this.cores.load(); }
@Override public void initialize() { File solrHome = new File(this.environment.getPermanentDirectory().getAbsolutePath(), "solr"); this.cores = new CoreContainer(solrHome.getAbsolutePath()); this.cores.load(); }
private void initServer(){ File solrConf = new File(managedSolrDir, "solr.xml"); if (!solrConf.exists()) { try { managedSolrDir = ConfigUtils.copyDefaultConfig((Class<?>) null, managedSolrDir, false); } catch (IOException e) { throw new IllegalStateException(String.format( "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"); server.load(); } private void shutdown() {
private void initServer(){ File solrConf = new File(managedSolrDir, "solr.xml"); if (!solrConf.exists()) { try { managedSolrDir = ConfigUtils.copyDefaultConfig((Class<?>) null, managedSolrDir, false); } catch (IOException e) { throw new IllegalStateException(String.format( "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"); server.load(); } private void shutdown() {
/** * Create a TestHarness using a specific config * @param config the ConfigSolr to use */ public TestHarness(NodeConfig config, CoresLocator coresLocator) { container = new CoreContainer(config, new Properties(), coresLocator); container.load(); updater = new UpdateRequestHandler(); updater.init(null); }
private CoreContainer createCoreContainer(String solrHome) throws SolrServerException { CoreContainer coreContainer = new CoreContainer(solrHome); coreContainer.load(); if (coreContainer.getCores().size() == 0) { throw new SolrServerException("Failed to initialize the Solr core. " + "Please check the configuration and log messages."); } else if (coreContainer.getCores().size() > 1) { this.logger.warn("Multiple Solr cores detected: [{}]. Using the first one.", StringUtils.join(coreContainer.getCoreNames(), ", ")); } return coreContainer; }
container.load(); for (String s : container.getAllCoreNames()) { LOG.warn("Got core name: " + s);
container.load();
container.load();
container.load();
String solrDir = "C:/Program Files/Apache Software Foundation/Tomcat 7.0/webapps/solr/new_core/"; //this solr Directory is home and specified core. //solrParams.set("qt", "/dataimport"); //solrParams.set("command", "full-import"); //above two line for importing data one time. CoreContainer container = new CoreContainer(solrDir); container.load(); EmbeddedSolrServer server = new EmbeddedSolrServer(container, "collection1"); ModifiableSolrParams solrParams = new ModifiableSolrParams(); solrParams.add(CommonParams.Q, "*:*"); QueryResponse queryResponse = server.query(solrParams); for (SolrDocument document : queryResponse.getResults()) { System.out.println(document); }
} else { CoreContainer coreContainer = new CoreContainer(solrHome.getPath()); coreContainer.load(); this.server = new EmbeddedSolrServer(coreContainer, solrCore); log.info("Default Embedded Solr Server Initialized");
coreContainer.load(); CoreDescriptor coreDescriptor = new CoreDescriptor(coreContainer, coreId, solrCoreFolder.getAbsolutePath());
public SolrWriter(KeepAliveHook keepAlive, Fields sinkFields, String dataDirPropertyName, String dataDir, File solrCoreDir, int maxSegments) throws IOException { _keepAlive = keepAlive; _sinkFields = sinkFields; _maxSegments = maxSegments; _updateRequest = new BinaryUpdateRequest(); // Set up overwrite=false. See https://issues.apache.org/jira/browse/SOLR-653 // for details why we have to do it this way. _updateRequest.setParam(UpdateParams.OVERWRITE, Boolean.toString(false)); // Fire up an embedded Solr server try { System.setProperty(dataDirPropertyName, dataDir); System.setProperty("enable.special-handlers", "false"); // All we need is the update request handler System.setProperty("enable.cache-warming", "false"); // We certainly don't need to warm the cache File solrHome = SolrSchemeUtil.makeTempSolrHome(solrCoreDir); _coreContainer = new CoreContainer(solrHome.getAbsolutePath()); _coreContainer.load(); _solrServer = new EmbeddedSolrServer(_coreContainer, solrCoreDir.getName()); } catch (Exception e) { if (_coreContainer != null) { _coreContainer.shutdown(); } throw new IOException(e); } }
container.load();
public SolrServer getSolrServer() { if (zkHost != null && zkHost.length() > 0) { if (collectionName == null || collectionName.length() == 0) { throw new MorphlineCompilationException("Parameter 'zkHost' requires that you also pass parameter 'collection'", config); } CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost); cloudSolrServer.setDefaultCollection(collectionName); return cloudSolrServer; } else { if (solrUrl == null && solrHomeDir != null) { CoreContainer coreContainer = new CoreContainer(solrHomeDir); coreContainer.load(); EmbeddedSolrServer embeddedSolrServer = new EmbeddedSolrServer(coreContainer, collectionName); return embeddedSolrServer; } if (solrUrl == null || solrUrl.length() == 0) { throw new MorphlineCompilationException("Missing parameter 'solrUrl'", config); } int solrServerNumThreads = 2; int solrServerQueueLength = solrServerNumThreads; SolrServer server = new SafeConcurrentUpdateSolrServer(solrUrl, solrServerQueueLength, solrServerNumThreads); return server; } }
public void setUp() { try { String dataDir = System.getProperty("CHUKWA_DATA_DIR", "target/test/var"); container = new CoreContainer(dataDir); container.load(); server = new EmbeddedSolrServer(container, "collection1" ); super.setUp(); } catch (Exception e) { log.error(ExceptionUtil.getStackTrace(e)); Assert.fail(e.getMessage()); } }
public SolrClient getSolrServer() { if (zkHost != null && zkHost.length() > 0) { if (collectionName == null || collectionName.length() == 0) { throw new MorphlineCompilationException("Parameter 'zkHost' requires that you also pass parameter 'collection'", config); } CloudSolrClient cloudSolrClient = new Builder() .withZkHost(zkHost) .build(); cloudSolrClient.setDefaultCollection(collectionName); cloudSolrClient.setZkClientTimeout(zkClientSessionTimeout); cloudSolrClient.setZkConnectTimeout(zkClientConnectTimeout); return cloudSolrClient; } else { if (solrUrl == null && solrHomeDir != null) { CoreContainer coreContainer = new CoreContainer(solrHomeDir); coreContainer.load(); EmbeddedSolrServer embeddedSolrServer = new EmbeddedSolrServer(coreContainer, collectionName); return embeddedSolrServer; } if (solrUrl == null || solrUrl.length() == 0) { throw new MorphlineCompilationException("Missing parameter 'solrUrl'", config); } int solrServerNumThreads = 2; int solrServerQueueLength = solrServerNumThreads; SolrClient server = new SafeConcurrentUpdateSolrServer(solrUrl, solrServerQueueLength, solrServerNumThreads); return server; } }
cores.load(solrHome, fconf); abortOnConfigurationError = false;