public VariantSearchManager(StudyConfigurationManager studyConfigurationManager, StorageConfiguration storageConfiguration) { this.storageConfiguration = storageConfiguration; this.solrQueryParser = new SolrQueryParser(studyConfigurationManager); this.cellBaseClient = new CellBaseClient(storageConfiguration.getCellbase().toClientConfiguration()); this.variantSearchToVariantConverter = new VariantSearchToVariantConverter(); this.solrManager = new SolrManager(storageConfiguration.getSearch().getHosts(), storageConfiguration.getSearch().getMode(), storageConfiguration.getSearch().getTimeout()); // Set internal insert batch size from configuration and default value insertBatchSize = storageConfiguration.getSearch().getInsertBatchSize() > 0 ? storageConfiguration.getSearch().getInsertBatchSize() : DEFAULT_INSERT_BATCH_SIZE; logger = LoggerFactory.getLogger(VariantSearchManager.class); }
protected boolean searchActiveAndAlive() throws StorageEngineException { return configuration.getSearch().isActive() && getVariantSearchManager() != null && getVariantSearchManager().isAlive(dbName); }
public VariantSearchManager configure(VariantStorageEngine variantStorageEngine) throws StorageEngineException { variantStorageEngine.getConfiguration().getSearch().setMode("core"); variantStorageEngine.getConfiguration().getSearch().setActive(true); VariantSearchManager variantSearchManager = variantStorageEngine.getVariantSearchManager(); variantSearchManager.setSolrManager(new SolrManager(solrClient, "localhost", "core", variantStorageEngine.getConfiguration().getSearch().getTimeout())); return variantSearchManager; }
if (configuration.getSearch().isActive() && variantSearchManager.isAlive(collectionName)) {
long timeStamp = System.currentTimeMillis(); if (configuration.getSearch().isActive() && variantSearchManager.isAlive(dbName)) {
@Test public void testFailSearchNotAvailable() throws StorageEngineException { VariantQueryException exception = new VariantQueryException("Unable to use search index. SearchEngine is not available"); thrown.expect(exception.getClass()); thrown.expectMessage(exception.getMessage()); variantStorageEngine.getConfiguration().getSearch().setActive(false); variantStorageEngine.doIntersectWithSearch(new Query(ANNOT_TRAIT.key(), "myTrait"), new QueryOptions(USE_SEARCH_INDEX, VariantStorageEngine.UseSearchIndex.YES)); }
public VariantSearchLoadResult searchIndex(Query inputQuery, QueryOptions inputQueryOptions, boolean overwrite) throws StorageEngineException, IOException, VariantSearchException { Query query = inputQuery == null ? new Query() : new Query(inputQuery); QueryOptions queryOptions = inputQueryOptions == null ? new QueryOptions() : new QueryOptions(inputQueryOptions); VariantDBAdaptor dbAdaptor = getDBAdaptor(); VariantSearchManager variantSearchManager = getVariantSearchManager(); // first, create the collection it it does not exist variantSearchManager.create(dbName); if (!configuration.getSearch().isActive() || !variantSearchManager.isAlive(dbName)) { throw new StorageEngineException("Solr is not alive!"); } // then, load variants queryOptions.put(QueryOptions.EXCLUDE, Arrays.asList(VariantField.STUDIES_SAMPLES_DATA, VariantField.STUDIES_FILES)); try (VariantDBIterator iterator = getVariantsToIndex(overwrite, query, queryOptions, dbAdaptor)) { ProgressLogger progressLogger = new ProgressLogger("Variants loaded in Solr:", () -> dbAdaptor.count(query).first(), 200); VariantSearchLoadResult load = variantSearchManager.load(dbName, iterator, progressLogger, newVariantSearchLoadListener()); long value = System.currentTimeMillis(); getStudyConfigurationManager().lockAndUpdateProject(projectMetadata -> { projectMetadata.getAttributes().put(SEARCH_INDEX_LAST_TIMESTAMP.key(), value); return projectMetadata; }); return load; } catch (StorageEngineException | IOException | RuntimeException e) { throw e; } catch (Exception e) { throw new StorageEngineException("Exception closing VariantDBIterator", e); } }