@Override public PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, ArtemisExecutor executor) { return new PageCursorProviderImpl(store, storageManager, executor, addressSettings.getPageCacheMaxSize()); }
@Override public void processReload() throws Exception { Collection<PageSubscription> cursorList = this.activeCursors.values(); for (PageSubscription cursor : cursorList) { cursor.processReload(); } if (!cursorList.isEmpty()) { // https://issues.jboss.org/browse/JBPAPP-10338 if you ack out of order, // the min page could be beyond the first page. // we have to reload any previously acked message long cursorsMinPage = checkMinPage(cursorList); // checkMinPage will return MaxValue if there aren't any pages or any cursors if (cursorsMinPage != Long.MAX_VALUE) { for (long startPage = pagingStore.getFirstPage(); startPage < cursorsMinPage; startPage++) { for (PageSubscription cursor : cursorList) { cursor.reloadPageInfo(startPage); } } } } cleanup(); }
protected void onDeletePage(Page deletedPage) throws Exception { List<PageSubscription> subscriptions = cloneSubscriptions(); for (PageSubscription subs : subscriptions) { subs.onDeletePage(deletedPage); } }
ArrayList<PageSubscription> cursorList = cloneSubscriptions(); long minPage = checkMinPage(cursorList); deliverIfNecessary(cursorList, minPage); boolean complete = checkPageCompletion(cursorList, minPage); cleanupComplete(cursorList); if (!checkPageCompletion(cursorList, i)) { break; finishCleanup(depagedPages);
@Override public PageCache getPageCache(final long pageId) { try { PageCache cache; synchronized (softCache) { if (pageId > pagingStore.getCurrentWritingPage()) { return null; } cache = softCache.get(pageId); if (cache == null) { if (!pagingStore.checkPageFileExists((int) pageId)) { return null; } cache = createPageCache(pageId); // anyone reading from this cache will have to wait reading to finish first // we also want only one thread reading this cache logger.tracef("adding pageCache pageNr=%d into cursor = %s", pageId, this.pagingStore.getAddress()); readPage((int) pageId, cache); softCache.put(pageId, cache); } } return cache; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
@Override public void run() { storageManager.setContext(storageManager.newSingleThreadContext()); try { if (cleanupEnabled) { cleanup(); } } finally { storageManager.clearContext(); scheduledCleanup.decrementAndGet(); } } });
@Override public PagedMessage getMessage(final PagePosition pos) { PageCache cache = getPageCache(pos.getPageNr()); if (cache == null || pos.getMessageNr() >= cache.getNumberOfMessages()) { // sanity check, this should never happen unless there's a bug throw new NonExistentPage("Invalid messageNumber passed = " + pos + " on " + cache); } return cache.getMessage(pos.getMessageNr()); }
@Override public PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, ArtemisExecutor executor) { return new PageCursorProviderImpl(store, storageManager, executor, addressSettings.getPageCacheMaxSize()); }
/** * Delete everything associated with any queue on this address. * This is to be called when the address is about to be released from paging. * Hence the PagingStore will be holding a write lock, meaning no messages are going to be paged at this time. * So, we shouldn't lock anything after this method, to avoid dead locks between the writeLock and any synchronization with the CursorProvider. */ @Override public void onPageModeCleared() { ArrayList<PageSubscription> subscriptions = cloneSubscriptions(); Transaction tx = new TransactionImpl(storageManager); for (PageSubscription sub : subscriptions) { try { sub.onPageModeCleared(tx); } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorCleaningPagingOnQueue(e, sub.getQueue().getName().toString()); } } try { tx.commit(); } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorCleaningPagingDuringCommit(e); } }
@Override public PageCursorProvider newCursorProvider(PagingStore store, StorageManager storageManager, AddressSettings addressSettings, ArtemisExecutor executor) { return new PageCursorProviderImpl(store, storageManager, executor, addressSettings.getPageCacheMaxSize()); }