@Override public void writePayload(final MessageStoreStatistics object, final DataOutput dataOut) throws IOException { dataOut.writeBoolean(null != object); if (object != null) { dataOut.writeLong(object.getMessageCount().getCount()); dataOut.writeLong(object.getMessageSize().getTotalSize()); dataOut.writeLong(object.getMessageSize().getMaxSize()); dataOut.writeLong(object.getMessageSize().getMinSize()); dataOut.writeLong(object.getMessageSize().getCount()); } }
@Override public void recoverMessageStoreStatistics() throws IOException { synchronized (messageTable) { long size = 0; int count = 0; for (Message message : messageTable.values()) { size += message.getSize(); } getMessageStoreStatistics().reset(); getMessageStoreStatistics().getMessageCount().setCount(count); getMessageStoreStatistics().getMessageSize().setTotalSize(size); } }
public MessageStoreStatistics(boolean enabled) { messageCount = new CountStatisticImpl("messageCount", "The number of messages in the store passing through the destination"); messageSize = new SizeStatisticImpl("messageSize","Size of messages in the store passing through the destination"); addStatistic("messageCount", messageCount); addStatistic("messageSize", messageSize); this.setEnabled(enabled); }
@Override public MessageStoreStatistics readPayload(final DataInput dataIn) throws IOException { if (!dataIn.readBoolean()) { return null; } MessageStoreStatistics messageStoreStatistics = new MessageStoreStatistics(); messageStoreStatistics.getMessageCount().setCount(dataIn.readLong()); messageStoreStatistics.getMessageSize().setTotalSize(dataIn.readLong()); messageStoreStatistics.getMessageSize().setMaxSize(dataIn.readLong()); messageStoreStatistics.getMessageSize().setMinSize(dataIn.readLong()); messageStoreStatistics.getMessageSize().setCount(dataIn.readLong()); return messageStoreStatistics; } }
@Override public void removeAllMessages(ConnectionContext context) throws IOException { synchronized (messageTable) { messageTable.clear(); getMessageStoreStatistics().reset(); } }
@Override public long getMessageSize() throws IOException { return getMessageStoreStatistics().getMessageSize().getTotalSize(); }
@Override public int getMessageCount() throws IOException { return (int) getMessageStoreStatistics().getMessageCount().getCount(); }
public void reset() { if (this.isDoReset()) { super.reset(); messageCount.reset(); messageSize.reset(); } }
protected void decrementAndSubSizeToStoreStat(Transaction tx, String kahaDestKey, StoredDestination sd, long size) throws IOException { MessageStoreStatistics storeStats = getStoreStats(kahaDestKey); if (storeStats != null) { decrementAndSubSizeToStoreStat(size, storeStats); sd.messageStoreStatistics.put(tx, storeStats); } else if (sd != null){ // During the recovery the storeStats is null MessageStoreStatistics storedStoreStats = sd.messageStoreStatistics.get(tx); if (storedStoreStats == null) { storedStoreStats = new MessageStoreStatistics(); } decrementAndSubSizeToStoreStat(size, storedStoreStats); sd.messageStoreStatistics.put(tx, storedStoreStats); } }
public void delete() { synchronized (messageTable) { messageTable.clear(); getMessageStoreStatistics().reset(); } }
@Override public long getStoreMessageSize() { MessageStore messageStore = destination.getMessageStore(); return messageStore != null ? messageStore.getMessageStoreStatistics().getMessageSize().getTotalSize() : 0; }
@Override public void recoverMessageStoreStatistics() throws IOException { int count = 0; synchronized(indexMutex) { count = pageFile.tx().execute(new Transaction.CallableClosure<Integer, IOException>(){ @Override public Integer execute(Transaction tx) throws IOException { // Iterate through all index entries to get a count of messages in the destination. StoredDestination sd = getStoredDestination(dest, tx); int rc=0; for (Iterator<Entry<String, Long>> iterator = sd.messageIdIndex.iterator(tx); iterator.hasNext();) { iterator.next(); rc++; } return rc; } }); } getMessageStoreStatistics().getMessageCount().setCount(count); }
public void reset() { if (this.isDoReset()) { super.reset(); messageCount.reset(); messageSize.reset(); } }
protected void incrementAndAddSizeToStoreStat(Transaction tx, String kahaDestKey, StoredDestination sd, long size) throws IOException { MessageStoreStatistics storeStats = getStoreStats(kahaDestKey); if (storeStats != null) { incrementAndAddSizeToStoreStat(size, storeStats); sd.messageStoreStatistics.put(tx, storeStats); } else if (sd != null){ // During the recovery the storeStats is null MessageStoreStatistics storedStoreStats = sd.messageStoreStatistics.get(tx); if (storedStoreStats == null) { storedStoreStats = new MessageStoreStatistics(); } incrementAndAddSizeToStoreStat(size, storedStoreStats); sd.messageStoreStatistics.put(tx, storedStoreStats); } }
private void incrementAndAddSizeToStoreStat(final long size, final MessageStoreStatistics storedStoreStats) { storedStoreStats.getMessageCount().increment(); if (size > 0) { storedStoreStats.getMessageSize().addSize(size); } }
@Override public void recoverMessageStoreStatistics() throws IOException { synchronized (messageTable) { long size = 0; int count = 0; for (Message message : messageTable.values()) { size += message.getSize(); } getMessageStoreStatistics().reset(); getMessageStoreStatistics().getMessageCount().setCount(count); getMessageStoreStatistics().getMessageSize().setTotalSize(size); } }
/** * Clear the counter for the destination, if one exists. * * @param kahaDestination */ protected void clearStoreStats(KahaDestination kahaDestination) { String key = key(kahaDestination); MessageStoreStatistics storeStats = getStoreStats(key); MessageStoreSubscriptionStatistics subStats = getSubStats(key); if (storeStats != null) { storeStats.reset(); } if (subStats != null) { subStats.reset(); } }
public MessageStoreStatistics(boolean enabled) { messageCount = new CountStatisticImpl("messageCount", "The number of messages in the store passing through the destination"); messageSize = new SizeStatisticImpl("messageSize","Size of messages in the store passing through the destination"); addStatistic("messageCount", messageCount); addStatistic("messageSize", messageSize); this.setEnabled(enabled); }
@Override public long getMessageSize() throws IOException { return getMessageStoreStatistics().getMessageSize().getTotalSize(); }
@Override public int getMessageCount() throws IOException { return (int) getMessageStoreStatistics().getMessageCount().getCount(); }