public synchronized SolrCore readSchema(String indexName) throws IOException, ParserConfigurationException, SAXException { SolrCore core = cache.get(indexName); if (core == null) { // get from cassandra if (logger.isDebugEnabled()) logger.debug("loading index schema for: " + indexName); ByteBuffer buf = readCoreResource(indexName, CassandraUtils.schemaKey); //Schema resource not found for the core if (buf == null) { throw new IOException(String.format("invalid core '%s'", indexName)); } InputStream stream = new ByteArrayInputStream(ByteBufferUtil.getArray(buf)); SolrResourceLoader resourceLoader = new SolandraResourceLoader(indexName, null); SolrConfig solrConfig = new SolrConfig(resourceLoader, solrConfigFile, null); IndexSchema schema = new IndexSchema(solrConfig, indexName, new InputSource(stream)); core = new SolrCore(indexName, "/tmp", solrConfig, schema, null); if (logger.isDebugEnabled()) logger.debug("Loaded core from cassandra: " + indexName); cache.put(indexName, core); } return core; }
public static void writeSchema(String indexName, String schemaXml) throws IOException { writeCoreResource(indexName, CassandraUtils.schemaKey, schemaXml); logger.info("Wrote Schema for " + indexName); //remove any existing cores cache.remove(indexName); }
cache = new ConcurrentLRUCache(limit, minLimit, acceptableLimit, initialSize, newThread, false, null); cache.setAlive(false); cumulativeStats.add(cache.getStats()); return cumulativeStats;
public Object get(Object key) { return cache.get(key); }
public Object put(Object key, Object value) { return cache.put(key, value); }
public NamedList getStatistics() { NamedList<Serializable> lst = new SimpleOrderedMap<Serializable>(); if (cache == null) return lst; ConcurrentLRUCache.Stats stats = cache.getStats(); long lookups = stats.getCumulativeLookups(); long hits = stats.getCumulativeHits(); Map items = cache.getLatestAccessedItems( showItems == -1 ? Integer.MAX_VALUE : showItems ); for (Map.Entry e : (Set <Map.Entry>)items.entrySet()) { Object k = e.getKey();
public int size() { return cache.size(); }
public void close() { cache.destroy(); }
public void clear() { cache.clear(); }
public void setState(State state) { this.state = state; cache.setAlive(state == State.LIVE); }
public void warm(SolrIndexSearcher searcher, SolrCache old) throws IOException { if (regenerator == null) return; long warmingStartTime = System.currentTimeMillis(); FastLRUCache other = (FastLRUCache) old; // warm entries if (autowarmCount != 0) { int sz = other.size(); if (autowarmCount != -1) sz = Math.min(sz, autowarmCount); Map items = other.cache.getLatestAccessedItems(sz); Map.Entry[] itemsArr = new Map.Entry[items.size()]; int counter = 0; for (Object mapEntry : items.entrySet()) { itemsArr[counter++] = (Map.Entry) mapEntry; } for (int i = itemsArr.length - 1; i >= 0; i--) { try { boolean continueRegen = regenerator.regenerateItem(searcher, this, old, itemsArr[i].getKey(), itemsArr[i].getValue()); if (!continueRegen) break; } catch (Throwable e) { SolrException.log(log, "Error during auto-warming of key:" + itemsArr[i].getKey(), e); } } } warmupTime = System.currentTimeMillis() - warmingStartTime; }