/** * not thread safe. should be properly lock. Right now we have two places to use it * and locked by the shutdown lock. If it gets more complicated, we should use separate * lock. * @throws IOException */ private void updateCachedReaders() throws IOException { if (log.isDebugEnabled()) { log.debug("updating reader cache"); } List<ZoieMultiReader<R>> olist = list; returnIndexReaders(olist); if (log.isDebugEnabled()) { log.debug("getting new reader from reader cache"); } list = _readerMgr.getIndexReaders(); if (log.isDebugEnabled()) { log.debug("reader updated with size: " + list.size()); } lastupdate = System.currentTimeMillis(); }
public void shutdown() { preshutdown(); while (true) { TimeUnit unit = TimeUnit.SECONDS; long t = 10L; try { if (retireThreadPool.awaitTermination(t, unit)) break; } catch (InterruptedException e) { log.warn("Exception when trying to shutdown. Will retry.", e); } } log.info("shutting down thread pool complete."); log.info("shutting down indices."); box.shutdown(); log.info("shutting down indices complete."); }
@Override public void run() { if (listener != null) { listener.onRetiredZoie(old); } retire(old); } });
trim(archives); swapArchives(archives, add); } else { if (archiveZoies.size() > trimThreshold) { trimZoie(archiveZoies); swapArchiveZoies(archiveZoies, addZoies);
archiveZoies = loadArchiveZoies(); _readerMgr = new HourglassReaderManager<R, D>(this, _dirMgrFactory, _decorator, archives, archiveZoies, hourglassListeners); _currentVersion = _dirMgrFactory.getArchivedVersion(); _currentZoie = _readerMgr.retireAndNew(null); _currentZoie.start(); _freshness = zoieConfig.getFreshness();
DirectoryReader reader = null; try { reader = getArchive(zoie); } catch (CorruptIndexException e) { log.error("retiring " + zoie.getAdminMBean().getIndexDir() archive(zoie, zoiereader); log.info("retired " + zoie.getAdminMBean().getIndexDir() + " in " + (System.currentTimeMillis() - t0) + "ms");
private void clearFromArchives(Collection<DataEvent<D>> data) throws ZoieException { if (_dirMgrFactory.getScheduler().isAppendOnly()) return; if (data != null && data.size() > 0) { List<DataEvent<D>> deletes = new ArrayList<DataEvent<D>>(data.size()); for (DataEvent<D> event : data) { deletes.add(new DataEvent<D>(event.getData(), event.getVersion(), true)); } for (ZoieSystem<R, D> zoie : _readerMgr.getArchiveZoies()) { zoie.consume(deletes); } } }
@Override public void shutdown() { try { _shutdownLock.writeLock().lock(); if (_isShutdown) { log.info("system already shut down"); return; } _isShutdown = true; } finally { _shutdownLock.writeLock().unlock(); } clearCachedReaders(); _readerMgr.shutdown(); log.info("shut down complete."); }
} else { _currentZoie = _readerMgr.retireAndNew(_currentZoie); _currentZoie.start(); clearFromArchives(data);
archiveZoies = loadArchiveZoies(); _readerMgr = new HourglassReaderManager<R, D>(this, _dirMgrFactory, _decorator, archives, archiveZoies, hourglassListeners); _currentVersion = _dirMgrFactory.getArchivedVersion(); _currentZoie = _readerMgr.retireAndNew(null); _currentZoie.start(); _freshness = zoieConfig.getFreshness();
trim(archives); swapArchives(archives, add); } else { if (archiveZoies.size() > trimThreshold) { trimZoie(archiveZoies); swapArchiveZoies(archiveZoies, addZoies);
DirectoryReader reader = null; try { reader = getArchive(zoie); } catch (CorruptIndexException e) { log.error("retiring " + zoie.getAdminMBean().getIndexDir() archive(zoie, zoiereader); log.info("retired " + zoie.getAdminMBean().getIndexDir() + " in " + (System.currentTimeMillis() - t0) + "ms");
private void clearFromArchives(Collection<DataEvent<D>> data) throws ZoieException { if (_dirMgrFactory.getScheduler().isAppendOnly()) return; if (data != null && data.size() > 0) { List<DataEvent<D>> deletes = new ArrayList<DataEvent<D>>(data.size()); for (DataEvent<D> event : data) { deletes.add(new DataEvent<D>(event.getData(), event.getVersion(), true)); } for (ZoieSystem<R, D> zoie : _readerMgr.getArchiveZoies()) { zoie.consume(deletes); } } }
@Override public void shutdown() { try { _shutdownLock.writeLock().lock(); if (_isShutdown) { log.info("system already shut down"); return; } _isShutdown = true; } finally { _shutdownLock.writeLock().unlock(); } clearCachedReaders(); _readerMgr.shutdown(); log.info("shut down complete."); }
} else { _currentZoie = _readerMgr.retireAndNew(_currentZoie); _currentZoie.start(); clearFromArchives(data);
archiveZoies = loadArchiveZoies(); _readerMgr = new HourglassReaderManager<R, D>(this, _dirMgrFactory, _decorator, hourglassListeners); _currentVersion = _dirMgrFactory.getArchivedVersion(); _currentZoie = _readerMgr.retireAndNew(null); _currentZoie.start(); _freshness = zoieConfig.getFreshness();
trim(archives); swapArchives(archives, add); trimZoie(archiveZoies); swapArchiveZoies(archiveZoies, addZoies);
try reader = getArchive(zoie); } catch (CorruptIndexException e) archive(zoie, zoiereader); log.info("retired " + zoie.getAdminMBean().getIndexDir() + " in " + (System.currentTimeMillis()-t0)+"ms"); log.info("Disk Index Size Total Now: " + (hg.getSizeBytes()/1024L) + "KB");
@Override public void run() { if (listener != null) { listener.onRetiredZoie(old); } retire(old); }}); }
private void clearFromArchives(Collection<DataEvent<D>> data) throws ZoieException { if (_dirMgrFactory.getScheduler().isAppendOnly()) return; if (data != null && data.size() > 0) { List<DataEvent<D>> deletes = new ArrayList<DataEvent<D>>(data.size()); for (DataEvent<D> event : data) { if (event instanceof MarkerDataEvent) continue; deletes.add(new DataEvent<D>(event.getData(), event.getVersion(), true)); } for (ZoieSystem<R, D> zoie : _readerMgr.getArchiveZoies()) { zoie.consume(deletes); } } }