/** * Copy the given lists to have immutable behavior. * * @param archives * @param retiree * @param actives * @param decorator */ public Box(List<ZoieIndexReader<R>> archives, List<ZoieSystem<R, D>> archiveZoies, List<ZoieSystem<R, D>> retiree, List<ZoieSystem<R, D>> actives, IndexReaderDecorator<R> decorator) { _archives = new LinkedList<ZoieIndexReader<R>>(archives); _archiveZoies = new LinkedList<ZoieSystem<R, D>>(archiveZoies); _retiree = new LinkedList<ZoieSystem<R, D>>(retiree); _actives = new LinkedList<ZoieSystem<R, D>>(actives); _decorator = decorator; if (log.isDebugEnabled()) { for (ZoieIndexReader<R> r : _archives) { log.debug("archive " + r.directory() + " refCount: " + r.getRefCount()); } } }
/** * The readers removed will also be decRef(). But the readers to be added will NOT get incRef(), * which means we assume the newly added ones have already been incRef(). * remove and add should be <b>disjoint</b> * @param remove the readers to be remove. This has to be disjoint from add. * @param add */ public synchronized void swapArchives(List<ZoieIndexReader<R>> remove, List<ZoieIndexReader<R>> add) { List<ZoieIndexReader<R>> archives = new LinkedList<ZoieIndexReader<R>>(add); if (!box._archives.containsAll(remove)) { log.error("swapArchives: potential sync issue. "); } archives.addAll(box._archives); archives.removeAll(remove); for(ZoieIndexReader<R> r : remove) { r.decZoieRef(); if (log.isDebugEnabled()) { log.debug("remove time " + r.directory() + " refCount: " + r.getRefCount()); } } Box<R, D> newbox = new Box<R, D>(archives, box._archiveZoies, box._retiree, box._actives, _decorator); box = newbox; }
log.info("refCount at shutdown: " + r.getRefCount() + " " + r.directory());