@Inject public FSIndexDirectory(Config config) { String directoryName = config.getString("core.index_directory"); if (directory == null) { File file; try { file = FileUtils.createDirIfNotExists(directoryName, ""); } catch (PersistenceException e) { throw new IndexException("Cannot create index directory " + directoryName, e); } try { directory = FSDirectory.open(file); } catch (IOException e) { throw new IndexException("Cannot open index directory " + directoryName, e); } } }
private void updateIndex(ReadableWaveletData wavelet) throws IndexException { Preconditions.checkNotNull(wavelet); try { // TODO (Yuri Z): Update documents instead of totally removing and adding. removeIndex(wavelet, nrtManager); addIndex(wavelet, nrtManager); indexWriter.commit(); } catch (IOException e) { throw new IndexException(String.valueOf(wavelet.getWaveletId()), e); } }
@Override protected void postIndexHook() { try { getWaveMap().unloadAllWavelets(); } catch (WaveletStateException e) { throw new IndexException("Problem encountered while cleaning up", e); } }
@Override protected void postIndexHook() { try { getWaveMap().unloadAllWavelets(); } catch (WaveletStateException e) { throw new IndexException("Problem encountered while cleaning up", e); } } }
private void postUpdateToSolr(ReadableWaveletData wavelet, JsonArray docsJson) { PostMethod postMethod = new PostMethod(solrBaseUrl + "/update/json?commit=true"); try { RequestEntity requestEntity = new StringRequestEntity(docsJson.toString(), "application/json", "UTF-8"); postMethod.setRequestEntity(requestEntity); HttpClient httpClient = new HttpClient(); int statusCode = httpClient.executeMethod(postMethod); if (statusCode != HttpStatus.SC_OK) { throw new IndexException(wavelet.getWaveId().serialise()); } } catch (IOException e) { throw new IndexException(String.valueOf(wavelet.getWaveletId()), e); } finally { postMethod.releaseConnection(); } }
@Inject public LucenePerUserWaveViewHandlerImpl(IndexDirectory directory, ReadableWaveletDataProvider waveletProvider, @Named(CoreSettingsNames.WAVE_SERVER_DOMAIN) String domain, @IndexExecutor Executor executor) { this.waveletProvider = waveletProvider; this.executor = executor; analyzer = new StandardAnalyzer(LUCENE_VERSION); try { IndexWriterConfig indexConfig = new IndexWriterConfig(LUCENE_VERSION, analyzer); indexConfig.setOpenMode(OpenMode.CREATE_OR_APPEND); indexWriter = new IndexWriter(directory.getDirectory(), indexConfig); nrtManager = new NRTManager(indexWriter, new WaveSearchWarmer(domain)); } catch (IOException ex) { throw new IndexException(ex); } nrtManagerReopenThread = new NRTManagerReopenThread(nrtManager, MAX_STALE_SEC, MIN_STALE_SEC); nrtManagerReopenThread.start(); }