You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2024/10/01 20:11:47 UTC
(activemq-artemis) branch main updated (a89c452ab7 -> 821005ab6e)
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
from a89c452ab7 ARTEMIS-5073 formatting error of AMQ601771 audit log event
new 022ec167cf ARTEMIS-5071 align naming for management option syntax
new 01afb572bc ARTEMIS-5072 support non-paged management results
new ca617d79bd ARTEMIS-5070 improve management docs
new 821005ab6e ARTEMIS-5075 support NOT_EQUALS op to filter some mngmnt results
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../main/webapp/plugin/js/components/addresses.js | 7 +-
.../webapp/plugin/js/components/connections.js | 7 +-
.../main/webapp/plugin/js/components/consumers.js | 7 +-
.../main/webapp/plugin/js/components/producers.js | 7 +-
.../src/main/webapp/plugin/js/components/queues.js | 7 +-
.../main/webapp/plugin/js/components/sessions.js | 7 +-
.../src/main/webapp/plugin/js/services/toolbar.js | 2 +-
.../management/impl/view/ActiveMQAbstractView.java | 48 ++-
.../core/management/impl/view/AddressView.java | 4 +-
.../core/management/impl/view/ConnectionView.java | 4 +-
.../core/management/impl/view/ConsumerView.java | 4 +-
.../core/management/impl/view/ProducerView.java | 4 +-
.../core/management/impl/view/QueueView.java | 4 +-
.../core/management/impl/view/SessionView.java | 4 +-
.../view/predicate/ActiveMQFilterPredicate.java | 40 ++-
.../core/management/impl/view/ViewTest.java | 104 ++++++
.../impl/view/predicate/PredicateTest.java | 106 +++++++
docs/user-manual/management.adoc | 349 ++++++++++++++++++++-
.../management/ActiveMQServerControlTest.java | 4 +-
19 files changed, 654 insertions(+), 65 deletions(-)
create mode 100644 artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/predicate/PredicateTest.java
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
(activemq-artemis) 01/04: ARTEMIS-5071 align naming for management option syntax
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 022ec167cf9d90d7b5e7e2d04020f61be0e7818b
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Thu Sep 26 14:14:34 2024 -0500
ARTEMIS-5071 align naming for management option syntax
This commit aligns the naming for the management option syntax but also
retains support for the old naming.
---
.../main/webapp/plugin/js/components/addresses.js | 6 +--
.../webapp/plugin/js/components/connections.js | 6 +--
.../main/webapp/plugin/js/components/consumers.js | 6 +--
.../main/webapp/plugin/js/components/producers.js | 6 +--
.../src/main/webapp/plugin/js/components/queues.js | 6 +--
.../main/webapp/plugin/js/components/sessions.js | 6 +--
.../src/main/webapp/plugin/js/services/toolbar.js | 2 +-
.../management/impl/view/ActiveMQAbstractView.java | 37 +++++++++++-----
.../core/management/impl/view/AddressView.java | 4 +-
.../core/management/impl/view/ConnectionView.java | 4 +-
.../core/management/impl/view/ConsumerView.java | 4 +-
.../core/management/impl/view/ProducerView.java | 4 +-
.../core/management/impl/view/QueueView.java | 4 +-
.../core/management/impl/view/SessionView.java | 4 +-
.../core/management/impl/view/ViewTest.java | 51 ++++++++++++++++++++++
.../management/ActiveMQServerControlTest.java | 4 +-
16 files changed, 111 insertions(+), 43 deletions(-)
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
index c0fc8be326..504b2a22db 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
@@ -124,7 +124,7 @@ var Artemis;
operation: "",
value: "",
sortOrder: "asc",
- sortColumn: "id"
+ sortField: "id"
},
text: {
fieldText: "Filter Field..",
@@ -167,7 +167,7 @@ var Artemis;
ctrl.filter.values.operation = "";
ctrl.filter.values.value = "";
ctrl.filter.sortOrder = "asc";
- ctrl.filter.sortColumn = "id";
+ ctrl.filter.sortField = "id";
ctrl.refreshed = true;
artemisAddress.address = null;
ctrl.pagination.load();
@@ -220,7 +220,7 @@ var Artemis;
operation: ctrl.filter.values.operation,
value: ctrl.filter.values.value,
sortOrder: ctrl.filter.values.sortOrder,
- sortColumn: ctrl.filter.values.sortColumn
+ sortField: ctrl.filter.values.sortField
};
if (ctrl.refreshed == true) {
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
index 649fface20..d99754fd83 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
@@ -146,7 +146,7 @@ var Artemis;
operation: "",
value: "",
sortOrder: "asc",
- sortColumn: "connectionID"
+ sortField: "connectionID"
},
text: {
fieldText: "Filter Field..",
@@ -204,7 +204,7 @@ var Artemis;
ctrl.filter.values.operation = "";
ctrl.filter.values.value = "";
ctrl.filter.sortOrder = "asc";
- ctrl.filter.sortColumn = "connectionID";
+ ctrl.filter.sortField = "connectionID";
ctrl.filter.text.fieldText = "Filter Field..";
ctrl.filter.text.operationText = "Operation..";
ctrl.filter.text.sortOrderText = "ascending";
@@ -222,7 +222,7 @@ var Artemis;
operation: ctrl.filter.values.operation,
value: ctrl.filter.values.value,
sortOrder: ctrl.filter.values.sortOrder,
- sortColumn: ctrl.filter.values.sortColumn
+ sortField: ctrl.filter.values.sortField
};
if (ctrl.refreshed == true) {
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
index 6c7ed8bc1d..58144361c0 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
@@ -164,7 +164,7 @@ var Artemis;
operation: "",
value: "",
sortOrder: "asc",
- sortColumn: "id"
+ sortField: "id"
},
text: {
fieldText: "Filter Field..",
@@ -218,7 +218,7 @@ var Artemis;
ctrl.filter.values.operation = "";
ctrl.filter.values.value = "";
ctrl.filter.sortOrder = "asc";
- ctrl.filter.sortColumn = "id";
+ ctrl.filter.sortField = "id";
ctrl.filter.text.fieldText = "Filter Field..";
ctrl.filter.text.operationText = "Operation..";
ctrl.filter.text.sortOrderText = "ascending";
@@ -291,7 +291,7 @@ var Artemis;
operation: ctrl.filter.values.operation,
value: ctrl.filter.values.value,
sortOrder: ctrl.filter.values.sortOrder,
- sortColumn: ctrl.filter.values.sortColumn
+ sortField: ctrl.filter.values.sortField
};
if (ctrl.refreshed == true) {
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
index a58ebcef84..8ab622ea2d 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
@@ -130,7 +130,7 @@ var Artemis;
operation: "",
value: "",
sortOrder: "asc",
- sortColumn: "id"
+ sortField: "id"
},
text: {
fieldText: "Filter Field..",
@@ -168,7 +168,7 @@ var Artemis;
ctrl.filter.values.operation = "";
ctrl.filter.values.value = "";
ctrl.filter.sortOrder = "asc";
- ctrl.filter.sortColumn = "id";
+ ctrl.filter.sortField = "id";
ctrl.filter.text.fieldText = "Filter Field..";
ctrl.filter.text.operationText = "Operation..";
ctrl.filter.text.sortOrderText = "ascending";
@@ -208,7 +208,7 @@ var Artemis;
operation: ctrl.filter.values.operation,
value: ctrl.filter.values.value,
sortOrder: ctrl.filter.values.sortOrder,
- sortColumn: ctrl.filter.values.sortColumn
+ sortField: ctrl.filter.values.sortField
};
if (ctrl.refreshed == true) {
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
index 4d5bcd6d6b..ac2c264bda 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
@@ -162,7 +162,7 @@ var Artemis;
operation: "",
value: "",
sortOrder: "asc",
- sortColumn: "id"
+ sortField: "id"
},
text: {
fieldText: "Filter Field..",
@@ -233,7 +233,7 @@ var Artemis;
ctrl.filter.values.operation = "";
ctrl.filter.values.value = "";
ctrl.filter.sortOrder = "asc";
- ctrl.filter.sortColumn = "id";
+ ctrl.filter.sortField = "id";
ctrl.filter.text.fieldText = "Filter Field..";
ctrl.filter.text.operationText = "Operation..";
ctrl.filter.text.sortOrderText = "ascending";
@@ -321,7 +321,7 @@ var Artemis;
operation: ctrl.filter.values.operation,
value: ctrl.filter.values.value,
sortOrder: ctrl.filter.values.sortOrder,
- sortColumn: ctrl.filter.values.sortColumn
+ sortField: ctrl.filter.values.sortField
};
if (ctrl.refreshed == true) {
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
index 20af96ff3e..3328d5a75b 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
@@ -143,7 +143,7 @@ var Artemis;
operation: "",
value: "",
sortOrder: "asc",
- sortColumn: "id"
+ sortField: "id"
},
text: {
fieldText: "Filter Field..",
@@ -182,7 +182,7 @@ var Artemis;
ctrl.filter.values.operation = "";
ctrl.filter.values.value = "";
ctrl.filter.sortOrder = "asc";
- ctrl.filter.sortColumn = "id";
+ ctrl.filter.sortField = "id";
ctrl.filter.text.fieldText = "Filter Field..";
ctrl.filter.text.operationText = "Operation..";
ctrl.filter.text.sortOrderText = "ascending";
@@ -257,7 +257,7 @@ var Artemis;
operation: ctrl.filter.values.operation,
value: ctrl.filter.values.value,
sortOrder: ctrl.filter.values.sortOrder,
- sortColumn: ctrl.filter.values.sortColumn
+ sortField: ctrl.filter.values.sortField
};
if (ctrl.refreshed == true) {
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/toolbar.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/toolbar.js
index 3a93c31dda..733862cfa5 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/toolbar.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/toolbar.js
@@ -51,7 +51,7 @@ var Artemis;
<button type="button" class="btn btn-default dropdown-toggle" id="filter" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{$ctrl.filter.text.sortByText}}<span class="caret"></span></button>
<ul class="dropdown-menu">
<li ng-repeat="option in $ctrl.filter.fieldOptions"
- id="option.id" ng-click="$ctrl.filter.values.sortColumn = option.id;$ctrl.filter.text.sortByText = option.name">{{ option.name }}</ul>
+ id="option.id" ng-click="$ctrl.filter.values.sortField = option.id;$ctrl.filter.text.sortByText = option.name">{{ option.name }}</ul>
</ul>
</div>
<div class="input-group-btn">
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
index 1491849d6a..9cadd78363 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
@@ -42,23 +42,28 @@ public abstract class ActiveMQAbstractView<T> {
private static final String SORT_ORDER = "sortOrder";
+ private static final String ASCENDING = "asc";
+
+ private static final String DESCENDING = "desc";
+
+ @Deprecated(forRemoval = true)
private static final String SORT_COLUMN = "sortColumn";
+ private static final String SORT_FIELD = "sortField";
+
private static final JsonObject DEFAULT_FILTER = JsonUtil.toJsonObject(Map.of(FILTER_FIELD, "", FILTER_OPERATION, "", FILTER_VALUE, ""));
protected Collection<T> collection;
protected ActiveMQFilterPredicate<T> predicate;
- protected String sortColumn;
+ protected String sortField;
protected String sortOrder;
- protected String options;
-
public ActiveMQAbstractView() {
- this.sortColumn = getDefaultOrderColumn();
- this.sortOrder = "asc";
+ this.sortField = getDefaultOrderColumn();
+ this.sortOrder = ASCENDING;
}
public void setCollection(Collection<T> collection) {
@@ -102,10 +107,10 @@ public abstract class ActiveMQAbstractView<T> {
public Comparator<T> getComparator() {
return (left, right) -> {
try {
- Object leftValue = getField(left, sortColumn);
- Object rightValue = getField(right, sortColumn);
+ Object leftValue = getField(left, sortField);
+ Object rightValue = getField(right, sortField);
if (leftValue instanceof Comparable && rightValue instanceof Comparable) {
- if (sortOrder.equals("desc")) {
+ if (sortOrder.equalsIgnoreCase(DESCENDING)) {
return ((Comparable) rightValue).compareTo(leftValue);
} else {
return ((Comparable) leftValue).compareTo(rightValue);
@@ -132,8 +137,12 @@ public abstract class ActiveMQAbstractView<T> {
predicate.setField(json.getString(FILTER_FIELD));
predicate.setOperation(json.getString(FILTER_OPERATION));
predicate.setValue(json.getString(FILTER_VALUE));
- if (json.containsKey(SORT_COLUMN) && json.containsKey(SORT_ORDER)) {
- this.sortColumn = json.getString(SORT_COLUMN);
+ if ((json.containsKey(SORT_COLUMN) || json.containsKey(SORT_FIELD)) && json.containsKey(SORT_ORDER)) {
+ if (json.containsKey(SORT_COLUMN)) {
+ this.sortField = json.getString(SORT_COLUMN);
+ } else {
+ this.sortField = json.getString(SORT_FIELD);
+ }
this.sortOrder = json.getString(SORT_ORDER);
}
}
@@ -145,6 +154,14 @@ public abstract class ActiveMQAbstractView<T> {
public abstract String getDefaultOrderColumn();
+ public String getSortField() {
+ return sortField;
+ }
+
+ public String getSortOrder() {
+ return sortOrder;
+ }
+
/**
* JsonObjectBuilder will throw an NPE if a null value is added. For this reason we check for null explicitly when
* adding objects.
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java
index 523450edd3..d89ad514a0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressView.java
@@ -24,7 +24,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class AddressView extends ActiveMQAbstractView<AddressInfo> {
- private static final String defaultSortColumn = AddressField.ID.getName();
+ private static final String defaultSortField = AddressField.ID.getName();
private final ActiveMQServer server;
@@ -90,6 +90,6 @@ public class AddressView extends ActiveMQAbstractView<AddressInfo> {
@Override
public String getDefaultOrderColumn() {
- return defaultSortColumn;
+ return defaultSortField;
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java
index 6f0a72b7b3..bc4045dbfd 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionView.java
@@ -31,7 +31,7 @@ import org.apache.activemq.artemis.utils.StringUtil;
public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
- private static final String defaultSortColumn = ConnectionField.CONNECTION_ID.getName();
+ private static final String defaultSortField = ConnectionField.CONNECTION_ID.getName();
private final ActiveMQServer server;
@@ -104,6 +104,6 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
@Override
public String getDefaultOrderColumn() {
- return defaultSortColumn;
+ return defaultSortField;
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java
index c3a5013faa..f79d859399 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerView.java
@@ -32,7 +32,7 @@ public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
public static final String CONSUMER_STATUS_ORPHANED = "Orphaned";
- private static final String defaultSortColumn = ConsumerField.ID.getName();
+ private static final String defaultSortField = ConsumerField.ID.getName();
private final ActiveMQServer server;
@@ -153,6 +153,6 @@ public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
@Override
public String getDefaultOrderColumn() {
- return defaultSortColumn;
+ return defaultSortField;
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java
index 23df8c88bc..42e0b5bbbd 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerView.java
@@ -25,7 +25,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
- private static final String defaultSortColumn = ProducerField.CREATION_TIME.getName();
+ private static final String defaultSortField = ProducerField.CREATION_TIME.getName();
private final ActiveMQServer server;
@@ -106,6 +106,6 @@ public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
@Override
public String getDefaultOrderColumn() {
- return defaultSortColumn;
+ return defaultSortField;
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java
index bc502742f1..29bcfae380 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueView.java
@@ -26,7 +26,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class QueueView extends ActiveMQAbstractView<QueueControl> {
- private static final String defaultSortColumn = QueueField.NAME.getName();
+ private static final String defaultSortField = QueueField.NAME.getName();
private ActiveMQServer server;
@@ -162,6 +162,6 @@ public class QueueView extends ActiveMQAbstractView<QueueControl> {
@Override
public String getDefaultOrderColumn() {
- return defaultSortColumn;
+ return defaultSortField;
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
index 28104c7e82..a1b7d1204c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionView.java
@@ -25,7 +25,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class SessionView extends ActiveMQAbstractView<ServerSession> {
- private static final String defaultSortColumn = SessionField.ID.getName();
+ private static final String defaultSortField = SessionField.ID.getName();
public SessionView() {
super();
@@ -79,6 +79,6 @@ public class SessionView extends ActiveMQAbstractView<ServerSession> {
@Override
public String getDefaultOrderColumn() {
- return defaultSortColumn;
+ return defaultSortField;
}
}
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java
index 10b7e2584b..997bdab071 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java
@@ -20,6 +20,9 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
public class ViewTest {
@Test
@@ -36,6 +39,14 @@ public class ViewTest {
connectionView.setOptions("");
}
+ @Test
+ public void testConnectionViewLegacySort() {
+ ConnectionView connectionView = new ConnectionView(Mockito.mock(ActiveMQServer.class));
+ assertNotEquals("protocol", connectionView.getDefaultOrderColumn());
+ connectionView.setOptions("{\"field\":\"protocol\",\"operation\":\"EQUALS\",\"value\":\"CORE\",\"sortColumn\":\"protocol\",\"sortOrder\":\"asc\"}");
+ assertEquals("protocol", connectionView.getSortField());
+ }
+
@Test
public void testDefaultSessionViewNullOptions() {
SessionView sessionView = new SessionView();
@@ -50,6 +61,14 @@ public class ViewTest {
sessionView.setOptions("");
}
+ @Test
+ public void testSessionViewLegacySort() {
+ SessionView sessionView = new SessionView();
+ assertNotEquals("user", sessionView.getDefaultOrderColumn());
+ sessionView.setOptions("{\"field\":\"user\",\"operation\":\"EQUALS\",\"value\":\"123\",\"sortColumn\":\"user\",\"sortOrder\":\"asc\"}");
+ assertEquals("user", sessionView.getSortField());
+ }
+
@Test
public void testDefaultAddressViewNullOptions() {
AddressView addressView = new AddressView(Mockito.mock(ActiveMQServer.class));
@@ -64,6 +83,14 @@ public class ViewTest {
addressView.setOptions("");
}
+ @Test
+ public void testAddressViewLegacySort() {
+ AddressView addressView = new AddressView(Mockito.mock(ActiveMQServer.class));
+ assertNotEquals("name", addressView.getDefaultOrderColumn());
+ addressView.setOptions("{\"field\":\"name\",\"operation\":\"EQUALS\",\"value\":\"123\",\"sortColumn\":\"name\",\"sortOrder\":\"asc\"}");
+ assertEquals("name", addressView.getSortField());
+ }
+
@Test
public void testDefaultQueueViewNullOptions() {
QueueView queueView = new QueueView(Mockito.mock(ActiveMQServer.class));
@@ -78,6 +105,14 @@ public class ViewTest {
queueView.setOptions("");
}
+ @Test
+ public void testQueueViewLegacySort() {
+ QueueView view = new QueueView(Mockito.mock(ActiveMQServer.class));
+ assertNotEquals("id", view.getDefaultOrderColumn());
+ view.setOptions("{\"field\":\"id\",\"operation\":\"EQUALS\",\"value\":\"123\",\"sortColumn\":\"id\",\"sortOrder\":\"asc\"}");
+ assertEquals("id", view.getSortField());
+ }
+
@Test
public void testDefaultConsumerViewNullOptions() {
ConsumerView consumerView = new ConsumerView(Mockito.mock(ActiveMQServer.class));
@@ -92,6 +127,14 @@ public class ViewTest {
consumerView.setOptions("");
}
+ @Test
+ public void testConsumerViewLegacySort() {
+ ConsumerView view = new ConsumerView(Mockito.mock(ActiveMQServer.class));
+ assertNotEquals("user", view.getDefaultOrderColumn());
+ view.setOptions("{\"field\":\"user\",\"operation\":\"EQUALS\",\"value\":\"123\",\"sortColumn\":\"user\",\"sortOrder\":\"asc\"}");
+ assertEquals("user", view.getSortField());
+ }
+
@Test
public void testDefaultProducerViewNullOptions() {
ProducerView producerView = new ProducerView(Mockito.mock(ActiveMQServer.class));
@@ -105,4 +148,12 @@ public class ViewTest {
// sanity check to ensure this doesn't just blow up
producerView.setOptions("");
}
+
+ @Test
+ public void testProducerViewLegacySort() {
+ ProducerView view = new ProducerView(Mockito.mock(ActiveMQServer.class));
+ assertNotEquals("user", view.getDefaultOrderColumn());
+ view.setOptions("{\"field\":\"user\",\"operation\":\"EQUALS\",\"value\":\"123\",\"sortColumn\":\"user\",\"sortOrder\":\"asc\"}");
+ assertEquals("user", view.getSortField());
+ }
}
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
index aaa50c7837..a55886fd2e 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlTest.java
@@ -6317,12 +6317,12 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
return ManagementControlHelper.createActiveMQServerControl(mbeanServer);
}
- private String createJsonFilter(String fieldName, String operationName, String value,String sortColumn, String sortOrder) {
+ private String createJsonFilter(String fieldName, String operationName, String value, String sortField, String sortOrder) {
HashMap<String, Object> filterMap = new HashMap<>();
filterMap.put("field", fieldName);
filterMap.put("operation", operationName);
filterMap.put("value", value);
- filterMap.put("sortColumn", sortColumn);
+ filterMap.put("sortField", sortField);
filterMap.put("sortOrder", sortOrder);
JsonObject jsonFilterObject = JsonUtil.toJsonObject(filterMap);
return jsonFilterObject.toString();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
(activemq-artemis) 03/04: ARTEMIS-5070 improve management docs
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit ca617d79bd775c7f0e7b89ee8dd3ad6b8cea5bc1
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Thu Sep 26 17:16:19 2024 -0500
ARTEMIS-5070 improve management docs
---
docs/user-manual/management.adoc | 348 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 340 insertions(+), 8 deletions(-)
diff --git a/docs/user-manual/management.adoc b/docs/user-manual/management.adoc
index 6f9a279826..7cc6c1cfa0 100644
--- a/docs/user-manual/management.adoc
+++ b/docs/user-manual/management.adoc
@@ -530,22 +530,29 @@ See the xref:examples.adoc#jmx-management[JMX Management Example] which shows ho
=== Exposing JMX using Jolokia
-The default Broker configuration ships with the https://jolokia.org[Jolokia] HTTP agent deployed as a web application.
+The default broker configuration ships with the https://jolokia.org[Jolokia] HTTP agent deployed as a web application.
Jolokia is a remote JMX-over-HTTP bridge that exposes MBeans.
-For a full guide as to how to use it refer to https://jolokia.org/documentation.html[Jolokia Documentation], however a simple example to query the broker's version would be to use a `curl` command like this:
+For a full guide as to how to use it refer to https://jolokia.org/reference/html/manual/jolokia_protocol.html[Jolokia documentation].
+
+==== Reading an Attribute
+
+A simple example to check whether a broker is active would be to use a `curl` command like this:
+
[,console]
----
-$ curl -v -H "Origin: http://localhost" -u myUser:myPass http://localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker=\"0.0.0.0\"/Active
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass http://localhost:8161/console/jolokia/read/org.apache.activemq.artemis:broker=\"0.0.0.0\"/Active
----
-Or you could send a JSON formatted request instead of using the URL
+
+Or you could send a JSON formatted `POST` request instead of using the URL
+
[,console]
----
-$ curl -v -H "Origin: http://localhost" -u myUser:myPass --header "Content-type: application/json" --request POST --data '{"attribute": "Active", "mbean": "org.apache.activemq.artemis:broker=\"0.0.0.0\"", "type": "read"}' http://localhost:8161/console/jolokia
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass --header "Content-type: application/json" --request POST --data '{"attribute": "Active", "mbean": "org.apache.activemq.artemis:broker=\"0.0.0.0\"", "type": "read"}' http://localhost:8161/console/jolokia
----
-By default it's necessary to pass the `Origin` header due to the CORS checking which is configured in `etc/jolokia-access.xml`.
+By default it's necessary to pass the `Origin` header due to the https://en.wikipedia.org/wiki/Cross-origin_resource_sharing[CORS] checking which is configured in `etc/jolokia-access.xml`.
-Such a `curl` command would give you back something like the following (after formatting):
+Either such `curl` command would give you back something like the following (after formatting):
[,json]
----
@@ -555,12 +562,337 @@ Such a `curl` command would give you back something like the following (after fo
"attribute": "Version",
"type": "read"
},
- "value": "2.24.0",
+ "value": "true",
"timestamp": 1663086398,
"status": 200
}
----
+The value of the attribute is contained in `value` (i.e. `true`).
+You could easily parse this JSON data with a tool like https://jqlang.github.io/jq/[`jq`] which is available in most Linux distributions, e.g.:
+
+[,console]
+----
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass --header "Content-type: application/json" --request POST --data '{"attribute": "Active", "mbean": "org.apache.activemq.artemis:broker=\"0.0.0.0\"", "type": "read"}' http://localhost:8161/console/jolokia | jq -r '.value'
+----
+
+This command would simply return:
+
+[,console]
+----
+true
+----
+
+See more details on Jolokia's `read` functionality in the https://jolokia.org/reference/html/manual/jolokia_protocol.html#read[Jolokia documentation].
+
+==== Executing an Operation
+
+Aside from reading an attribute the next most common task is executing an operation.
+For example, you can list the connections to the broker with `curl` and parse the output with `jq` like this:
+
+[,console]
+----
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass "http://localhost:8161/console/jolokia/exec/org.apache.activemq.artemis:broker=\"0.0.0.0\"/listConnections/\"\"/-1/-1" | jq '.value | fromjson'
+----
+
+Or you could send a JSON formatted `POST` request instead of using the URL
+
+[,console]
+----
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass --header "Content-type: application/json" --request POST --data '{"operation": "listConnections", "mbean": "org.apache.activemq.artemis:broker=\"0.0.0.0\"", "type": "exec", "arguments": [ "", -1, -1 ] }' http://localhost:8161/console/jolokia | jq '.value | fromjson'
+----
+
+Either such command would give you back something like the following (after formatting):
+
+[,json]
+----
+{
+ "data": [
+ {
+ "connectionID": "bd8d4635",
+ "remoteAddress": "127.0.0.1:55754",
+ "users": "",
+ "creationTime": "Wed Jan 1 12:00:00 CDT 2020",
+ "implementation": "RemotingConnectionImpl",
+ "protocol": "CORE",
+ "clientID": "",
+ "localAddress": "tcp:///127.0.0.1:61616",
+ "sessionCount": 2
+ },
+ {
+ "connectionID": "2a7ac661",
+ "remoteAddress": "127.0.0.1:54394",
+ "users": "",
+ "creationTime": "Wed Jan 1 12:00:00 CDT 2020",
+ "implementation": "OpenWireConnection",
+ "protocol": "OPENWIRE",
+ "clientID": "ID:myMachine-34439-1727292626395-0:1",
+ "localAddress": "tcp:///127.0.0.1:61616",
+ "sessionCount": 3
+ }
+ ],
+ "count": 2
+}
+----
+
+You could also leverage the <<management-method-option-syntax>> to get more specific results.
+
+[,console]
+----
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass "http://localhost:8161/console/jolokia/exec/org.apache.activemq.artemis:broker=\"0.0.0.0\"/listConnections/\{\"field\":\"protocol\",\"operation\":\"EQUALS\",\"value\":\"OPENWIRE\"\}/-1/-1" | jq '.value | fromjson'
+----
+
+Or you could send a JSON formatted `POST` request instead of using the URL
+
+[,console]
+----
+$ curl -s -H "Origin: http://localhost" -u myUser:myPass --header "Content-type: application/json" --request POST --data '{"operation": "listConnections", "mbean": "org.apache.activemq.artemis:broker=\"0.0.0.0\"", "type": "exec", "arguments": [ "{\"field\":\"protocol\",\"operation\":\"EQUALS\",\"value\":\"OPENWIRE\"}", -1, -1 ] }' http://localhost:8161/console/jolokia | jq '.value | fromjson'
+----
+
+Either such command would give you back something like the following (after formatting):
+
+[,json]
+----
+{
+ "data": [
+ {
+ "connectionID": "2a7ac661",
+ "remoteAddress": "127.0.0.1:54394",
+ "users": "",
+ "creationTime": "Wed Jan 1 12:00:00 CDT 2020",
+ "implementation": "OpenWireConnection",
+ "protocol": "OPENWIRE",
+ "clientID": "ID:myMachine-34439-1727292626395-0:1",
+ "localAddress": "tcp:///127.0.0.1:61616",
+ "sessionCount": 3
+ }
+ ],
+ "count": 1
+}
+----
+
+See more details on Jolokia's `exec` functionality in the https://jolokia.org/reference/html/manual/jolokia_protocol.html#exec[Jolokia documentation].
+
+=== Management Method Option Syntax
+
+When there are lots of these resources to manage it can sometimes be difficult to find a particular resource.
+For example, if there are 1,000 connections to the broker and you just want to manage one particular connection that is using a specific client ID.
+A handful of management operations support a special JSON syntax to filter results based on the following inputs:
+
+* `field` (see the list of fields for each management operation below)
+* `operation`
+** `CONTAINS`
+** `NOT_CONTAINS`
+** `EQUALS`
+** `GREATER_THAN`
+** `LESS_THAN`
+* `value`
+* `sortField` (optional)
+* `sortOrder` (optional)
+** `asc`
+** `desc`
+
+Here are the methods which support this syntax along with the available fields:
+
+listConnections::
+* `connectionID`
+* `clientID`
+* `users`
+* `protocol`
+* `sessionCount`
+* `remoteAddress`
+* `localAddress`
+* `sessionID`
+* `creationTime`
+* `implementation`
+* Example:
++
+[,json]
+----
+{
+ "field": "protocol",
+ "operation": "EQUALS",
+ "value": "OPENWIRE"
+}
+----
+
+listSessions::
+* `id`
+* `connectionID`
+* `consumerCount`
+* `producerCount`
+* `user`
+* `validatedUser`
+* `protocol`
+* `clientID`
+* `localAddress`
+* `remoteAddress`
+* `creationTime`
+* Example:
++
+[,json]
+----
+{
+ "field": "remoteAddress",
+ "operation": "CONTAINS",
+ "value": "127.0.0.1"
+}
+----
+
+listAddresses::
+* `id`
+* `name`
+* `routingTypes`
+* `producerId`
+* `queueCount`
+* `internal`
+* Example:
++
+[,json]
+----
+{
+ "field": "name",
+ "operation": "CONTAINS",
+ "value": "shipping"
+}
+----
+
+listQueues::
+* `id`
+* `name`
+* `consumerID`
+* `address`
+* `maxConsumers`
+* `filter`
+* `messageCount`
+* `consumerCount`
+* `deliveringCount`
+* `messagesAdded`
+* `messagesAcked`
+* `messagesExpired`
+* `routingType`
+* `user`
+* `autoCreated`
+* `durable`
+* `paused`
+* `temporary`
+* `purgeOnNoConsumers`
+* `messagesKilled`
+* `directDeliver`
+* `lastValue`
+* `exclusive`
+* `scheduledCount`
+* `lastValueKey`
+* `groupRebalance`
+* `groupRebalancePauseDispatch`
+* `groupBuckets`
+* `groupFirstKey`
+* `enabled`
+* `ringSize`
+* `consumersBeforeDispatch`
+* `delayBeforeDispatch`
+* `autoDelete`
+* `internalQueue`
+* Example:
++
+[,json]
+----
+{
+ "field": "consumerCount",
+ "operation": "GREATER_THAN",
+ "value": "7"
+}
+----
+
+listConsumers::
+* `id` or `consumerID`
+* `sequentialId` or `sequentialId`
+* `session` or `sessionID`
+* `connection` or `connectionID`
+* `queue` or `queueName`
+* `filter`
+* `address`
+* `user`
+* `validatedUser`
+* `protocol`
+* `clientID`
+* `localAddress`
+* `remoteAddress`
+* `queueType`
+* `browseOnly`
+* `creationTime`
+* `messagesInTransit` or `deliveringCount`
+* `messagesInTransitSize`
+* `messagesDelivered`
+* `messagesDeliveredSize`
+* `messagesAcknowledged`
+* `messagesAcknowledgedAwaitingCommit`
+* `lastDeliveredTime`
+* `lastAcknowledgedTime`
+* `status`
+* Example:
++
+[,json]
+----
+{
+ "field": "messagesAcknowledged",
+ "operation": "LESS_THAN",
+ "value": "10"
+}
+----
+
+listProducers::
+* `id`
+* `name`
+* `session` or `sessionID`
+* `connectionID`
+* `address` or `destination`
+* `user`
+* `validatedUser`
+* `protocol`
+* `clientID`
+* `localAddress`
+* `remoteAddress`
+* `creationTime`
+* `msgSent`
+* `msgSizeSent`
+* `lastProducedMessageID`
+* Example:
++
+[,json]
+----
+{
+ "field": "validatedUser",
+ "operation": "EQUALS",
+ "value": "bob"
+}
+----
+
+==== Sorting
+
+Results can be sorted by any field in either ascending (`asc`) or descending (`desc`) order.
+For example, use something like this in a call to `listConnections` to get all the AMQP connections with the newest connections first.
+
+[,json]
+----
+{
+ "field": "protocol",
+ "operation": "EQUALS",
+ "value": "AMQP",
+ "sortField": "creationTime",
+ "sortOrder": "desc"
+}
+----
+
+==== Pagination
+
+These methods also support _pagination_.
+In other words, the results can be divided into groups and then iterated through.
+The second parameter is the "page number" (i.e. which page to inspect) and the third parameter is the "page size" (i.e. how many results to return on each page).
+This is how, for example, the web console displays paginated results.
+
+To disable pagination pass `-1` for either page number of page size (or both).
+
=== JMX and the Web Console
The web console that ships with Artemis uses Jolokia under the covers which in turn uses JMX.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
(activemq-artemis) 04/04: ARTEMIS-5075 support NOT_EQUALS op to filter some mngmnt results
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 821005ab6ea662ed4304b8041e6bd5616c762cbe
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Fri Sep 27 15:08:38 2024 -0500
ARTEMIS-5075 support NOT_EQUALS op to filter some mngmnt results
This commit adds support for a NOT_EQUALS operator to the management
operations which already support filtering.
It also adds a handful of tests for the predicate since there didn't
seem to be any such tests.
---
.../main/webapp/plugin/js/components/addresses.js | 1 +
.../webapp/plugin/js/components/connections.js | 1 +
.../main/webapp/plugin/js/components/consumers.js | 1 +
.../main/webapp/plugin/js/components/producers.js | 1 +
.../src/main/webapp/plugin/js/components/queues.js | 1 +
.../main/webapp/plugin/js/components/sessions.js | 1 +
.../view/predicate/ActiveMQFilterPredicate.java | 40 +++++---
.../impl/view/predicate/PredicateTest.java | 106 +++++++++++++++++++++
docs/user-manual/management.adoc | 1 +
9 files changed, 141 insertions(+), 12 deletions(-)
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
index 504b2a22db..b1707921ae 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
@@ -110,6 +110,7 @@ var Artemis;
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
+ {id: 'NOT_EQUALS', name: 'Not Equals'},
{id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'},
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
index d99754fd83..63a5225f47 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
@@ -132,6 +132,7 @@ var Artemis;
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
+ {id: 'NOT_EQUALS', name: 'Not Equals'},
{id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'},
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
index 58144361c0..ec9ab72caf 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
@@ -150,6 +150,7 @@ var Artemis;
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
+ {id: 'NOT_EQUALS', name: 'Not Equals'},
{id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'},
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
index 8ab622ea2d..66d10afa4f 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
@@ -119,6 +119,7 @@ var Artemis;
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
+ {id: 'NOT_EQUALS', name: 'Not Equals'},
{id: 'CONTAINS', name: 'Contains'}
],
sortOptions: [
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
index ac2c264bda..ce26f728b6 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
@@ -148,6 +148,7 @@ var Artemis;
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
+ {id: 'NOT_EQUALS', name: 'Not Equals'},
{id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'},
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
index 3328d5a75b..eb8cb3c94e 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
@@ -129,6 +129,7 @@ var Artemis;
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
+ {id: 'NOT_EQUALS', name: 'Not Equals'},
{id: 'CONTAINS', name: 'Contains'},
{id: 'NOT_CONTAINS', name: 'Does Not Contain'},
{id: 'GREATER_THAN', name: 'Greater Than'},
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ActiveMQFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ActiveMQFilterPredicate.java
index 80a373fb44..d742f9a67d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ActiveMQFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ActiveMQFilterPredicate.java
@@ -23,7 +23,7 @@ import java.util.function.Predicate;
public class ActiveMQFilterPredicate<T> implements Predicate<T> {
public enum Operation {
- CONTAINS, NOT_CONTAINS, EQUALS, GREATER_THAN, LESS_THAN;
+ CONTAINS, NOT_CONTAINS, EQUALS, NOT_EQUALS, GREATER_THAN, LESS_THAN;
}
protected String field;
@@ -32,10 +32,6 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
protected Operation operation;
- public static boolean contains(String field, String value) {
- return field.contains(value);
- }
-
public ActiveMQFilterPredicate() {
}
@@ -65,7 +61,7 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
}
public void setOperation(String operation) {
- if (operation != null && !operation.equals("")) {
+ if (operation != null && !operation.isBlank()) {
this.operation = Operation.valueOf(operation);
}
}
@@ -75,6 +71,8 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
switch (operation) {
case EQUALS:
return equals(field, value);
+ case NOT_EQUALS:
+ return !equals(field, value);
case CONTAINS:
return contains(field, value);
case NOT_CONTAINS:
@@ -104,16 +102,22 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
longValue = Long.parseLong(value);
} catch (NumberFormatException ex) {
//cannot compare
- return false;
+ if (operation == Operation.NOT_EQUALS || operation == Operation.NOT_CONTAINS) {
+ return true;
+ } else {
+ return false;
+ }
}
switch (operation) {
case EQUALS:
return field == longValue;
+ case NOT_EQUALS:
+ return field != longValue;
case CONTAINS:
return false;
case NOT_CONTAINS:
- return false;
+ return true;
case LESS_THAN:
return field < longValue;
case GREATER_THAN:
@@ -131,16 +135,22 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
intValue = Integer.parseInt(value);
} catch (NumberFormatException ex) {
//cannot compare
- return false;
+ if (operation == Operation.NOT_EQUALS || operation == Operation.NOT_CONTAINS) {
+ return true;
+ } else {
+ return false;
+ }
}
switch (operation) {
case EQUALS:
return field == intValue;
+ case NOT_EQUALS:
+ return field != intValue;
case CONTAINS:
return false;
case NOT_CONTAINS:
- return false;
+ return true;
case LESS_THAN:
return field < intValue;
case GREATER_THAN:
@@ -158,16 +168,22 @@ public class ActiveMQFilterPredicate<T> implements Predicate<T> {
floatValue = Float.parseFloat(value);
} catch (NumberFormatException ex) {
//cannot compare
- return false;
+ if (operation == Operation.NOT_EQUALS || operation == Operation.NOT_CONTAINS) {
+ return true;
+ } else {
+ return false;
+ }
}
switch (operation) {
case EQUALS:
return field == floatValue;
+ case NOT_EQUALS:
+ return field != floatValue;
case CONTAINS:
return false;
case NOT_CONTAINS:
- return false;
+ return true;
case LESS_THAN:
return field < floatValue;
case GREATER_THAN:
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/predicate/PredicateTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/predicate/PredicateTest.java
new file mode 100644
index 0000000000..088ff3e656
--- /dev/null
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/predicate/PredicateTest.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.core.management.impl.view.predicate;
+
+import org.apache.activemq.artemis.utils.RandomUtil;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.activemq.artemis.core.management.impl.view.predicate.ActiveMQFilterPredicate.Operation.CONTAINS;
+import static org.apache.activemq.artemis.core.management.impl.view.predicate.ActiveMQFilterPredicate.Operation.EQUALS;
+import static org.apache.activemq.artemis.core.management.impl.view.predicate.ActiveMQFilterPredicate.Operation.GREATER_THAN;
+import static org.apache.activemq.artemis.core.management.impl.view.predicate.ActiveMQFilterPredicate.Operation.LESS_THAN;
+import static org.apache.activemq.artemis.core.management.impl.view.predicate.ActiveMQFilterPredicate.Operation.NOT_CONTAINS;
+import static org.apache.activemq.artemis.core.management.impl.view.predicate.ActiveMQFilterPredicate.Operation.NOT_EQUALS;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PredicateTest {
+
+ @Test
+ public void testBasePredicateEquals() {
+ String string = RandomUtil.randomString();
+ ActiveMQFilterPredicate<String> predicate = new ActiveMQFilterPredicate<>();
+ predicate.setOperation(EQUALS.name());
+ predicate.setValue(string);
+ assertTrue(predicate.matches(string));
+ assertFalse(predicate.matches(RandomUtil.randomString()));
+ assertFalse(predicate.matches(0L));
+ assertFalse(predicate.matches(0f));
+ assertFalse(predicate.matches(0));
+ }
+
+ @Test
+ public void testBasePredicateNotEquals() {
+ String string = RandomUtil.randomString();
+ ActiveMQFilterPredicate<String> predicate = new ActiveMQFilterPredicate<>();
+ predicate.setOperation(NOT_EQUALS.name());
+ predicate.setValue(string);
+ assertFalse(predicate.matches(string));
+ assertTrue(predicate.matches(RandomUtil.randomString()));
+ assertTrue(predicate.matches(0L));
+ assertTrue(predicate.matches(0f));
+ assertTrue(predicate.matches(0));
+ }
+
+ @Test
+ public void testBasePredicateContains() {
+ ActiveMQFilterPredicate<String> predicate = new ActiveMQFilterPredicate<>();
+ predicate.setOperation(CONTAINS.name());
+ predicate.setValue("12");
+ assertTrue(predicate.matches("0123"));
+ assertFalse(predicate.matches("43"));
+ assertFalse(predicate.matches(0L));
+ assertFalse(predicate.matches(0f));
+ assertFalse(predicate.matches(0));
+ }
+
+ @Test
+ public void testBasePredicateNotContains() {
+ ActiveMQFilterPredicate<String> predicate = new ActiveMQFilterPredicate<>();
+ predicate.setOperation(NOT_CONTAINS.name());
+ predicate.setValue("12");
+ assertFalse(predicate.matches("0123"));
+ assertTrue(predicate.matches("42"));
+ assertTrue(predicate.matches(0L));
+ assertTrue(predicate.matches(0f));
+ assertTrue(predicate.matches(0));
+ }
+
+ @Test
+ public void testBasePredicateLessThan() {
+ ActiveMQFilterPredicate<Integer> predicate = new ActiveMQFilterPredicate<>();
+ predicate.setOperation(LESS_THAN.name());
+ predicate.setValue("12");
+ assertFalse(predicate.matches("foo"));
+ assertFalse(predicate.matches(42));
+ assertTrue(predicate.matches(0L));
+ assertTrue(predicate.matches(0f));
+ assertTrue(predicate.matches(0));
+ }
+
+ @Test
+ public void testBasePredicateGreaterThan() {
+ ActiveMQFilterPredicate<Integer> predicate = new ActiveMQFilterPredicate<>();
+ predicate.setOperation(GREATER_THAN.name());
+ predicate.setValue("12");
+ assertFalse(predicate.matches("foo"));
+ assertTrue(predicate.matches(42));
+ assertFalse(predicate.matches(0L));
+ assertFalse(predicate.matches(0f));
+ assertFalse(predicate.matches(0));
+ }
+}
diff --git a/docs/user-manual/management.adoc b/docs/user-manual/management.adoc
index 7cc6c1cfa0..c08e51d44f 100644
--- a/docs/user-manual/management.adoc
+++ b/docs/user-manual/management.adoc
@@ -684,6 +684,7 @@ A handful of management operations support a special JSON syntax to filter resul
** `CONTAINS`
** `NOT_CONTAINS`
** `EQUALS`
+** `NOT_EQUALS`
** `GREATER_THAN`
** `LESS_THAN`
* `value`
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
(activemq-artemis) 02/04: ARTEMIS-5072 support non-paged management results
Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 01afb572bc518eb3304f69fab529304d656f7c76
Author: Justin Bertram <jb...@apache.org>
AuthorDate: Thu Sep 26 15:41:34 2024 -0500
ARTEMIS-5072 support non-paged management results
---
.../management/impl/view/ActiveMQAbstractView.java | 11 ++++-
.../core/management/impl/view/ViewTest.java | 53 ++++++++++++++++++++++
2 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
index 9cadd78363..2355aba60b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ActiveMQAbstractView.java
@@ -88,8 +88,15 @@ public abstract class ActiveMQAbstractView<T> {
public List<T> getPagedResult(int page, int pageSize) {
List<T> builder = new ArrayList<>();
- int start = (page - 1) * pageSize;
- int end = Math.min(page * pageSize, collection.size());
+ final int start;
+ final int end;
+ if (page == -1 || pageSize == -1) {
+ start = 0;
+ end = collection.size();
+ } else {
+ start = (page - 1) * pageSize;
+ end = Math.min(page * pageSize, collection.size());
+ }
int i = 0;
for (T e : collection.stream().sorted(getComparator()).collect(Collectors.toList())) {
if (i >= start && i < end) {
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java
index 997bdab071..032e9fc385 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/management/impl/view/ViewTest.java
@@ -16,7 +16,11 @@
*/
package org.apache.activemq.artemis.core.management.impl.view;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.json.JsonObjectBuilder;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -156,4 +160,53 @@ public class ViewTest {
view.setOptions("{\"field\":\"user\",\"operation\":\"EQUALS\",\"value\":\"123\",\"sortColumn\":\"user\",\"sortOrder\":\"asc\"}");
assertEquals("user", view.getSortField());
}
+
+ @Test
+ public void testPageSizeAndPageNumber() {
+ ActiveMQAbstractView myView = new ActiveMQAbstractView() {
+ @Override
+ Object getField(Object o, String fieldName) {
+ return null;
+ }
+
+ @Override
+ public Class getClassT() {
+ return null;
+ }
+
+ @Override
+ public JsonObjectBuilder toJson(Object obj) {
+ return null;
+ }
+
+ @Override
+ public String getDefaultOrderColumn() {
+ return "";
+ }
+ };
+
+ List<Integer> list = new ArrayList<>();
+ for (int i = 0; i < 1000; i++) {
+ list.add(i);
+ }
+
+ myView.setCollection(list);
+
+ // one or more inputs is -1
+ assertEquals(list.size(), myView.getPagedResult(-1, -1).size());
+ assertEquals(list.size(), myView.getPagedResult(123, -1).size());
+ assertEquals(list.size(), myView.getPagedResult(-1, 123).size());
+
+ // page 0 - not really valid but still "works"
+ assertEquals(0, myView.getPagedResult(0, 123).size());
+
+
+ assertEquals(123, myView.getPagedResult(1, 123).size());
+
+ // last page
+ assertEquals(100, myView.getPagedResult(10, 100).size());
+
+ // past the last page
+ assertEquals(0, myView.getPagedResult(11, 100).size());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@activemq.apache.org
For additional commands, e-mail: commits-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact