Skip to content

Commit

Permalink
ARTEMIS-3397 remove queue rate metric from web console
Browse files Browse the repository at this point in the history
This is a follow-up from ARTEMIS-2322.

The changes related to expired message are only there because
QueueFilterPredicate had a bug where the rate was correlated to expired
messages. When I fixed that I noticed that expired messages was actually
missing so I added it.
  • Loading branch information
jbertram committed Jul 21, 2021
1 parent 3a8e995 commit 02aa07a
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum QueueField {
DELIVERING_COUNT("deliveringCount"),
MESSAGES_ADDED("messagesAdded"),
MESSAGES_ACKED("messagesAcked"),
RATE("rate"),
MESSAGES_EXPIRED("messagesExpired"),
ROUTING_TYPE("routingType"),
USER("user"),
AUTO_CREATED("autoCreated"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public JsonObjectBuilder toJson(QueueControl queue) {
.add(QueueField.NAME.getName(), toString(queue.getName()))
.add(QueueField.ADDRESS.getName(), toString(queue.getAddress()))
.add(QueueField.FILTER.getName(), toString(queue.getFilter()))
.add(QueueField.RATE.getName(), toString(q.getRate()))
.add(QueueField.DURABLE.getName(), toString(queue.isDurable()))
.add(QueueField.PAUSED.getName(), toString(q.isPaused()))
.add(QueueField.TEMPORARY.getName(), toString(queue.isTemporary()))
Expand All @@ -62,6 +61,7 @@ public JsonObjectBuilder toJson(QueueControl queue) {
.add(QueueField.MESSAGES_ADDED.getName(), toString(queue.getMessagesAdded()))
.add(QueueField.MESSAGE_COUNT.getName(), toString(queue.getMessageCount()))
.add(QueueField.MESSAGES_ACKED.getName(), toString(queue.getMessagesAcknowledged()))
.add(QueueField.MESSAGES_EXPIRED.getName(), toString(queue.getMessagesExpired()))
.add(QueueField.DELIVERING_COUNT.getName(), toString(queue.getDeliveringCount()))
.add(QueueField.MESSAGES_KILLED.getName(), toString(queue.getMessagesKilled()))
.add(QueueField.DIRECT_DELIVER.getName(), toString(q.isDirectDeliver()))
Expand Down Expand Up @@ -95,8 +95,6 @@ public Object getField(QueueControl queue, String fieldName) {
return queue.getAddress();
case FILTER:
return queue.getFilter();
case RATE:
return q.getRate();
case DURABLE:
return queue.isDurable();
case PAUSED:
Expand All @@ -121,6 +119,8 @@ public Object getField(QueueControl queue, String fieldName) {
return queue.getMessageCount();
case MESSAGES_ACKED:
return queue.getMessagesAcknowledged();
case MESSAGES_EXPIRED:
return queue.getMessagesExpired();
case DELIVERING_COUNT:
return queue.getDeliveringCount();
case MESSAGES_KILLED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean test(QueueControl queue) {
return matches(queue.getMessagesAdded());
case MESSAGES_ACKED:
return matches(queue.getMessagesAcknowledged());
case RATE:
case MESSAGES_EXPIRED:
return matches(queue.getMessagesExpired());
case ROUTING_TYPE:
return matches(queue.getRoutingType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ default int retryMessages(Filter filter, Integer expectedHits) throws Exception

void postAcknowledge(MessageReference ref, AckReason reason);

float getRate();

/**
* @return the user associated with this queue
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4032,8 +4032,7 @@ public synchronized void resetMessagesKilled() {
messagesKilled.set(0);
}

@Override
public float getRate() {
private float getRate() {
long locaMessageAdded = getMessagesAdded();
float timeSlice = ((System.currentTimeMillis() - queueRateCheckTime.getAndSet(System.currentTimeMillis())) / 1000.0f);
if (timeSlice == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1631,11 +1631,6 @@ public void postAcknowledge(MessageReference ref, AckReason reason) {

}

@Override
public float getRate() {
return 0.0f;
}

@Override
public SimpleString getUser() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,11 +962,6 @@ public LinkedListIterator<MessageReference> browserIterator() {
public void postAcknowledge(MessageReference ref, AckReason reason) {
}

@Override
public float getRate() {
return 0.0f;
}

@Override
public SimpleString getUser() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.activemq.artemis.tests.unit.core.server.impl;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
Expand Down Expand Up @@ -210,7 +212,7 @@ public void testSimpleadd() {
}

@Test
public void testRate() throws InterruptedException {
public void testRate() throws Exception {
QueueImpl queue = getTemporaryQueue();

final int numMessages = 10;
Expand All @@ -223,7 +225,10 @@ public void testRate() throws InterruptedException {

Thread.sleep(1000);

float rate = queue.getRate();
Method getRate = QueueImpl.class.getDeclaredMethod("getRate", null);
getRate.setAccessible(true);
float rate = (float) getRate.invoke(queue, null);

Assert.assertTrue(rate <= 10.0f);
log.debug("Rate: " + rate);
}
Expand Down

0 comments on commit 02aa07a

Please sign in to comment.