/** * Called when this index is closed. */ synchronized void clear() { maps = new Maps(); tombstones.clear(); // NOTE: we can't zero this here, because a refresh thread could be calling InternalEngine.pruneDeletedTombstones at the same time, // and this will lead to an assert trip. Presumably it's fine if our ramBytesUsedTombstones is non-zero after clear since the // index is being closed: //ramBytesUsedTombstones.set(0); }
/** * Called when this index is closed. */ synchronized void clear() { maps = new Maps(); tombstones.clear(); // NOTE: we can't zero this here, because a refresh thread could be calling InternalEngine.pruneDeletedTombstones at the same time, // and this will lead to an assert trip. Presumably it's fine if our ramBytesUsedTombstones is non-zero after clear since the index // is being closed: //ramBytesUsedTombstones.set(0); }
/** Called when this index is closed. */ synchronized void clear() { maps = new Maps(); tombstones.clear(); ramBytesUsedCurrent.set(0); // NOTE: we can't zero this here, because a refresh thread could be calling InternalEngine.pruneDeletedTombstones at the same time, // and this will lead to an assert trip. Presumably it's fine if our ramBytesUsedTombstones is non-zero after clear since the index // is being closed: //ramBytesUsedTombstones.set(0); if (mgr != null) { mgr.removeListener(this); mgr = null; } }
/** Called when this index is closed. */ synchronized void clear() { maps = new Maps(); tombstones.clear(); ramBytesUsedCurrent.set(0); // NOTE: we can't zero this here, because a refresh thread could be calling InternalEngine.pruneDeletedTombstones at the same time, // and this will lead to an assert trip. Presumably it's fine if our ramBytesUsedTombstones is non-zero after clear since the index // is being closed: //ramBytesUsedTombstones.set(0); if (mgr != null) { mgr.removeListener(this); mgr = null; } }
@Override public void afterRefresh(boolean didRefresh) throws IOException { // We can now drop old because these operations are now visible via the newly opened searcher. Even if didRefresh is false, which // means Lucene did not actually open a new reader because it detected no changes, it's possible old has some entries in it, which // is fine: it means they were actually already included in the previously opened reader, so we can still safely drop them in that // case. This is because we assign new maps (in beforeRefresh) slightly before Lucene actually flushes any segments for the // reopen, and so any concurrent indexing requests can still sneak in a few additions to that current map that are in fact reflected // in the previous reader. We don't touch tombstones here: they expire on their own index.gc_deletes timeframe: maps = new Maps(maps.current, ConcurrentCollections.<BytesRef,VersionValue>newConcurrentMapWithAggressiveConcurrency()); }
/** Sync'd because we replace old mgr. */ synchronized void setManager(ReferenceManager newMgr) { if (mgr != null) { mgr.removeListener(this); } mgr = newMgr; // In case InternalEngine closes & opens a new IndexWriter/SearcherManager, all deletes are made visible, so we clear old and // current here. This is safe because caller holds writeLock here (so no concurrent adds/deletes can be happeninge): maps = new Maps(); // So we are notified when reopen starts and finishes mgr.addListener(this); }
/** * Builds a new map for the refresh transition this should be called in beforeRefresh() */ Maps buildTransitionMap() { return new Maps(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency(current.size())), current, shouldInheritSafeAccess()); }
/** * Called when this index is closed. */ synchronized void clear() { maps = new Maps(); tombstones.clear(); // NOTE: we can't zero this here, because a refresh thread could be calling InternalEngine.pruneDeletedTombstones at the same time, // and this will lead to an assert trip. Presumably it's fine if our ramBytesUsedTombstones is non-zero after clear since the index // is being closed: //ramBytesUsedTombstones.set(0); }
@Override public void beforeRefresh() throws IOException { // Start sending all updates after this point to the new // map. While reopen is running, any lookup will first // try this new map, then fallback to old, then to the // current searcher: maps = new Maps(ConcurrentCollections.<BytesRef,VersionValue>newConcurrentMapWithAggressiveConcurrency(), maps.current); // This is not 100% correct, since concurrent indexing ops can change these counters in between our execution of the previous // line and this one, but that should be minor, and the error won't accumulate over time: ramBytesUsedCurrent.set(0); }
/** * builds a new map that invalidates the old map but maintains the current. This should be called in afterRefresh() */ Maps invalidateOldMap() { return new Maps(current, VersionLookup.EMPTY, previousMapsNeededSafeAccess); }
/** * Builds a new map for the refresh transition this should be called in beforeRefresh() */ Maps buildTransitionMap() { return new Maps(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency(current.size())), current, shouldInheritSafeAccess()); }
@Override public void afterRefresh(boolean didRefresh) throws IOException { // We can now drop old because these operations are now visible via the newly opened searcher. Even if didRefresh is false, which // means Lucene did not actually open a new reader because it detected no changes, it's possible old has some entries in it, which // is fine: it means they were actually already included in the previously opened reader, so we can still safely drop them in that // case. This is because we assign new maps (in beforeRefresh) slightly before Lucene actually flushes any segments for the // reopen, and so any concurrent indexing requests can still sneak in a few additions to that current map that are in fact reflected // in the previous reader. We don't touch tombstones here: they expire on their own index.gc_deletes timeframe: maps = new Maps(maps.current, ConcurrentCollections.<BytesRef,VersionValue>newConcurrentMapWithAggressiveConcurrency()); }
/** * builds a new map that invalidates the old map but maintains the current. This should be called in afterRefresh() */ Maps invalidateOldMap() { return new Maps(current, VersionLookup.EMPTY, previousMapsNeededSafeAccess); }
/** Sync'd because we replace old mgr. */ synchronized void setManager(ReferenceManager<?> newMgr) { if (mgr != null) { mgr.removeListener(this); } mgr = newMgr; // In case InternalEngine closes & opens a new IndexWriter/SearcherManager, all deletes are made visible, so we clear old and // current here. This is safe because caller holds writeLock here (so no concurrent adds/deletes can be happeninge): maps = new Maps(); // So we are notified when reopen starts and finishes mgr.addListener(this); }
@Override public void beforeRefresh() throws IOException { // Start sending all updates after this point to the new // map. While reopen is running, any lookup will first // try this new map, then fallback to old, then to the // current searcher: maps = new Maps(ConcurrentCollections.<BytesRef,VersionValue>newConcurrentMapWithAggressiveConcurrency(), maps.current); // This is not 100% correct, since concurrent indexing ops can change these counters in between our execution of the previous // line and this one, but that should be minor, and the error won't accumulate over time: ramBytesUsedCurrent.set(0); }
/** * builds a new map that invalidates the old map but maintains the current. This should be called in afterRefresh() */ Maps invalidateOldMap() { return new Maps(current, VersionLookup.EMPTY, previousMapsNeededSafeAccess); }
/** * Builds a new map for the refresh transition this should be called in beforeRefresh() */ Maps buildTransitionMap() { return new Maps(new VersionLookup(ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency(current.size())), current, shouldInheritSafeAccess()); }