public synchronized void addSize(long size) { count++; totalSize += size; if (size > maxSize) { maxSize = size; } if (size < minSize || minSize == 0) { minSize = size; } updateSampleTime(); if (parent != null) { parent.addSize(size); } }
@Override protected synchronized void onLoad(ListNode<String, Location> node, Transaction tx) { try { Iterator<Entry<String, Location>> i = node.iterator(tx); while (i.hasNext()) { messageSize.addSize(i.next().getValue().getSize()); } } catch (IOException e) { LOG.warn("could not increment message size", e); } }
@Override public void onRemove(Entry<String, Location> removed) { super.onRemove(removed); if (removed != null) { messageSize.addSize(-removed.getValue().getSize()); } }
@Override public synchronized Location add(Transaction tx, String key, Location value) throws IOException { Location location = super.add(tx, key, value); messageSize.addSize(value.getSize()); return location; }
@Override public synchronized Location addFirst(Transaction tx, String key, Location value) throws IOException { Location location = super.addFirst(tx, key, value); messageSize.addSize(value.getSize()); return location; }
public void addToMap(MessageReference message, PendingNode node) { PendingNode previous = this.map.put(message.getMessageId(), node); if (previous != null) { try { messageSize.addSize(-previous.getMessage().getSize()); } catch (Exception e) { //expected for NullMessageReference } } try { messageSize.addSize(message.getSize()); } catch (Exception e) { //expected for NullMessageReference } }
public PendingNode removeFromMap(MessageReference message) { PendingNode removed = this.map.remove(message.getMessageId()); if (removed != null) { try { messageSize.addSize(-removed.getMessage().getSize()); } catch (Exception e) { //expected for NullMessageReference } } return removed; } }
private void addReferencesAndUpdateRedispatch(LinkedList<MessageReference> redispatch, Destination destination, List<MessageReference> dispatched) { ArrayList<MessageReference> references = new ArrayList<MessageReference>(); for (MessageReference r : dispatched) { if (r.getRegionDestination() == destination) { references.add(r); getSubscriptionStatistics().getInflightMessageSize().addSize(-r.getSize()); } } redispatch.addAll(0, references); destination.getDestinationStatistics().getInflight().subtract(references.size()); dispatched.removeAll(references); }
private void incrementAndAddSizeToStoreStat(final long size, final MessageStoreStatistics storedStoreStats) { storedStoreStats.getMessageCount().increment(); if (size > 0) { storedStoreStats.getMessageSize().addSize(size); } }
private void decrementAndSubSizeToStoreStat(final long size, final MessageStoreStatistics storedStoreStats) { storedStoreStats.getMessageCount().decrement(); if (size > 0) { storedStoreStats.getMessageSize().addSize(-size); } }
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(); }
protected static final void incMessageStoreStatistics(final MessageStoreStatistics stats, final Message message) { if (stats != null && message != null) { stats.getMessageCount().increment(); stats.getMessageSize().addSize(message.getSize()); } }
protected void decrementAndSubSizeToStoreStat(String kahaDestKey, String subKey, long size) { if (enableSubscriptionStatistics) { MessageStoreSubscriptionStatistics subStats = getSubStats(kahaDestKey); if (subStats != null && subKey != null) { subStats.getMessageCount(subKey).decrement(); if (size > 0) { subStats.getMessageSize(subKey).addSize(-size); } } } }
protected static final void decMessageStoreStatistics(final MessageStoreStatistics stats, final Message message) { if (stats != null && message != null) { stats.getMessageCount().decrement(); stats.getMessageSize().addSize(-message.getSize()); } } }
protected void incrementAndAddSizeToStoreStat(String kahaDestKey, String subKey, long size) { if (enableSubscriptionStatistics) { MessageStoreSubscriptionStatistics subStats = getSubStats(kahaDestKey); if (subStats != null && subKey != null) { subStats.getMessageCount(subKey).increment(); if (size > 0) { subStats.getMessageSize(subKey).addSize(size); } } } }
@Override public void updateMessage(Message message) { synchronized (messageTable) { Message original = messageTable.get(message.getMessageId()); // if can't be found then increment count, else remove old size if (original == null) { getMessageStoreStatistics().getMessageCount().increment(); } else { getMessageStoreStatistics().getMessageSize().addSize(-original.getSize()); } messageTable.put(message.getMessageId(), message); getMessageStoreStatistics().getMessageSize().addSize(message.getSize()); } }
public void removeSubscription(String subKey) { SubscriptionStatistics subStats = subStatistics.remove(subKey); //Subtract from the parent if (subStats != null) { getMessageCount().subtract(subStats.getMessageCount().getCount()); getMessageSize().addSize(-subStats.getMessageSize().getTotalSize()); } }
@Override public void afterCommit() throws Exception { Destination nodeDest = (Destination) node.getRegionDestination(); synchronized (dispatchLock) { getSubscriptionStatistics().getDequeues().increment(); if (dispatched.remove(node)) { // if consumer is removed, dispatched will be empty and inflight will // already have been adjusted getSubscriptionStatistics().getInflightMessageSize().addSize(-node.getSize()); nodeDest.getDestinationStatistics().getInflight().decrement(); } } contractPrefetchExtension(1); nodeDest.wakeup(); dispatchPending(); }
@Override public void processMessageDispatchNotification(MessageDispatchNotification mdn) { synchronized (matchedListMutex) { try { matched.reset(); while (matched.hasNext()) { MessageReference node = matched.next(); node.decrementReferenceCount(); if (node.getMessageId().equals(mdn.getMessageId())) { synchronized(dispatchLock) { matched.remove(); getSubscriptionStatistics().getDispatched().increment(); if (isUseTopicSubscriptionInflightStats()) { dispatched.add(new DispatchedNode(node)); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); } node.decrementReferenceCount(); } break; } } } finally { matched.release(); } } }
@Override public void processMessageDispatchNotification(MessageDispatchNotification mdn) throws Exception { synchronized(pendingLock) { try { pending.reset(); while (pending.hasNext()) { MessageReference node = pending.next(); node.decrementReferenceCount(); if (node.getMessageId().equals(mdn.getMessageId())) { // Synchronize between dispatched list and removal of messages from pending list // related to remove subscription action synchronized(dispatchLock) { pending.remove(); createMessageDispatch(node, node.getMessage()); dispatched.add(node); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); onDispatch(node, node.getMessage()); } return; } } } finally { pending.release(); } } throw new JMSException( "Slave broker out of sync with master: Dispatched message (" + mdn.getMessageId() + ") was not in the pending list for " + mdn.getConsumerId() + " on " + mdn.getDestination().getPhysicalName()); }