/** * This is a common check we do before scheduling depaging.. or while depaging. * Before scheduling a depage runnable we verify if it fits / needs depaging. * We also check for while needsDepage While depaging. * This is just to avoid a copy & paste dependency * * @return */ private boolean needsDepage() { return queueMemorySize.get() < pageSubscription.getPagingStore().getMaxSize(); }
@Override public void destroyPaging() throws Exception { // it could be null on embedded or certain unit tests if (pageSubscription != null) { pageSubscription.destroy(); pageSubscription.cleanupEntries(true); } }
@Override public long getMessagesAdded() { if (pageSubscription != null) { return messagesAdded.get() + pageSubscription.getCounter().getValueAdded(); } else { return messagesAdded.get(); } }
@Override public ArtemisExecutor getExecutor() { if (pageSubscription != null && pageSubscription.isPaging()) { // When in page mode, we don't want to have concurrent IO on the same PageStore return pageSubscription.getExecutor(); } else { return executor; } }
logger.trace("commit & useRedelivery on " + cursor + ", position=" + cursorPos); cursor.addPendingDelivery(cursorPos); cursor.redeliver(iterator, cursorPos); return true; } else if (committed) { logger.trace("rolled back, position ignored on " + cursor + ", position=" + cursorPos); cursor.positionIgnored(cursorPos); return true; } else { lateDeliveries = new LinkedList<>(); cursor.addPendingDelivery(cursorPos); lateDeliveries.add(new LateDelivery(cursor, cursorPos, iterator)); return true;
queue.getPageSubscription().getPagingStore().startPaging(); session.commit(); if (i < 19) { queue.getPageSubscription().getPagingStore().forceAnotherPage(); Assert.assertEquals(20, queue.getPageSubscription().getPagingStore().getCurrentWritingPage()); queue.getPageSubscription().getPagingStore().forceAnotherPage(); queue.getPageSubscription().cleanupEntries(false); queue.getPageSubscription().getPagingStore().getCursorProvider().cleanup();
sub.reloadACK(encoding.position); } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloading(encoding.queueID); sub.getCounter().loadValue(record.id, encoding.getValue(), encoding.getPersistentSize()); } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingPage(encoding.getQueueID()); sub.getCounter().loadInc(record.id, encoding.getValue(), encoding.getPersistentSize()); } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingPageCursor(encoding.getQueueID()); if (!sub.reloadPageCompletion(encoding.position)) { if (logger.isDebugEnabled()) { logger.debug("Complete page " + encoding.position.getPageNr() + " doesn't exist on page manager " + sub.getPagingStore().getAddress()); PageSubscription sub = locateSubscription(pendingCountEncoding.getQueueID(), pageSubscriptions, queueInfos, pagingManager); if (sub != null) { sub.notEmpty(); sub.getCounter().processReload();
@Override public void forceDelivery() { if (pageSubscription != null && pageSubscription.isPaging()) { if (logger.isTraceEnabled()) { logger.trace("Force delivery scheduling depage"); } scheduleDepage(false); } if (logger.isTraceEnabled()) { logger.trace("Force delivery delivering async"); } deliverAsync(); }
Assert.assertEquals(0, purgeQueue.getPageSubscription().getPagingStore().getAddressSize()); producer.send(session.createTextMessage("hello" + i)); if (i == 10) { purgeQueue.getPageSubscription().getPagingStore().startPaging(); Wait.assertEquals(0, purgeQueue.getPageSubscription().getPagingStore()::getAddressSize); purgeQueue.getPageSubscription().getPagingStore().startPaging(); purgeQueue.getPageSubscription().getPagingStore().startPaging(); Assert.assertTrue(purgeQueue.getPageSubscription().isPaging()); producer.send(session.createTextMessage("hello" + i)); if (i % 2 == 0) { Wait.assertEquals(0, purgeQueue.getPageSubscription().getPagingStore()::getAddressSize); Wait.assertFalse(purgeQueue.getPageSubscription()::isPaging);
long maxSize = pageSubscription.getPagingStore().getPageSizeBytes(); pageSubscription.incrementDeliveredSize(getPersistentSize(reference));
sub.reloadPreparedACK(tx, encoding.position); referencesToAck.add(new PagedReferenceImpl(encoding.position, null, sub)); } else { sub.getCounter().applyIncrementOnTX(tx, record.id, encoding.getValue(), encoding.getPersistentSize()); sub.notEmpty(); } else { ActiveMQServerLogger.LOGGER.journalCannotFindQueueReloadingACK(encoding.getQueueID());
private LinkedListIterator<PagedReference> getPagingIterator() { if (pagingIterator == null) { pagingIterator = pageSubscription.iterator(true); } return pagingIterator; }
@Test public void testReceiveThenCheckCounter() throws Exception { Queue queue = server.locateQueue(ADDRESS); assertEquals(numMsgs, queue.getMessagesAdded()); receiveAllMessages(); queue.getPageSubscription().cleanupEntries(true); assertEquals(numMsgs, queue.getMessagesAdded()); }
public void setPageSubscription(PageSubscription sub) { this.subs = sub; if (subs != null) { sub.setQueue(this); } }
@Override public void acknowledge() throws Exception { subscription.ack(this); }
@Override public void addPendingFlag() { subscription.addPendingDelivery(position); }
@Override public void acknowledge(final Transaction tx, final MessageReference ref, final AckReason reason, final ServerConsumer consumer) throws Exception { if (ref.isPaged()) { pageSubscription.ackTx(tx, (PagedReference) ref); getRefsOperation(tx).addAck(ref); } else { Message message = ref.getMessage(); boolean durableRef = message.isDurable() && isDurableMessage(); if (durableRef) { storageManager.storeAcknowledgeTransactional(tx.getID(), id, message.getMessageID()); tx.setContainsPersistent(); } getRefsOperation(tx).addAck(ref); } if (reason == AckReason.EXPIRED) { messagesExpired.incrementAndGet(); } else if (reason == AckReason.KILLED) { messagesKilled.incrementAndGet(); } else { messagesAcknowledged.incrementAndGet(); } if (server != null && server.hasBrokerMessagePlugins()) { server.callBrokerMessagePlugins(plugin -> plugin.messageAcknowledged(ref, reason, consumer)); } }
queue.getPageSubscription().getPagingStore().forceAnotherPage(); Assert.assertEquals(3, queue.getPageSubscription().getPagingStore().getCurrentWritingPage()); queue.getPageSubscription().cleanupEntries(false); queue.getPageSubscription().getPagingStore().getCursorProvider().cleanup();
private void checkDepage() { if (pageIterator != null && pageSubscription.isPaging() && !depagePending && needsDepage() && pageIterator.hasNext()) { scheduleDepage(false); } }