@Override public void onFailure() { Destination nodeDest = (Destination) node.getRegionDestination(); if (nodeDest != null) { if (node != QueueMessageReference.NULL_MESSAGE) { nodeDest.getDestinationStatistics().getDispatched().increment(); nodeDest.getDestinationStatistics().getInflight().increment(); LOG.trace("{} failed to dispatch: {} - {}, dispatched: {}, inflight: {}", new Object[]{ info.getConsumerId(), message.getMessageId(), message.getDestination(), getSubscriptionStatistics().getDispatched().getCount(), dispatched.size() }); } } if (node instanceof QueueMessageReference) { ((QueueMessageReference) node).unlock(); } } });
private void dropMessage(QueueMessageReference reference) { //use dropIfLive so we only process the statistics at most one time if (reference.dropIfLive()) { getDestinationStatistics().getDequeues().increment(); getDestinationStatistics().getMessages().decrement(); pagedInMessagesLock.writeLock().lock(); try { pagedInMessages.remove(reference); } finally { pagedInMessagesLock.writeLock().unlock(); } } }
private void incrementStatsOnAck(final Destination destination, final MessageAck ack, final int count) { getSubscriptionStatistics().getDequeues().add(count); destination.getDestinationStatistics().getDequeues().add(count); destination.getDestinationStatistics().getInflight().subtract(count); if (info.isNetworkSubscription()) { destination.getDestinationStatistics().getForwards().add(count); } if (ack.isExpiredAck()) { destination.getDestinationStatistics().getExpired().add(count); } }
public void add(long amount) { if (isEnabled()) { counter.addAndGet(amount); updateSampleTime(); if (parent != null) { parent.add(amount); } } }
public void decrement() { if (isEnabled()) { counter.decrementAndGet(); updateSampleTime(); if (parent != null) { parent.decrement(); } } }
@Override public void stop() throws Exception { started = false; destinationsLock.readLock().lock(); try{ for (Iterator<Destination> i = destinations.values().iterator(); i.hasNext();) { Destination dest = i.next(); dest.stop(); } } finally { destinationsLock.readLock().unlock(); } destinationsLock.writeLock().lock(); try { destinations.clear(); regionStatistics.getAdvisoryDestinations().reset(); regionStatistics.getDestinations().reset(); regionStatistics.getAllDestinations().reset(); } finally { destinationsLock.writeLock().unlock(); } }
pagedInPendingDispatchLock.readLock().lock(); try { pagedInPendingSize = dispatchPendingList.size(); toPageIn, force, destinationStatistics.getInflight().getCount(), pagedInMessages.size(), pagedInPendingSize, destinationStatistics.getEnqueues().getCount(), destinationStatistics.getDequeues().getCount(), getMemoryUsage().getUsage(), maxPageSize if (broker.isExpired(ref)) { messageExpired(createConnectionContext(), ref); } else { messagesLock.writeLock().unlock(); pagedInMessagesLock.writeLock().lock(); try { if (isPrioritizedMessages()) { store.removeMessage(connectionContext, new MessageAck(ref.getMessage(), MessageAck.POSION_ACK_TYPE, 1)); broker.getRoot().sendToDeadLetterQueue(connectionContext, ref.getMessage(), null, new Throwable("duplicate paged in from cursor for " + destination));
@Override public boolean recoverMessage(Message message) { recoveredAccumulator++; if ((recoveredAccumulator % 10000) == 0) { LOG.info("cursor for {} has recovered {} messages. {}% complete", new Object[]{ getActiveMQDestination().getQualifiedName(), recoveredAccumulator, new Integer((int) (recoveredAccumulator * 100 / totalMessageCount))}); } // Message could have expired while it was being // loaded.. message.setRegionDestination(Queue.this); if (message.isExpired() && broker.isExpired(message)) { toExpire.add(message); return true; } if (hasSpace()) { messagesLock.writeLock().lock(); try { try { messages.addMessageLast(message); } catch (Exception e) { LOG.error("Failed to add message to cursor", e); } } finally { messagesLock.writeLock().unlock(); } destinationStatistics.getMessages().increment(); return true; } return false; }
ActiveMQDestination dest, int maximumMessages) throws Exception { if (destination.equals(dest)) { return 0; do { doPageIn(true); pagedInMessagesLock.readLock().lock(); try { set.addAll(pagedInMessages.values()); } finally { pagedInMessagesLock.readLock().unlock(); } while (set.size() < this.destinationStatistics.getMessages().getCount() && set.size() < maximumMessages); return movedCounter;
@Override public void messageExpired(ConnectionContext context, Subscription subs, MessageReference reference) { LOG.debug("message expired: {}", reference); broker.messageExpired(context, reference, subs); destinationStatistics.getExpired().increment(); try { removeMessage(context, subs, (QueueMessageReference) reference); messagesLock.writeLock().lock(); try { messages.rollback(reference.getMessageId()); } finally { messagesLock.writeLock().unlock(); } } catch (IOException e) { LOG.error("Failed to remove expired Message from the store ", e); } }
pagedInPendingDispatchLock.writeLock().lock(); try { LOG.debug("{} remove sub: {}, lastDeliveredSeqId: {}, dequeues: {}, dispatched: {}, inflight: {}, groups: {}", new Object[]{ getActiveMQDestination().getQualifiedName(), sub, lastDeliveredSequenceId, getDestinationStatistics().getDequeues().getCount(), getDestinationStatistics().getDispatched().getCount(), getDestinationStatistics().getInflight().getCount(), sub.getConsumerInfo().getAssignedGroupCount(destination) }); consumersLock.writeLock().lock(); try { removeFromConsumerList(sub); if (sub.getConsumerInfo().isExclusive()) { Subscription exclusiveConsumer = dispatchSelector.getExclusiveConsumer(); if (exclusiveConsumer == sub) { exclusiveConsumer = null; for (Subscription s : consumers) { if (s.getConsumerInfo().isExclusive() && (exclusiveConsumer == null || s.getConsumerInfo().getPriority() > exclusiveConsumer .getConsumerInfo().getPriority())) { MessageReference ref = unackedListIterator.next(); consumersLock.writeLock().unlock();
final void messageSent(final ConnectionContext context, final Message msg) throws Exception { pendingSends.decrementAndGet(); destinationStatistics.getEnqueues().increment(); destinationStatistics.getMessages().increment(); destinationStatistics.getMessageSize().addSize(msg.getSize()); messageDelivered(context, msg); consumersLock.readLock().lock(); try { if (consumers.isEmpty()) { onMessageWithNoConsumers(context, msg); } }finally { consumersLock.readLock().unlock(); } LOG.debug("{} Message {} sent to {}", new Object[]{ broker.getBrokerName(), msg.getMessageId(), this.destination }); wakeup(); }
@Override public void addSubscription(ConnectionContext context, Subscription sub) throws Exception { LOG.debug("{} add sub: {}, dequeues: {}, dispatched: {}, inflight: {}", new Object[]{ getActiveMQDestination().getQualifiedName(), sub, getDestinationStatistics().getDequeues().getCount(), getDestinationStatistics().getDispatched().getCount(), getDestinationStatistics().getInflight().getCount() }); pagedInPendingDispatchLock.writeLock().lock(); try { consumersLock.writeLock().lock(); try { if (sub.getConsumerInfo().isExclusive() || isAllConsumersExclusiveByDefault()) { Subscription exclusiveConsumer = dispatchSelector.getExclusiveConsumer(); if (exclusiveConsumer == null) { exclusiveConsumer = sub; } else if (sub.getConsumerInfo().getPriority() == Byte.MAX_VALUE || sub.getConsumerInfo().getPriority() > exclusiveConsumer.getConsumerInfo().getPriority()) { exclusiveConsumer = sub; consumersLock.writeLock().unlock();
@Override public int getMessageCount(String clientId, String subscriptionName) throws IOException { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); if (isEnableSubscriptionStatistics()) { return (int)this.messageStoreSubStats.getMessageCount(subscriptionKey).getCount(); } else { indexLock.writeLock().lock(); try { return pageFile.tx().execute(new Transaction.CallableClosure<Integer, IOException>() { @Override public Integer execute(Transaction tx) throws IOException { StoredDestination sd = getStoredDestination(dest, tx); LastAck cursorPos = getLastAck(tx, sd, subscriptionKey); if (cursorPos == null) { // The subscription might not exist. return 0; } return (int) getStoredMessageCount(tx, sd, subscriptionKey); } }); } finally { indexLock.writeLock().unlock(); } } }
MessageStoreStatistics recoveredStatistics; lockAsyncJobQueue(); indexLock.writeLock().lock(); try { recoveredStatistics = pageFile.tx().execute(new Transaction.CallableClosure<MessageStoreStatistics, IOException>() { recoveredStatistics.getMessageCount().subtract(ackedAndPrepared.size()); getMessageStoreStatistics().getMessageCount().setCount(recoveredStatistics.getMessageCount().getCount()); getMessageStoreStatistics().getMessageSize().setTotalSize(recoveredStatistics.getMessageSize().getTotalSize()); } finally { indexLock.writeLock().unlock();
try { sendLock.lock(); long originalMessageCount = this.destinationStatistics.getMessages().getCount(); do { doPageIn(true, false, getMaxPageSize()); // signal no expiry processing needed. pagedInMessagesLock.readLock().lock(); try { list = new ArrayList<MessageReference>(pagedInMessages.values()); }finally { pagedInMessagesLock.readLock().unlock(); } while (!list.isEmpty() && this.destinationStatistics.getMessages().getCount() > 0); if (this.destinationStatistics.getMessages().getCount() > 0) { LOG.warn("{} after purge of {} messages, message count stats report: {}", getActiveMQDestination().getQualifiedName(), originalMessageCount, this.destinationStatistics.getMessages().getCount());
if (ack.isPoisonAck() || (sub != null && sub.getConsumerInfo().isNetworkSubscription())) { messagesLock.writeLock().lock(); try { messages.rollback(reference.getMessageId()); } finally { messagesLock.writeLock().unlock(); if (sub != null && sub.getConsumerInfo().isNetworkSubscription()) { getDestinationStatistics().getForwards().increment();
long numberOfRetryAttemptsToCheckAllMessagesOnce = this.destinationStatistics.getMessages().getCount(); Set<MessageReference> set = new LinkedHashSet<MessageReference>(); do { doPageIn(true); pagedInMessagesLock.readLock().lock(); try { set.addAll(pagedInMessages.values()); } finally { pagedInMessagesLock.readLock().unlock(); if (ref.getMessage().getOriginalDestination() != null) { moveMessageTo(context, (QueueMessageReference)ref, ref.getMessage().getOriginalDestination()); set.remove(ref); if (++restoredCounter >= maximumMessages && maximumMessages > 0) { } while (numberOfRetryAttemptsToCheckAllMessagesOnce > 0 && set.size() < this.destinationStatistics.getMessages().getCount()); return restoredCounter;