You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2021/04/01 17:23:27 UTC
[activemq-artemis] branch master updated: ARTEMIS-3203 Match filter
field names with view field names
This is an automated email from the ASF dual-hosted git repository.
jbertram pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/master by this push:
new 2f851cb ARTEMIS-3203 Match filter field names with view field names
new 7e6c9eb This closes #3524
2f851cb is described below
commit 2f851cbbe0da46bee8ce6f075553139fa2a25225
Author: Domenico Francesco Bruscino <br...@apache.org>
AuthorDate: Wed Mar 31 20:09:42 2021 +0200
ARTEMIS-3203 Match filter field names with view field names
The filter and the view use different convection for field names, ie the
connection view uses the `sessionID` field name while the connection filter
uses the `SESSION_ID` field name. This commit replace the field names used
by the filter with the field names used by the view preserving the backward
compatibility.
---
.../artemis/cli/commands/queue/StatQueue.java | 22 +++-
.../main/webapp/plugin/js/components/addresses.js | 4 +-
.../webapp/plugin/js/components/connections.js | 12 +-
.../main/webapp/plugin/js/components/consumers.js | 22 ++--
.../main/webapp/plugin/js/components/producers.js | 20 ++--
.../src/main/webapp/plugin/js/components/queues.js | 14 +--
.../main/webapp/plugin/js/components/sessions.js | 10 +-
.../core/management/impl/view/AddressField.java | 50 ++++++++
.../core/management/impl/view/AddressView.java | 23 ++--
.../core/management/impl/view/ConnectionField.java | 55 +++++++++
.../core/management/impl/view/ConnectionView.java | 43 +++----
.../core/management/impl/view/ConsumerField.java | 57 +++++++++
.../core/management/impl/view/ConsumerView.java | 61 +++++-----
.../core/management/impl/view/ProducerField.java | 54 +++++++++
.../core/management/impl/view/ProducerView.java | 49 ++++----
.../core/management/impl/view/QueueField.java | 78 ++++++++++++
.../core/management/impl/view/QueueView.java | 133 +++++++++++----------
.../core/management/impl/view/SessionField.java | 55 +++++++++
.../core/management/impl/view/SessionView.java | 31 ++---
.../view/predicate/AddressFilterPredicate.java | 14 ++-
.../view/predicate/ConnectionFilterPredicate.java | 18 ++-
.../view/predicate/ConsumerFilterPredicate.java | 16 +--
.../view/predicate/ProducerFilterPredicate.java | 16 +--
.../impl/view/predicate/QueueFilterPredicate.java | 16 +--
.../view/predicate/SessionFilterPredicate.java | 14 ++-
25 files changed, 646 insertions(+), 241 deletions(-)
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
index 85144d6..6925cd2 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/queue/StatQueue.java
@@ -28,6 +28,8 @@ import javax.json.JsonArray;
import javax.json.JsonObject;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
@Command(name = "stat", description = "prints out basic stats associated with queues. Output includes CONSUMER_COUNT (number of consumers), MESSAGE_COUNT (current message count on the queue, including scheduled, paged and in-delivery messages), MESSAGES_ADDED (messages added to the queue), DELIVERING_COUNT (messages broker is currently delivering to consumer(s)), MESSAGES_ACKED (messages acknowledged from the consumer(s))." + " Queues can be filtered using EITHER '--queueName X' where X [...]
@@ -35,9 +37,16 @@ import java.util.HashMap;
public class StatQueue extends AbstractAction {
public enum FIELD {
-
NAME("name"), ADDRESS("address"), CONSUMER_COUNT("consumerCount"), MESSAGE_COUNT("messageCount"), MESSAGES_ADDED("messagesAdded"), DELIVERING_COUNT("deliveringCount"), MESSAGES_ACKED("messagesAcked"), SCHEDULED_COUNT("scheduledCount"), ROUTING_TYPE("routingType");
+ private static final Map<String, FIELD> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (FIELD e: values()) {
+ lookup.put(e.jsonId, e);
+ }
+ }
+
private String jsonId;
FIELD(String jsonId) {
@@ -48,6 +57,9 @@ public class StatQueue extends AbstractAction {
return this.jsonId;
}
+ public static FIELD valueOfJsonId(String jsonId) {
+ return lookup.get(jsonId);
+ }
}
public enum OPERATION {
@@ -224,7 +236,13 @@ public class StatQueue extends AbstractAction {
if ((fieldName != null) && (fieldName.trim().length() > 0)) {
try {
- FIELD field = FIELD.valueOf(fieldName);
+ FIELD field = FIELD.valueOfJsonId(fieldName);
+
+ //for backward compatibility
+ if (field == null) {
+ field = FIELD.valueOf(fieldName);
+ }
+
filterMap.put("field", field.toString());
} catch (IllegalArgumentException ex) {
context.err.println("'--field' must be set to one of the following " + Arrays.toString(FIELD.values()));
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 649fe05..d15a3a2 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
@@ -100,8 +100,8 @@ var Artemis;
fieldOptions: [
{id: 'id', name: 'ID'},
{id: 'name', name: 'Name'},
- {id: 'routing_Types', name: 'Routing Types'},
- {id: 'queue_Count', name: 'Queue Count'}
+ {id: 'routingTypes', name: 'Routing Types'},
+ {id: 'queueCount', name: 'Queue Count'}
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
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 3aa3099..c3f95e4 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
@@ -118,14 +118,14 @@ var Artemis;
ctrl.filter = {
fieldOptions: [
- {id: 'connection_id', name: 'ID'},
- {id: 'client_id', name: 'Client ID'},
+ {id: 'connectionID', name: 'ID'},
+ {id: 'clientID', name: 'Client ID'},
{id: 'users', name: 'Users'},
{id: 'protocol', name: 'Protocol'},
- {id: 'session_count', name: 'Session Count'},
- {id: 'remote_address', name: 'Remote Address'},
- {id: 'local_address', name: 'Local Address'},
- {id: 'session_id', name: 'Session ID'}
+ {id: 'sessionCount', name: 'Session Count'},
+ {id: 'remoteAddress', name: 'Remote Address'},
+ {id: 'localAddress', name: 'Local Address'},
+ {id: 'sessionID', name: 'Session ID'}
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
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 da55649..e7de525 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
@@ -117,15 +117,15 @@ var Artemis;
}
ctrl.filter = {
fieldOptions: [
- {id: 'ID', name: 'ID'},
- {id: 'SESSION_ID', name: 'Session ID'},
- {id: 'CLIENT_ID', name: 'Client ID'},
- {id: 'USER', name: 'User'},
- {id: 'ADDRESS', name: 'Address'},
- {id: 'QUEUE', name: 'Queue'},
- {id: 'PROTOCOL', name: 'Protocol'},
- {id: 'LOCAL_ADDRESS', name: 'Local Address'},
- {id: 'REMOTE_ADDRESS', name: 'Remote Address'}
+ {id: 'id', name: 'ID'},
+ {id: 'session', name: 'Session'},
+ {id: 'clientID', name: 'Client ID'},
+ {id: 'user', name: 'User'},
+ {id: 'address', name: 'Address'},
+ {id: 'queue', name: 'Queue'},
+ {id: 'protocol', name: 'Protocol'},
+ {id: 'localAddress', name: 'Local Address'},
+ {id: 'remoteAddress', name: 'Remote Address'}
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
@@ -197,10 +197,10 @@ var Artemis;
};
if (artemisConsumer.consumer) {
- Artemis.log.debug("navigating to consumer = " + artemisConsumer.consumer.sessionID);
+ Artemis.log.debug("navigating to consumer = " + artemisConsumer.consumer.session);
ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
- ctrl.filter.values.value = artemisConsumer.consumer.sessionID;
+ ctrl.filter.values.value = artemisConsumer.consumer.session;
artemisConsumer.consumer = null;
}
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 9d87c01..b7a098c 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
@@ -98,14 +98,14 @@ var Artemis;
}
ctrl.filter = {
fieldOptions: [
- {id: 'ID', name: 'ID'},
- {id: 'SESSION_ID', name: 'Session ID'},
- {id: 'CLIENT_ID', name: 'Client ID'},
- {id: 'USER', name: 'User'},
- {id: 'ADDRESS', name: 'Address'},
- {id: 'PROTOCOL', name: 'Protocol'},
- {id: 'LOCAL_ADDRESS', name: 'Local Address'},
- {id: 'REMOTE_ADDRESS', name: 'Remote Address'}
+ {id: 'id', name: 'ID'},
+ {id: 'session', name: 'Session'},
+ {id: 'clientID', name: 'Client ID'},
+ {id: 'user', name: 'User'},
+ {id: 'address', name: 'Address'},
+ {id: 'protocol', name: 'Protocol'},
+ {id: 'localAddress', name: 'Local Address'},
+ {id: 'remoteAddress', name: 'Remote Address'}
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
@@ -178,10 +178,10 @@ var Artemis;
};
if (artemisProducer.producer) {
- Artemis.log.debug("navigating to producer = " + artemisProducer.producer.sessionID);
+ Artemis.log.debug("navigating to producer = " + artemisProducer.producer.session);
ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
- ctrl.filter.values.value = artemisProducer.producer.sessionID;
+ ctrl.filter.values.value = artemisProducer.producer.session;
artemisProducer.producer = null;
}
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 ab2da29..6c80f21 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
@@ -127,18 +127,18 @@ var Artemis;
fieldOptions: [
{id: 'id', name: 'ID'},
{id: 'name', name: 'Name'},
- {id: 'consumer_Id', name: 'Consumer ID'},
+ {id: 'consumerId', name: 'Consumer ID'},
{id: 'address', name: 'Address'},
{id: 'filter', name: 'Filter'},
- {id: 'max_Consumers', name: 'Max Consumers'},
- {id: 'routing_Type', name: 'Routing Type'},
- {id: 'purge_On_No_Consumers', name: 'Purge On No Consumers'},
+ {id: 'maxConsumers', name: 'Max Consumers'},
+ {id: 'routingType', name: 'Routing Type'},
+ {id: 'purgeOnNoConsumers', name: 'Purge On No Consumers'},
{id: 'user', name: 'User'},
- {id: 'message_Count', name: 'Message Count'},
- {id: 'delivering_Count', name: 'Delivering Count'},
+ {id: 'messageCount', name: 'Message Count'},
+ {id: 'deliveringCount', name: 'Delivering Count'},
{id: 'paused', name: 'Paused'},
{id: 'temporary', name: 'Temporary'},
- {id: 'auto_Created', name: 'Auto Created'},
+ {id: 'autoCreated', name: 'Auto Created'},
{id: 'rate', name: 'Rate'}
],
operationOptions: [
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 47dd96f..2fe9bd4 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
@@ -114,13 +114,13 @@ var Artemis;
ctrl.filter = {
fieldOptions: [
{id: 'id', name: 'ID'},
- {id: 'connection_id', name: 'Connection ID'},
- {id: 'consumer_count', name: 'Consumer Count'},
+ {id: 'connectionID', name: 'Connection ID'},
+ {id: 'consumerCount', name: 'Consumer Count'},
{id: 'user', name: 'User'},
{id: 'protocol', name: 'Protocol'},
- {id: 'client_id', name: 'Client ID'},
- {id: 'local_address', name: 'Local Address'},
- {id: 'remote_address', name: 'Remote Address'}
+ {id: 'clientID', name: 'Client ID'},
+ {id: 'localAddress', name: 'Local Address'},
+ {id: 'remoteAddress', name: 'Remote Address'}
],
operationOptions: [
{id: 'EQUALS', name: 'Equals'},
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressField.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressField.java
new file mode 100644
index 0000000..4f3667b
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/AddressField.java
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public enum AddressField {
+ ID("id"),
+ NAME("name"),
+ ROUTING_TYPES("routingTypes"),
+ PRODUCER_ID("producerId"),
+ QUEUE_COUNT("queueCount");
+
+ private static final Map<String, AddressField> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (AddressField e: values()) {
+ lookup.put(e.name, e);
+ }
+ }
+
+ private final String name;
+
+ public String getName() {
+ return name;
+ }
+
+ AddressField(String name) {
+ this.name = name;
+ }
+
+ public static AddressField valueOfName(String name) {
+ return lookup.get(name);
+ }
+}
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 c5e0629..2594f20 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 = "id";
+ private static final String defaultSortColumn = AddressField.ID.getName();
private final ActiveMQServer server;
@@ -45,13 +45,16 @@ public class AddressView extends ActiveMQAbstractView<AddressInfo> {
return null;
}
- JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(address.getId())).add("name", toString(address.getName())).add("routingTypes", toString(address.getRoutingTypes()));
+ JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
+ .add(AddressField.ID.getName(), toString(address.getId()))
+ .add(AddressField.NAME.getName(), toString(address.getName()))
+ .add(AddressField.ROUTING_TYPES.getName(), toString(address.getRoutingTypes()));
try {
- obj.add("queueCount", toString(server.bindingQuery(address.getName()).getQueueNames().size()));
+ obj.add(AddressField.QUEUE_COUNT.getName(), toString(server.bindingQuery(address.getName()).getQueueNames().size()));
return obj;
} catch (Exception e) {
- obj.add("queueCount", 0);
+ obj.add(AddressField.QUEUE_COUNT.getName(), 0);
}
return obj;
}
@@ -62,14 +65,16 @@ public class AddressView extends ActiveMQAbstractView<AddressInfo> {
return null;
}
- switch (fieldName) {
- case "id":
+ AddressField field = AddressField.valueOfName(fieldName);
+
+ switch (field) {
+ case ID:
return address.getId();
- case "name":
+ case NAME:
return address.getName();
- case "routingTypes":
+ case ROUTING_TYPES:
return address.getRoutingTypes();
- case "queueCount":
+ case QUEUE_COUNT:
try {
return server.bindingQuery(address.getName()).getQueueNames().size();
} catch (Exception e) {
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionField.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionField.java
new file mode 100644
index 0000000..272f706
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConnectionField.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public enum ConnectionField {
+ CONNECTION_ID("connectionID"),
+ CLIENT_ID("clientID"),
+ USERS("users"),
+ PROTOCOL("protocol"),
+ SESSION_COUNT("sessionCount"),
+ REMOTE_ADDRESS("remoteAddress"),
+ LOCAL_ADDRESS("localAddress"),
+ SESSION_ID("sessionID"),
+ CREATION_TIME("creationTime"),
+ IMPLEMENTATION("implementation");
+
+ private static final Map<String, ConnectionField> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (ConnectionField e: values()) {
+ lookup.put(e.name, e);
+ }
+ }
+
+ private final String name;
+
+ public String getName() {
+ return name;
+ }
+
+ ConnectionField(String name) {
+ this.name = name;
+ }
+
+ public static ConnectionField valueOfName(String name) {
+ return lookup.get(name);
+ }
+}
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 0bf0017..18b8d30 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
@@ -32,7 +32,7 @@ import org.apache.activemq.artemis.utils.StringUtil;
public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
- private static final String defaultSortColumn = "connectionID";
+ private static final String defaultSortColumn = ConnectionField.CONNECTION_ID.getName();
private final ActiveMQServer server;
@@ -62,25 +62,28 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
}
}
- return JsonLoader.createObjectBuilder().add("connectionID", toString(connection.getID()))
- .add("remoteAddress", toString(connection.getRemoteAddress()))
- .add("users", StringUtil.joinStringList(users, ","))
- .add("creationTime", new Date(connection.getCreationTime()).toString())
- .add("implementation", toString(connection.getClass().getSimpleName()))
- .add("protocol", toString(connection.getProtocolName()))
- .add("clientID", toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID))
- .add("localAddress", toString(connection.getTransportLocalAddress()))
- .add("sessionCount", sessions.size());
+ return JsonLoader.createObjectBuilder()
+ .add(ConnectionField.CONNECTION_ID.getName(), toString(connection.getID()))
+ .add(ConnectionField.REMOTE_ADDRESS.getName(), toString(connection.getRemoteAddress()))
+ .add(ConnectionField.USERS.getName(), StringUtil.joinStringList(users, ","))
+ .add(ConnectionField.CREATION_TIME.getName(), new Date(connection.getCreationTime()).toString())
+ .add(ConnectionField.IMPLEMENTATION.getName(), toString(connection.getClass().getSimpleName()))
+ .add(ConnectionField.PROTOCOL.getName(), toString(connection.getProtocolName()))
+ .add(ConnectionField.CLIENT_ID.getName(), toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID))
+ .add(ConnectionField.LOCAL_ADDRESS.getName(), toString(connection.getTransportLocalAddress()))
+ .add(ConnectionField.SESSION_COUNT.getName(), sessions.size());
}
@Override
public Object getField(RemotingConnection connection, String fieldName) {
- switch (fieldName) {
- case "connectionID":
+ ConnectionField field = ConnectionField.valueOfName(fieldName);
+
+ switch (field) {
+ case CONNECTION_ID:
return connection.getID();
- case "remoteAddress":
+ case REMOTE_ADDRESS:
return connection.getRemoteAddress();
- case "users":
+ case USERS:
Set<String> users = new TreeSet<>();
List<ServerSession> sessions = server.getSessions(connection.getID().toString());
for (ServerSession session : sessions) {
@@ -88,17 +91,17 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
users.add(username);
}
return StringUtil.joinStringList(users, ",");
- case "creationTime":
+ case CREATION_TIME:
return new Date(connection.getCreationTime());
- case "implementation":
+ case IMPLEMENTATION:
return connection.getClass().getSimpleName();
- case "protocol":
+ case PROTOCOL:
return connection.getProtocolName();
- case "clientID":
+ case CLIENT_ID:
return connection.getClientID();
- case "localAddress":
+ case LOCAL_ADDRESS:
return connection.getTransportLocalAddress();
- case "sessionCount":
+ case SESSION_COUNT:
return server.getSessions(connection.getID().toString()).size();
default:
throw new IllegalArgumentException("Unsupported field, " + fieldName);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerField.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerField.java
new file mode 100644
index 0000000..6269288
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ConsumerField.java
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public enum ConsumerField {
+ ID("id"),
+ SESSION("session"),
+ QUEUE("queue"),
+ FILTER("filter"),
+ ADDRESS("address"),
+ USER("user"),
+ PROTOCOL("protocol"),
+ CLIENT_ID("clientID"),
+ LOCAL_ADDRESS("localAddress"),
+ REMOTE_ADDRESS("remoteAddress"),
+ QUEUE_TYPE("queueType"),
+ CREATION_TIME("creationTime");
+
+ private static final Map<String, ConsumerField> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (ConsumerField e: values()) {
+ lookup.put(e.name, e);
+ }
+ }
+
+ private final String name;
+
+ public String getName() {
+ return name;
+ }
+
+ ConsumerField(String name) {
+ this.name = name;
+ }
+
+ public static ConsumerField valueOfName(String name) {
+ return lookup.get(name);
+ }
+}
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 019e64b..34eeffb 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
@@ -28,7 +28,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
- private static final String defaultSortColumn = "id";
+ private static final String defaultSortColumn = ConsumerField.ID.getName();
private final ActiveMQServer server;
@@ -52,24 +52,25 @@ public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
return null;
}
- String jmsSessionClientID = null;
- //for the special case for JMS
- if (session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
- jmsSessionClientID = session.getMetaData("jms-client-id");
+ String consumerClientID = consumer.getConnectionClientID();
+ if (consumerClientID == null && session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
+ //for the special case for JMS
+ consumerClientID = session.getMetaData("jms-client-id");
}
- JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(consumer.getSequentialID()))
- .add("session", toString(consumer.getSessionName()))
- .add("clientID", toString(consumer.getConnectionClientID() != null ? consumer.getConnectionClientID() : jmsSessionClientID))
- .add("user", toString(session.getUsername()))
- .add("protocol", toString(consumer.getConnectionProtocolName()))
- .add("queue", toString(consumer.getQueueName()))
- .add("queueType", toString(consumer.getQueueType()).toLowerCase())
- .add("filter", toString(consumer.getFilterString()))
- .add("address", toString(consumer.getQueueAddress()))
- .add("localAddress", toString(consumer.getConnectionLocalAddress()))
- .add("remoteAddress", toString(consumer.getConnectionRemoteAddress()))
- .add("creationTime", new Date(consumer.getCreationTime()).toString());
+ JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
+ .add(ConsumerField.ID.getName(), toString(consumer.getSequentialID()))
+ .add(ConsumerField.SESSION.getName(), toString(consumer.getSessionName()))
+ .add(ConsumerField.CLIENT_ID.getName(), toString(consumerClientID))
+ .add(ConsumerField.USER.getName(), toString(session.getUsername()))
+ .add(ConsumerField.PROTOCOL.getName(), toString(consumer.getConnectionProtocolName()))
+ .add(ConsumerField.QUEUE.getName(), toString(consumer.getQueueName()))
+ .add(ConsumerField.QUEUE_TYPE.getName(), toString(consumer.getQueueType()).toLowerCase())
+ .add(ConsumerField.FILTER.getName(), toString(consumer.getFilterString()))
+ .add(ConsumerField.ADDRESS.getName(), toString(consumer.getQueueAddress()))
+ .add(ConsumerField.LOCAL_ADDRESS.getName(), toString(consumer.getConnectionLocalAddress()))
+ .add(ConsumerField.REMOTE_ADDRESS.getName(), toString(consumer.getConnectionRemoteAddress()))
+ .add(ConsumerField.CREATION_TIME.getName(), new Date(consumer.getCreationTime()).toString());
return obj;
}
@@ -82,28 +83,30 @@ public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
return null;
}
- switch (fieldName) {
- case "id":
+ ConsumerField field = ConsumerField.valueOfName(fieldName);
+
+ switch (field) {
+ case ID:
return consumer.getSequentialID();
- case "session":
+ case SESSION:
return consumer.getSessionName();
- case "user":
+ case USER:
return session.getUsername();
- case "clientID":
+ case CLIENT_ID:
return consumer.getConnectionClientID();
- case "protocol":
+ case PROTOCOL:
return consumer.getConnectionProtocolName();
- case "queue":
+ case QUEUE:
return consumer.getQueueName();
- case "queueType":
+ case QUEUE_TYPE:
return consumer.getQueueType();
- case "filter":
+ case FILTER:
return consumer.getFilterString();
- case "localAddress":
+ case LOCAL_ADDRESS:
return consumer.getConnectionLocalAddress();
- case "remoteAddress":
+ case REMOTE_ADDRESS:
return consumer.getConnectionRemoteAddress();
- case "creationTime":
+ case CREATION_TIME:
return new Date(consumer.getCreationTime());
default:
throw new IllegalArgumentException("Unsupported field, " + fieldName);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerField.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerField.java
new file mode 100644
index 0000000..3352dea
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/ProducerField.java
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public enum ProducerField {
+ ID("id"),
+ SESSION("session"),
+ CONNECTION_ID("connectionID"),
+ ADDRESS("address"), USER("user"),
+ PROTOCOL("protocol"),
+ CLIENT_ID("clientID"),
+ LOCAL_ADDRESS("localAddress"),
+ REMOTE_ADDRESS("remoteAddress"),
+ CREATION_TIME("creationTime");
+
+ private static final Map<String, ProducerField> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (ProducerField e: values()) {
+ lookup.put(e.name, e);
+ }
+ }
+
+ private final String name;
+
+ public String getName() {
+ return name;
+ }
+
+ ProducerField(String name) {
+ this.name = name;
+ }
+
+ public static ProducerField valueOfName(String name) {
+ return lookup.get(name);
+ }
+}
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 27aed84..ac3fcf6 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
@@ -27,7 +27,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
- private static final String defaultSortColumn = "creationTime";
+ private static final String defaultSortColumn = ProducerField.CREATION_TIME.getName();
private final ActiveMQServer server;
@@ -51,21 +51,22 @@ public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
return null;
}
- String jmsSessionClientID = null;
+ String sessionClientID = session.getRemotingConnection().getClientID();
//for the special case for JMS
- if (session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
- jmsSessionClientID = session.getMetaData("jms-client-id");
+ if (sessionClientID == null && session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
+ sessionClientID = session.getMetaData("jms-client-id");
}
- JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(producer.getID()))
- .add("session", toString(session.getName()))
- .add("clientID", toString(session.getRemotingConnection().getClientID() != null ? session.getRemotingConnection().getClientID() : jmsSessionClientID))
- .add("user", toString(session.getUsername()))
- .add("protocol", toString(session.getRemotingConnection().getProtocolName()))
- .add("address", toString(producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress()))
- .add("localAddress", toString(session.getRemotingConnection().getTransportConnection().getLocalAddress()))
- .add("remoteAddress", toString(session.getRemotingConnection().getTransportConnection().getRemoteAddress()))
- .add("creationTime", toString(producer.getCreationTime()));
+ JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
+ .add(ProducerField.ID.getName(), toString(producer.getID()))
+ .add(ProducerField.SESSION.getName(), toString(session.getName()))
+ .add(ProducerField.CLIENT_ID.getName(), toString(sessionClientID))
+ .add(ProducerField.USER.getName(), toString(session.getUsername()))
+ .add(ProducerField.PROTOCOL.getName(), toString(session.getRemotingConnection().getProtocolName()))
+ .add(ProducerField.ADDRESS.getName(), toString(producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress()))
+ .add(ProducerField.LOCAL_ADDRESS.getName(), toString(session.getRemotingConnection().getTransportConnection().getLocalAddress()))
+ .add(ProducerField.REMOTE_ADDRESS.getName(), toString(session.getRemotingConnection().getTransportConnection().getRemoteAddress()))
+ .add(ProducerField.CREATION_TIME.getName(), toString(producer.getCreationTime()));
return obj;
}
@@ -78,24 +79,26 @@ public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
return null;
}
- switch (fieldName) {
- case "id":
+ ProducerField field = ProducerField.valueOfName(fieldName);
+
+ switch (field) {
+ case ID:
return producer.getID();
- case "session":
+ case SESSION:
return session.getName();
- case "user":
+ case USER:
return session.getUsername();
- case "clientID":
+ case CLIENT_ID:
return session.getRemotingConnection().getClientID();
- case "protocol":
+ case PROTOCOL:
return session.getRemotingConnection().getProtocolName();
- case "address":
+ case ADDRESS:
return producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress();
- case "localAddress":
+ case LOCAL_ADDRESS:
return session.getRemotingConnection().getTransportConnection().getLocalAddress();
- case "remoteAddress":
+ case REMOTE_ADDRESS:
return session.getRemotingConnection().getTransportConnection().getRemoteAddress();
- case "creationTime":
+ case CREATION_TIME:
return producer.getCreationTime();
default:
throw new IllegalArgumentException("Unsupported field, " + fieldName);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueField.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueField.java
new file mode 100644
index 0000000..8486ab6
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/QueueField.java
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public enum QueueField {
+ ID("id"),
+ NAME("name"),
+ CONSUMER_ID("consumerID"),
+ ADDRESS("address"),
+ MAX_CONSUMERS("maxConsumers"),
+ FILTER("filter"),
+ MESSAGE_COUNT("messageCount"),
+ CONSUMER_COUNT("consumerCount"),
+ DELIVERING_COUNT("deliveringCount"),
+ MESSAGES_ADDED("messagesAdded"),
+ MESSAGES_ACKED("messagesAcked"),
+ RATE("rate"),
+ ROUTING_TYPE("routingType"),
+ USER("user"),
+ AUTO_CREATED("autoCreated"),
+ DURABLE("durable"),
+ PAUSED("paused"),
+ TEMPORARY("temporary"),
+ PURGE_ON_NO_CONSUMERS("purgeOnNoConsumers"),
+ MESSAGES_KILLED("messagesKilled"),
+ DIRECT_DELIVER("directDeliver"),
+ LAST_VALUE("lastValue"),
+ EXCLUSIVE("exclusive"),
+ SCHEDULED_COUNT("scheduledCount"),
+ LAST_VALUE_KEY("lastValueKey"),
+ GROUP_REBALANCE("groupRebalance"),
+ GROUP_REBALANCE_PAUSE_DISPATCH("groupRebalancePauseDispatch"),
+ GROUP_BUCKETS("groupBuckets"),
+ GROUP_FIRST_KEY("groupFirstKey"),
+ ENABLED("enabled"),
+ RING_SIZE("ringSize"),
+ CONSUMERS_BEFORE_DISPATCH("consumersBeforeDispatch"),
+ DELAY_BEFORE_DISPATCH("delayBeforeDispatch");
+
+ private static final Map<String, QueueField> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (QueueField e: values()) {
+ lookup.put(e.name, e);
+ }
+ }
+
+ private final String name;
+
+ public String getName() {
+ return name;
+ }
+
+ QueueField(String name) {
+ this.name = name;
+ }
+
+ public static QueueField valueOfName(String name) {
+ return lookup.get(name);
+ }
+}
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 66d16e1..ded307c 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 = "name";
+ private static final String defaultSortColumn = QueueField.NAME.getName();
private ActiveMQServer server;
@@ -44,105 +44,112 @@ public class QueueView extends ActiveMQAbstractView<QueueControl> {
@Override
public JsonObjectBuilder toJson(QueueControl queue) {
Queue q = server.locateQueue(new SimpleString(queue.getName()));
- JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(queue.getID()))
- .add("name", toString(queue.getName())).add("address", toString(queue.getAddress()))
- .add("filter", toString(queue.getFilter())).add("rate", toString(q.getRate()))
- .add("durable", toString(queue.isDurable())).add("paused", toString(q.isPaused()))
- .add("temporary", toString(queue.isTemporary()))
- .add("purgeOnNoConsumers", toString(queue.isPurgeOnNoConsumers()))
- .add("consumerCount", toString(queue.getConsumerCount()))
- .add("maxConsumers", toString(queue.getMaxConsumers()))
- .add("autoCreated", toString(q.isAutoCreated()))
- .add("user", toString(q.getUser()))
- .add("routingType", toString(queue.getRoutingType()))
- .add("messagesAdded", toString(queue.getMessagesAdded()))
- .add("messageCount", toString(queue.getMessageCount()))
- .add("messagesAcked", toString(queue.getMessagesAcknowledged()))
- .add("deliveringCount", toString(queue.getDeliveringCount()))
- .add("messagesKilled", toString(queue.getMessagesKilled()))
- .add("directDeliver", toString(q.isDirectDeliver()))
- .add("exclusive", toString(queue.isExclusive()))
- .add("lastValue", toString(queue.isLastValue()))
- .add("lastValueKey", toString(queue.getLastValueKey()))
- .add("scheduledCount", toString(queue.getScheduledCount()))
- .add("groupRebalance", toString(queue.isGroupRebalance()))
- .add("groupRebalancePauseDispatch", toString(queue.isGroupRebalancePauseDispatch()))
- .add("groupBuckets", toString(queue.getGroupBuckets()))
- .add("groupFirstKey", toString(queue.getGroupFirstKey()))
- .add("enabled", toString(queue.isEnabled()))
- .add("ringSize", toString(queue.getRingSize()))
- .add("consumersBeforeDispatch", toString(queue.getConsumersBeforeDispatch()))
- .add("delayBeforeDispatch", toString(queue.getDelayBeforeDispatch()));
+ JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
+ .add(QueueField.ID.getName(), toString(queue.getID()))
+ .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()))
+ .add(QueueField.PURGE_ON_NO_CONSUMERS.getName(), toString(queue.isPurgeOnNoConsumers()))
+ .add(QueueField.CONSUMER_COUNT.getName(), toString(queue.getConsumerCount()))
+ .add(QueueField.MAX_CONSUMERS.getName(), toString(queue.getMaxConsumers()))
+ .add(QueueField.AUTO_CREATED.getName(), toString(q.isAutoCreated()))
+ .add(QueueField.USER.getName(), toString(q.getUser()))
+ .add(QueueField.ROUTING_TYPE.getName(), toString(queue.getRoutingType()))
+ .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.DELIVERING_COUNT.getName(), toString(queue.getDeliveringCount()))
+ .add(QueueField.MESSAGES_KILLED.getName(), toString(queue.getMessagesKilled()))
+ .add(QueueField.DIRECT_DELIVER.getName(), toString(q.isDirectDeliver()))
+ .add(QueueField.EXCLUSIVE.getName(), toString(queue.isExclusive()))
+ .add(QueueField.LAST_VALUE.getName(), toString(queue.isLastValue()))
+ .add(QueueField.LAST_VALUE_KEY.getName(), toString(queue.getLastValueKey()))
+ .add(QueueField.SCHEDULED_COUNT.getName(), toString(queue.getScheduledCount()))
+ .add(QueueField.GROUP_REBALANCE.getName(), toString(queue.isGroupRebalance()))
+ .add(QueueField.GROUP_REBALANCE_PAUSE_DISPATCH.getName(), toString(queue.isGroupRebalancePauseDispatch()))
+ .add(QueueField.GROUP_BUCKETS.getName(), toString(queue.getGroupBuckets()))
+ .add(QueueField.GROUP_FIRST_KEY.getName(), toString(queue.getGroupFirstKey()))
+ .add(QueueField.ENABLED.getName(), toString(queue.isEnabled()))
+ .add(QueueField.RING_SIZE.getName(), toString(queue.getRingSize()))
+ .add(QueueField.CONSUMERS_BEFORE_DISPATCH.getName(), toString(queue.getConsumersBeforeDispatch()))
+ .add(QueueField.DELAY_BEFORE_DISPATCH.getName(), toString(queue.getDelayBeforeDispatch()));
return obj;
}
@Override
public Object getField(QueueControl queue, String fieldName) {
Queue q = server.locateQueue(new SimpleString(queue.getName()));
- switch (fieldName) {
- case "id":
+
+ QueueField field = QueueField.valueOfName(fieldName);
+
+ switch (field) {
+ case ID:
return queue.getID();
- case "name":
+ case NAME:
return queue.getName();
- case "address":
+ case ADDRESS:
return queue.getAddress();
- case "filter":
+ case FILTER:
return queue.getFilter();
- case "rate":
+ case RATE:
return q.getRate();
- case "durable":
+ case DURABLE:
return queue.isDurable();
- case "paused":
+ case PAUSED:
return q.isPaused();
- case "temporary":
+ case TEMPORARY:
return queue.isTemporary();
- case "purgeOnNoConsumers":
+ case PURGE_ON_NO_CONSUMERS:
return queue.isPurgeOnNoConsumers();
- case "consumerCount":
+ case CONSUMER_COUNT:
return queue.getConsumerCount();
- case "maxConsumers":
+ case MAX_CONSUMERS:
return queue.getMaxConsumers();
- case "autoCreated":
+ case AUTO_CREATED:
return q.isAutoCreated();
- case "user":
+ case USER:
return q.getUser();
- case "routingType":
+ case ROUTING_TYPE:
return queue.getRoutingType();
- case "messagesAdded":
+ case MESSAGES_ADDED:
return queue.getMessagesAdded();
- case "messageCount":
+ case MESSAGE_COUNT:
return queue.getMessageCount();
- case "messagesAcked":
+ case MESSAGES_ACKED:
return queue.getMessagesAcknowledged();
- case "deliveringCount":
+ case DELIVERING_COUNT:
return queue.getDeliveringCount();
- case "messagesKilled":
+ case MESSAGES_KILLED:
return queue.getMessagesKilled();
- case "deliverDeliver":
+ case DIRECT_DELIVER:
return q.isDirectDeliver();
- case "exclusive":
+ case EXCLUSIVE:
return q.isExclusive();
- case "lastValue":
+ case LAST_VALUE:
return q.isLastValue();
- case "lastValueKey":
+ case LAST_VALUE_KEY:
return q.getLastValueKey();
- case "scheduledCount":
+ case SCHEDULED_COUNT:
return q.getScheduledCount();
- case "groupRebalance":
+ case GROUP_REBALANCE:
return queue.isGroupRebalance();
- case "groupRebalancePauseDispatch":
+ case GROUP_REBALANCE_PAUSE_DISPATCH:
return queue.isGroupRebalancePauseDispatch();
- case "groupBuckets":
+ case GROUP_BUCKETS:
return queue.getGroupBuckets();
- case "groupFirstKey":
+ case GROUP_FIRST_KEY:
return queue.getGroupFirstKey();
- case "enabled":
+ case ENABLED:
return q.isEnabled();
- case "ringSize":
+ case RING_SIZE:
return q.getRingSize();
- case "consumersBeforeDispatch":
+ case CONSUMERS_BEFORE_DISPATCH:
return q.getConsumersBeforeDispatch();
- case "delayBeforeDispatch":
+ case DELAY_BEFORE_DISPATCH:
return q.getDelayBeforeDispatch();
default:
throw new IllegalArgumentException("Unsupported field, " + fieldName);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionField.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionField.java
new file mode 100644
index 0000000..e4c8871
--- /dev/null
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/SessionField.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public enum SessionField {
+ ID("id"),
+ CONNECTION_ID("connectionID"),
+ CONSUMER_COUNT("consumerCount"),
+ PRODUCER_COUNT("producerCount"),
+ USER("user"),
+ PROTOCOL("protocol"),
+ CLIENT_ID("clientID"),
+ LOCAL_ADDRESS("localAddress"),
+ REMOTE_ADDRESS("remoteAddress"),
+ CREATION_TIME("creationTime");
+
+ private static final Map<String, SessionField> lookup = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+
+ static {
+ for (SessionField e: values()) {
+ lookup.put(e.name, e);
+ }
+ }
+
+ private final String name;
+
+ public String getName() {
+ return name;
+ }
+
+ SessionField(String name) {
+ this.name = name;
+ }
+
+ public static SessionField valueOfName(String name) {
+ return lookup.get(name);
+ }
+}
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 a1d85d8..f1ece69 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 = "id";
+ private static final String defaultSortColumn = SessionField.ID.getName();
public SessionView() {
super();
@@ -39,29 +39,32 @@ public class SessionView extends ActiveMQAbstractView<ServerSession> {
@Override
public JsonObjectBuilder toJson(ServerSession session) {
- JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(session.getName()))
- .add("user", toString(session.getUsername()))
- .add("creationTime", new Date(session.getCreationTime()).toString())
- .add("consumerCount", session.getConsumerCount())
- .add("producerCount", session.getProducerCount())
- .add("connectionID", session.getConnectionID().toString());
+ JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
+ .add(SessionField.ID.getName(), toString(session.getName()))
+ .add(SessionField.USER.getName(), toString(session.getUsername()))
+ .add(SessionField.CREATION_TIME.getName(), new Date(session.getCreationTime()).toString())
+ .add(SessionField.CONSUMER_COUNT.getName(), session.getConsumerCount())
+ .add(SessionField.PRODUCER_COUNT.getName(), session.getProducerCount())
+ .add(SessionField.CONNECTION_ID.getName(), session.getConnectionID().toString());
return obj;
}
@Override
public Object getField(ServerSession session, String fieldName) {
- switch (fieldName) {
- case "id":
+ SessionField field = SessionField.valueOfName(fieldName);
+
+ switch (field) {
+ case ID:
return session.getName();
- case "user":
+ case USER:
return session.getUsername();
- case "creationTime":
+ case CREATION_TIME:
return new Date(session.getCreationTime());
- case "consumerCount":
+ case CONSUMER_COUNT:
return session.getConsumerCount();
- case "producerCount":
+ case PRODUCER_COUNT:
return session.getProducerCount();
- case "connectionID":
+ case CONNECTION_ID:
return session.getConnectionID();
default:
throw new IllegalArgumentException("Unsupported field, " + fieldName);
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/AddressFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/AddressFilterPredicate.java
index 6c7789a..04eb82b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/AddressFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/AddressFilterPredicate.java
@@ -16,16 +16,13 @@
*/
package org.apache.activemq.artemis.core.management.impl.view.predicate;
+import org.apache.activemq.artemis.core.management.impl.view.AddressField;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
public class AddressFilterPredicate extends ActiveMQFilterPredicate<AddressInfo> {
- enum Field {
- ID, NAME, ROUTING_TYPES, PRODUCER_ID, QUEUE_COUNT
- }
-
- private Field f;
+ private AddressField f;
private final ActiveMQServer server;
@@ -61,7 +58,12 @@ public class AddressFilterPredicate extends ActiveMQFilterPredicate<AddressInfo>
@Override
public void setField(String field) {
if (field != null && !field.equals("")) {
- this.f = Field.valueOf(field.toUpperCase());
+ this.f = AddressField.valueOfName(field);
+
+ //for backward compatibility
+ if (this.f == null) {
+ this.f = AddressField.valueOf(field);
+ }
}
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConnectionFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConnectionFilterPredicate.java
index 0b441f4..6b4d214 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConnectionFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConnectionFilterPredicate.java
@@ -20,17 +20,14 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.apache.activemq.artemis.core.management.impl.view.ConnectionField;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingConnection> {
- enum Field {
- CONNECTION_ID, CLIENT_ID, USERS, PROTOCOL, SESSION_COUNT, REMOTE_ADDRESS, LOCAL_ADDRESS, SESSION_ID
- }
-
- private Field f;
+ private ConnectionField f;
private ActiveMQServer server;
@@ -66,6 +63,10 @@ public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingC
return matches(connection.getTransportConnection().getLocalAddress());
case SESSION_ID:
return matchAny(server.getSessions(connection.getID().toString()));
+ case CREATION_TIME:
+ return matches(connection.getCreationTime());
+ case IMPLEMENTATION:
+ return matches(connection.getClass().getSimpleName());
}
return true;
}
@@ -73,7 +74,12 @@ public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingC
@Override
public void setField(String field) {
if (field != null && !field.equals("")) {
- this.f = Field.valueOf(field.toUpperCase());
+ this.f = ConnectionField.valueOfName(field);
+
+ //for backward compatibility
+ if (this.f == null) {
+ this.f = ConnectionField.valueOf(field);
+ }
}
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConsumerFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConsumerFilterPredicate.java
index bd6af11..2f3296b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConsumerFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ConsumerFilterPredicate.java
@@ -16,16 +16,13 @@
*/
package org.apache.activemq.artemis.core.management.impl.view.predicate;
+import org.apache.activemq.artemis.core.management.impl.view.ConsumerField;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerConsumer;
public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsumer> {
- enum Field {
- ID, SESSION_ID, QUEUE, FILTER, ADDRESS, USER, PROTOCOL, CLIENT_ID, LOCAL_ADDRESS, REMOTE_ADDRESS
- }
-
- private Field f;
+ private ConsumerField f;
private final ActiveMQServer server;
@@ -42,7 +39,7 @@ public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsu
switch (f) {
case ID:
return matches(consumer.getSequentialID());
- case SESSION_ID:
+ case SESSION:
return matches(consumer.getSessionID());
case USER:
return matches(server.getSessionByID(consumer.getSessionID()).getUsername());
@@ -67,7 +64,12 @@ public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsu
@Override
public void setField(String field) {
if (field != null && !field.equals("")) {
- this.f = Field.valueOf(field.toUpperCase());
+ this.f = ConsumerField.valueOfName(field);
+
+ //for backward compatibility
+ if (this.f == null) {
+ this.f = ConsumerField.valueOf(field);
+ }
}
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ProducerFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ProducerFilterPredicate.java
index cfb3b7f..ea5ab17 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ProducerFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/ProducerFilterPredicate.java
@@ -16,16 +16,13 @@
*/
package org.apache.activemq.artemis.core.management.impl.view.predicate;
+import org.apache.activemq.artemis.core.management.impl.view.ProducerField;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerProducer;
public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProducer> {
- enum Field {
- ID, SESSION_ID, CONNECTION_ID, ADDRESS, USER, PROTOCOL, CLIENT_ID, LOCAL_ADDRESS, REMOTE_ADDRESS
- }
-
- private Field f;
+ private ProducerField f;
private final ActiveMQServer server;
@@ -44,7 +41,7 @@ public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProdu
return matches(producer.getID());
case CONNECTION_ID:
return matches(producer.getConnectionID());
- case SESSION_ID:
+ case SESSION:
return matches(producer.getSessionID());
case USER:
return matches(server.getSessionByID(producer.getSessionID()).getUsername());
@@ -65,7 +62,12 @@ public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProdu
@Override
public void setField(String field) {
if (field != null && !field.equals("")) {
- this.f = Field.valueOf(field.toUpperCase());
+ this.f = ProducerField.valueOfName(field);
+
+ //for backward compatibility
+ if (this.f == null) {
+ this.f = ProducerField.valueOf(field);
+ }
}
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/QueueFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/QueueFilterPredicate.java
index 55379ea..5acb2ba 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/QueueFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/QueueFilterPredicate.java
@@ -18,19 +18,14 @@ package org.apache.activemq.artemis.core.management.impl.view.predicate;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.QueueControl;
+import org.apache.activemq.artemis.core.management.impl.view.QueueField;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.Queue;
public class QueueFilterPredicate extends ActiveMQFilterPredicate<QueueControl> {
- enum Field {
- ID, NAME, CONSUMER_ID, QUEUE, ADDRESS, MAX_CONSUMERS, FILTER, MESSAGE_COUNT, CONSUMER_COUNT, DELIVERING_COUNT,
- MESSAGES_ADDED, MESSAGES_ACKED, RATE, ROUTING_TYPE, USER, AUTO_CREATED, DURABLE, PAUSED, TEMPORARY,
- PURGE_ON_NO_CONSUMERS, MESSAGES_KILLED, DIRECT_DELIVER, LAST_VALUE, EXCLUSIVE, SCHEDULED_COUNT
- }
-
- private Field f;
+ private QueueField f;
private ActiveMQServer server;
@@ -109,7 +104,12 @@ public class QueueFilterPredicate extends ActiveMQFilterPredicate<QueueControl>
@Override
public void setField(String field) {
if (field != null && !field.equals("")) {
- this.f = Field.valueOf(field.toUpperCase());
+ this.f = QueueField.valueOfName(field);
+
+ //for backward compatibility
+ if (this.f == null) {
+ this.f = QueueField.valueOf(field);
+ }
}
}
}
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/SessionFilterPredicate.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/SessionFilterPredicate.java
index 33c81dd..d1c1fe8 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/SessionFilterPredicate.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/view/predicate/SessionFilterPredicate.java
@@ -16,15 +16,12 @@
*/
package org.apache.activemq.artemis.core.management.impl.view.predicate;
+import org.apache.activemq.artemis.core.management.impl.view.SessionField;
import org.apache.activemq.artemis.core.server.ServerSession;
public class SessionFilterPredicate extends ActiveMQFilterPredicate<ServerSession> {
- enum Field {
- ID, CONNECTION_ID, CONSUMER_COUNT, PRODUCER_COUNT, USER, PROTOCOL, CLIENT_ID, LOCAL_ADDRESS, REMOTE_ADDRESS
- }
-
- private Field f;
+ private SessionField f;
public SessionFilterPredicate() {
super();
@@ -59,7 +56,12 @@ public class SessionFilterPredicate extends ActiveMQFilterPredicate<ServerSessio
@Override
public void setField(String field) {
if (field != null && !field.equals("")) {
- this.f = Field.valueOf(field.toUpperCase());
+ this.f = SessionField.valueOfName(field);
+
+ //for backward compatibility
+ if (this.f == null) {
+ this.f = SessionField.valueOf(field);
+ }
}
}
}