/** * @param queueID * @param pageSubscriptions * @param queueInfos * @return */ private static PageSubscription locateSubscription(final long queueID, final Map<Long, PageSubscription> pageSubscriptions, final Map<Long, QueueBindingInfo> queueInfos, final PagingManager pagingManager) throws Exception { PageSubscription subs = pageSubscriptions.get(queueID); if (subs == null) { QueueBindingInfo queueInfo = queueInfos.get(queueID); if (queueInfo != null) { SimpleString address = queueInfo.getAddress(); PagingStore store = pagingManager.getPageStore(address); if (store == null) { return null; } subs = store.getCursorProvider().getSubscription(queueID); pageSubscriptions.put(queueID, subs); } } return subs; }
private void openNewPage() throws Exception { lock.writeLock().lock(); try { numberOfPages++; int tmpCurrentPageId = currentPageId + 1; if (logger.isTraceEnabled()) { logger.trace("new pageNr=" + tmpCurrentPageId, new Exception("trace")); } if (currentPage != null) { currentPage.close(true); } currentPage = createPage(tmpCurrentPageId); LivePageCache pageCache = new LivePageCacheImpl(currentPage); currentPage.setLiveCache(pageCache); cursorProvider.addPageCache(pageCache); currentPageSize.set(0); currentPage.open(); currentPageId = tmpCurrentPageId; if (currentPageId < firstPageId) { firstPageId = currentPageId; } } finally { lock.writeLock().unlock(); } }
/** * This method will disable cleanup of pages. No page will be deleted after this call. */ @Override public void disableCleanup() { getCursorProvider().disableCleanup(); }
private PagedReference getReference(PagePosition pos) { return cursorProvider.newReference(pos, cursorProvider.getMessage(pos), this); }
@Override public synchronized void stop() throws Exception { if (running) { cursorProvider.flushExecutors(); cursorProvider.stop(); final List<Runnable> pendingTasks = new ArrayList<>(); final int pendingTasksWhileShuttingDown = executor.shutdownNow(pendingTasks::add); if (pendingTasksWhileShuttingDown > 0) { logger.tracef("Try executing %d pending tasks on stop", pendingTasksWhileShuttingDown); for (Runnable pendingTask : pendingTasks) { try { pendingTask.run(); } catch (Throwable t) { logger.warn("Error while executing a pending task on shutdown", t); } } } running = false; if (currentPage != null) { currentPage.close(false); currentPage = null; } } }
pgStoreAddress.getCursorProvider().getSubscription(serverQueue.getID()).cleanupEntries(false); pgStoreAddress.getCursorProvider().cleanup();
private PagedReference internalGetNext(final PagePosition pos) { PagePosition retPos = pos.nextMessage(); PageCache cache = cursorProvider.getPageCache(pos.getPageNr()); retPos = moveNextPage(retPos); cache = cursorProvider.getPageCache(retPos.getPageNr()); return cursorProvider.newReference(retPos, serverMessage, this); } else { return null;
private int getNumberOfMessages() { if (wasLive) { // if the page was live at any point, we need to // get the number of messages from the page-cache PageCache localcache = this.cache.get(); if (localcache == null) { localcache = cursorProvider.getPageCache(pageId); this.cache = new WeakReference<>(localcache); } return localcache.getNumberOfMessages(); } else { return numberOfMessages; } }
@Override public PagedMessage queryMessage(PagePosition pos) { return cursorProvider.getMessage(pos); }
@Override public void flushExecutors() { cursorProvider.flushExecutors(); FutureLatch future = new FutureLatch(); executor.execute(future); if (!future.await(60000)) { ActiveMQServerLogger.LOGGER.pageStoreTimeout(address); } }
/** * Returns a new {@link QueueConfig} using the parameters configured on the {@link Builder}. * <br> * The reference parameters aren't defensively copied from the {@link Builder} to the {@link QueueConfig}. * <br> * This method creates a new {@link PageSubscription} only if {@link #pagingManager} is not {@code null} and * if {@link FilterUtils#isTopicIdentification} returns {@code false} on {@link #filter}. * * @throws IllegalStateException if the creation of {@link PageSubscription} fails */ public QueueConfig build() { final PageSubscription pageSubscription; if (pagingManager != null && !FilterUtils.isTopicIdentification(filter)) { try { final PagingStore pageStore = this.pagingManager.getPageStore(address); if (pageStore != null) { pageSubscription = pageStore.getCursorProvider().createSubscription(id, filter, durable); } else { pageSubscription = null; } } catch (Exception e) { throw new IllegalStateException(e); } } else { pageSubscription = null; } return new QueueConfig(id, address, name, filter, pageSubscription, user, durable, temporary, autoCreated, routingType, maxConsumers, exclusive, lastValue, lastValueKey, nonDestructive, consumersBeforeDispatch, delayBeforeDispatch, purgeOnNoConsumers, configurationManaged); }
cursorProvider.close(this); } catch (Exception e) { try {
server.getPagingManager().getPageStore(ADDRESS).getCursorProvider().clearCache();
public PageCursorInfo getPageInfo(final long pageNr) { synchronized (consumedPages) { PageCursorInfo pageInfo = consumedPages.get(pageNr); if (pageInfo == null) { PageCache cache = cursorProvider.getPageCache(pageNr); if (cache == null) { return null; } pageInfo = new PageCursorInfo(pageNr, cache.getNumberOfMessages(), cache); consumedPages.put(pageNr, pageInfo); } return pageInfo; } }
PageSubscriptionCounter counter = store.getCursorProvider().getSubscription(entry.getKey()).getCounter();
store.getCursorProvider().cleanup();
cursorProvider.addPageCache(pageCache);
return false; PageSubscription subscription = store.getCursorProvider().getSubscription(queue.getID()); if (subscription.contains((PagedReference) reference)) { return true;