@Override public void initialize() throws InitializationException { this.server = new EmbeddedSolrServer(this.cores.getContainer(), "patients"); }
@Override public void createReplacementCore(Vocabulary vocabulary) throws InitializationException { try { final String replacementCoreId = vocabulary.getIdentifier() + TEMP; final String absPath = this.environment.getPermanentDirectory().getAbsolutePath(); File tempDirectory = new File(absPath, SOLR + replacementCoreId); if (!tempDirectory.exists()) { Files.createDirectories(tempDirectory.toPath()); } CoreContainer container = this.coreContainer.getContainer(); File configOrigin = new File(absPath, SOLR + vocabulary.getIdentifier() + "/conf"); File configTemp = new File(absPath, SOLR + replacementCoreId + "/conf"); FileUtils.copyDirectory(configOrigin, configTemp); container.create(replacementCoreId, Collections.<String, String>emptyMap()); SolrClient core = new EmbeddedSolrServer(container, replacementCoreId); this.cores.put(replacementCoreId, core); } catch (IOException ex) { throw new InitializationException("Invalid Solr resource: " + ex.getMessage(), ex); } }
@Override public void discardReplacementCore(Vocabulary vocabulary) { final String replacementCoreId = vocabulary.getIdentifier() + TEMP; if (this.cores.containsKey(replacementCoreId)) { CoreContainer container = this.coreContainer.getContainer(); SolrCore solrCore = container.getCore(replacementCoreId); if (solrCore != null) { solrCore.close(); } container.unload(replacementCoreId, true, true, true); this.cores.remove(replacementCoreId); this.caches.remove(replacementCoreId); } } }
@Override public void replaceCore(Vocabulary vocabulary) throws InitializationException { final String absPath = this.environment.getPermanentDirectory().getAbsolutePath(); final File indexOrigin = new File(absPath, SOLR + vocabulary.getIdentifier() + "/data"); final File indexTemp = new File(absPath, SOLR + vocabulary.getIdentifier() + TEMP + "/data"); try { CoreContainer container = this.coreContainer.getContainer(); SolrCore solrCore = container.getCore(vocabulary.getIdentifier()); if (solrCore != null) { solrCore.close(); } container.unload(vocabulary.getIdentifier(), true, false, false); FileUtils.copyDirectory(indexTemp, indexOrigin); initialize(vocabulary); } catch (IOException ex) { ex.printStackTrace(); } }
private void initialize(Vocabulary vocabulary) throws InitializationException final CoreContainer container = this.coreContainer.getContainer(); final String coreIdentifier = vocabulary.getIdentifier(); SolrCore solrCore = container.getCore(coreIdentifier);