/** * Getter for the EntityCache * @return the cache or <code>null</code> if no one is configured */ public EntityCache getDocumentCache(){ return documentCacheRef != null ? documentCacheRef.get() : null; } /**
@Override public void close() { lock.writeLock().lock(); try { if(current != null){ Object version = log.isDebugEnabled() ? current.get().getVersion() : null; current.decref(); log.debug(" > close EntityCache for version {} (remaining refCount: {})", version , current.getRefcount()); current = null; } } finally{ lock.writeLock().unlock(); } }
public SolrIndexSearcher getSearcher() { return searcherRef.get(); }
public SolrIndexSearcher getSearcher() { if(core == null) return null;//a request for a core admin will no have a core // should this reach out and get a searcher from the core singleton, or // should the core populate one in a factory method to create requests? // or there could be a setSearcher() method that Solr calls if (searcherHolder==null) { searcherHolder = core.getSearcher(); } return searcherHolder.get(); }
public FieldLoaderImpl(IndexReader reader) { this.reader = reader; loadedFieldsFields = new ArrayList<Field>(solrDocfields.size()); for(String loadedFieldName : solrDocfields){ loadedFieldsFields.add(new StringField(LOADED_FIELDS_FIELD_NAME, loadedFieldName, Store.NO)); } if(documentCacheRef != null){ this.cache = documentCacheRef.get(); } else { this.cache = null; } }
/** * closes the {@link SolrEntityCache} */ protected void close(){ if(log.isDebugEnabled()){ log.debug(" > close EntityCache for version {}", current.get().getVersion()); } ((SolrEntityCache)get()).close(); }
public String getIndexDir() { if (_searcher == null) return dataDir + "index/"; SolrIndexSearcher searcher = _searcher.get(); return searcher.getIndexDir() == null ? dataDir + "index/" : searcher.getIndexDir(); }
/** * Updates the configuration based on the current version of the * {@link #getIndex()}. If the SolrCore was not updated this will do * nothing. */ public void update(){ RefCounted<SolrIndexSearcher> searcherRef = index.getSearcher(); try { update(getIndexVersion(searcherRef.get()), searcherRef.get()); } finally { searcherRef.decref(); //decrease the count on the searcher } } /**
private void registerSearcher(RefCounted<SolrIndexSearcher> newSearcherHolder) throws IOException { synchronized (searcherLock) { try { if (_searcher != null) { _searcher.decref(); // dec refcount for this._searcher _searcher=null; } _searcher = newSearcherHolder; SolrIndexSearcher newSearcher = newSearcherHolder.get(); newSearcher.register(); // register subitems (caches) log.info(logid+"Registered new searcher " + newSearcher); } catch (Throwable e) { log(e); } finally { // wake up anyone waiting for a searcher // even in the face of errors. onDeckSearchers--; searcherLock.notifyAll(); } } }
private long getIndexVersion(){ RefCounted<SolrIndexSearcher> searcherRef = index.getSearcher(); try { return getIndexVersion(searcherRef.get()); } finally { searcherRef.decref(); } }
private long[] getIndexVersion() { long version[] = new long[2]; RefCounted<SolrIndexSearcher> searcher = core.getSearcher(); try { version[0] = searcher.get().getReader().getIndexCommit().getVersion(); version[1] = searcher.get().getReader().getIndexCommit().getGeneration(); } catch (IOException e) { LOG.warn("Unable to get index version : ", e); } finally { searcher.decref(); } return version; }
protected static void waitForWarming(SolrCore core) throws InterruptedException { RefCounted<SolrIndexSearcher> registeredSearcher = core.getRegisteredSearcher(); RefCounted<SolrIndexSearcher> newestSearcher = core.getNewestSearcher(false); while (registeredSearcher == null || registeredSearcher.get() != newestSearcher.get()) { if (registeredSearcher != null) { registeredSearcher.decref(); } newestSearcher.decref(); Thread.sleep(50); registeredSearcher = core.getRegisteredSearcher(); newestSearcher = core.getNewestSearcher(false); } registeredSearcher.decref(); newestSearcher.decref(); }
RefCounted<SolrIndexSearcher> searcherRef = core.getSearcher(); try { SolrIndexSearcher searcher = searcherRef.get();
RefCounted<SolrIndexSearcher> searcherRef = core.getSearcher(); try { SolrIndexSearcher searcher = searcherRef.get();
public List<SimpleOrderedMap<Object>> generateTree(ResponseBuilder rb, NamedList<Integer> facetValues) throws IOException { List<SimpleOrderedMap<Object>> retVal = null; // First get the searcher for the required collection RefCounted<SolrIndexSearcher> searcherRef = getSearcherReference(rb); try { // Build the facet tree(s) Collection<TreeFacetField> fTrees = treeBuilder.processFacetTree(searcherRef.get(), extractFacetValues(facetValues)); LOGGER.debug("Extracted {} facet trees", fTrees.size()); if (pruner != null) { // Prune the trees fTrees = pruner.prune(fTrees); } // Convert the trees into a SimpleOrderedMap retVal = convertTreeFacetFields(fTrees); } finally { // Make sure the search ref count is decreased searcherRef.decref(); } return retVal; }
/** * If this {@link IndexConfiguration} is still in sync with the version * of the {@link #getIndex() SolrCore}. This will return true if * <code>{@link #isRuntimeGeneration()} == false </code> * @return <code>true</code> if still active. Otherwise <code>false</code> */ public boolean isCurrent(){ if(!runtimeGeneration){ return true; } else { RefCounted<SolrIndexSearcher> searcherRef = index.getSearcher(); try { long version = searcherRef.get().getIndexReader().getVersion(); return indexVersion == version; } finally { searcherRef.decref(); } } }
public int getNumberOfSegments() { return this.getCore().getSearcher().get().getIndexReader().leaves().size(); }
public int getNumberOfSegments() { return this.getCore().getSearcher().get().getIndexReader().leaves().size(); }
protected NamedList<Object> getCoreStatus(CoreContainer cores, String cname) throws IOException { NamedList<Object> info = new SimpleOrderedMap<Object>(); SolrCore core = cores.getCore(cname); if (core != null) { try { info.add("name", core.getName()); info.add("instanceDir", normalizePath(core.getResourceLoader().getInstanceDir())); info.add("dataDir", normalizePath(core.getDataDir())); info.add("startTime", new Date(core.getStartTime())); info.add("uptime", System.currentTimeMillis() - core.getStartTime()); RefCounted<SolrIndexSearcher> searcher = core.getSearcher(); try { info.add("index", LukeRequestHandler.getIndexInfo(searcher.get().getReader(), false)); } finally { searcher.decref(); } } finally { core.close(); } } return info; }