This commit is contained in:
Justin Bertram 2021-04-01 12:23:00 -05:00
commit 7e6c9ebdf9
25 changed files with 646 additions and 241 deletions

View File

@ -28,6 +28,8 @@ import javax.json.JsonArray;
import javax.json.JsonObject; import javax.json.JsonObject;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; 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 is contained in the queue name OR using a full filter '--field NAME --operation EQUALS --value X'." @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 is contained in the queue name OR using a full filter '--field NAME --operation EQUALS --value X'."
@ -35,9 +37,16 @@ import java.util.HashMap;
public class StatQueue extends AbstractAction { public class StatQueue extends AbstractAction {
public enum FIELD { 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"); 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; private String jsonId;
FIELD(String jsonId) { FIELD(String jsonId) {
@ -48,6 +57,9 @@ public class StatQueue extends AbstractAction {
return this.jsonId; return this.jsonId;
} }
public static FIELD valueOfJsonId(String jsonId) {
return lookup.get(jsonId);
}
} }
public enum OPERATION { public enum OPERATION {
@ -224,7 +236,13 @@ public class StatQueue extends AbstractAction {
if ((fieldName != null) && (fieldName.trim().length() > 0)) { if ((fieldName != null) && (fieldName.trim().length() > 0)) {
try { 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()); filterMap.put("field", field.toString());
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
context.err.println("'--field' must be set to one of the following " + Arrays.toString(FIELD.values())); context.err.println("'--field' must be set to one of the following " + Arrays.toString(FIELD.values()));

View File

@ -100,8 +100,8 @@ var Artemis;
fieldOptions: [ fieldOptions: [
{id: 'id', name: 'ID'}, {id: 'id', name: 'ID'},
{id: 'name', name: 'Name'}, {id: 'name', name: 'Name'},
{id: 'routing_Types', name: 'Routing Types'}, {id: 'routingTypes', name: 'Routing Types'},
{id: 'queue_Count', name: 'Queue Count'} {id: 'queueCount', name: 'Queue Count'}
], ],
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},

View File

@ -118,14 +118,14 @@ var Artemis;
ctrl.filter = { ctrl.filter = {
fieldOptions: [ fieldOptions: [
{id: 'connection_id', name: 'ID'}, {id: 'connectionID', name: 'ID'},
{id: 'client_id', name: 'Client ID'}, {id: 'clientID', name: 'Client ID'},
{id: 'users', name: 'Users'}, {id: 'users', name: 'Users'},
{id: 'protocol', name: 'Protocol'}, {id: 'protocol', name: 'Protocol'},
{id: 'session_count', name: 'Session Count'}, {id: 'sessionCount', name: 'Session Count'},
{id: 'remote_address', name: 'Remote Address'}, {id: 'remoteAddress', name: 'Remote Address'},
{id: 'local_address', name: 'Local Address'}, {id: 'localAddress', name: 'Local Address'},
{id: 'session_id', name: 'Session ID'} {id: 'sessionID', name: 'Session ID'}
], ],
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},

View File

@ -117,15 +117,15 @@ var Artemis;
} }
ctrl.filter = { ctrl.filter = {
fieldOptions: [ fieldOptions: [
{id: 'ID', name: 'ID'}, {id: 'id', name: 'ID'},
{id: 'SESSION_ID', name: 'Session ID'}, {id: 'session', name: 'Session'},
{id: 'CLIENT_ID', name: 'Client ID'}, {id: 'clientID', name: 'Client ID'},
{id: 'USER', name: 'User'}, {id: 'user', name: 'User'},
{id: 'ADDRESS', name: 'Address'}, {id: 'address', name: 'Address'},
{id: 'QUEUE', name: 'Queue'}, {id: 'queue', name: 'Queue'},
{id: 'PROTOCOL', name: 'Protocol'}, {id: 'protocol', name: 'Protocol'},
{id: 'LOCAL_ADDRESS', name: 'Local Address'}, {id: 'localAddress', name: 'Local Address'},
{id: 'REMOTE_ADDRESS', name: 'Remote Address'} {id: 'remoteAddress', name: 'Remote Address'}
], ],
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
@ -197,10 +197,10 @@ var Artemis;
}; };
if (artemisConsumer.consumer) { 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.field = ctrl.filter.fieldOptions[1].id;
ctrl.filter.values.operation = ctrl.filter.operationOptions[0].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; artemisConsumer.consumer = null;
} }

View File

@ -98,14 +98,14 @@ var Artemis;
} }
ctrl.filter = { ctrl.filter = {
fieldOptions: [ fieldOptions: [
{id: 'ID', name: 'ID'}, {id: 'id', name: 'ID'},
{id: 'SESSION_ID', name: 'Session ID'}, {id: 'session', name: 'Session'},
{id: 'CLIENT_ID', name: 'Client ID'}, {id: 'clientID', name: 'Client ID'},
{id: 'USER', name: 'User'}, {id: 'user', name: 'User'},
{id: 'ADDRESS', name: 'Address'}, {id: 'address', name: 'Address'},
{id: 'PROTOCOL', name: 'Protocol'}, {id: 'protocol', name: 'Protocol'},
{id: 'LOCAL_ADDRESS', name: 'Local Address'}, {id: 'localAddress', name: 'Local Address'},
{id: 'REMOTE_ADDRESS', name: 'Remote Address'} {id: 'remoteAddress', name: 'Remote Address'}
], ],
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},
@ -178,10 +178,10 @@ var Artemis;
}; };
if (artemisProducer.producer) { 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.field = ctrl.filter.fieldOptions[1].id;
ctrl.filter.values.operation = ctrl.filter.operationOptions[0].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; artemisProducer.producer = null;
} }

View File

@ -127,18 +127,18 @@ var Artemis;
fieldOptions: [ fieldOptions: [
{id: 'id', name: 'ID'}, {id: 'id', name: 'ID'},
{id: 'name', name: 'Name'}, {id: 'name', name: 'Name'},
{id: 'consumer_Id', name: 'Consumer ID'}, {id: 'consumerId', name: 'Consumer ID'},
{id: 'address', name: 'Address'}, {id: 'address', name: 'Address'},
{id: 'filter', name: 'Filter'}, {id: 'filter', name: 'Filter'},
{id: 'max_Consumers', name: 'Max Consumers'}, {id: 'maxConsumers', name: 'Max Consumers'},
{id: 'routing_Type', name: 'Routing Type'}, {id: 'routingType', name: 'Routing Type'},
{id: 'purge_On_No_Consumers', name: 'Purge On No Consumers'}, {id: 'purgeOnNoConsumers', name: 'Purge On No Consumers'},
{id: 'user', name: 'User'}, {id: 'user', name: 'User'},
{id: 'message_Count', name: 'Message Count'}, {id: 'messageCount', name: 'Message Count'},
{id: 'delivering_Count', name: 'Delivering Count'}, {id: 'deliveringCount', name: 'Delivering Count'},
{id: 'paused', name: 'Paused'}, {id: 'paused', name: 'Paused'},
{id: 'temporary', name: 'Temporary'}, {id: 'temporary', name: 'Temporary'},
{id: 'auto_Created', name: 'Auto Created'}, {id: 'autoCreated', name: 'Auto Created'},
{id: 'rate', name: 'Rate'} {id: 'rate', name: 'Rate'}
], ],
operationOptions: [ operationOptions: [

View File

@ -114,13 +114,13 @@ var Artemis;
ctrl.filter = { ctrl.filter = {
fieldOptions: [ fieldOptions: [
{id: 'id', name: 'ID'}, {id: 'id', name: 'ID'},
{id: 'connection_id', name: 'Connection ID'}, {id: 'connectionID', name: 'Connection ID'},
{id: 'consumer_count', name: 'Consumer Count'}, {id: 'consumerCount', name: 'Consumer Count'},
{id: 'user', name: 'User'}, {id: 'user', name: 'User'},
{id: 'protocol', name: 'Protocol'}, {id: 'protocol', name: 'Protocol'},
{id: 'client_id', name: 'Client ID'}, {id: 'clientID', name: 'Client ID'},
{id: 'local_address', name: 'Local Address'}, {id: 'localAddress', name: 'Local Address'},
{id: 'remote_address', name: 'Remote Address'} {id: 'remoteAddress', name: 'Remote Address'}
], ],
operationOptions: [ operationOptions: [
{id: 'EQUALS', name: 'Equals'}, {id: 'EQUALS', name: 'Equals'},

View File

@ -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);
}
}

View File

@ -24,7 +24,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class AddressView extends ActiveMQAbstractView<AddressInfo> { public class AddressView extends ActiveMQAbstractView<AddressInfo> {
private static final String defaultSortColumn = "id"; private static final String defaultSortColumn = AddressField.ID.getName();
private final ActiveMQServer server; private final ActiveMQServer server;
@ -45,13 +45,16 @@ public class AddressView extends ActiveMQAbstractView<AddressInfo> {
return null; 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 { 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; return obj;
} catch (Exception e) { } catch (Exception e) {
obj.add("queueCount", 0); obj.add(AddressField.QUEUE_COUNT.getName(), 0);
} }
return obj; return obj;
} }
@ -62,14 +65,16 @@ public class AddressView extends ActiveMQAbstractView<AddressInfo> {
return null; return null;
} }
switch (fieldName) { AddressField field = AddressField.valueOfName(fieldName);
case "id":
switch (field) {
case ID:
return address.getId(); return address.getId();
case "name": case NAME:
return address.getName(); return address.getName();
case "routingTypes": case ROUTING_TYPES:
return address.getRoutingTypes(); return address.getRoutingTypes();
case "queueCount": case QUEUE_COUNT:
try { try {
return server.bindingQuery(address.getName()).getQueueNames().size(); return server.bindingQuery(address.getName()).getQueueNames().size();
} catch (Exception e) { } catch (Exception e) {

View File

@ -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);
}
}

View File

@ -32,7 +32,7 @@ import org.apache.activemq.artemis.utils.StringUtil;
public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> { 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; private final ActiveMQServer server;
@ -62,25 +62,28 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
} }
} }
return JsonLoader.createObjectBuilder().add("connectionID", toString(connection.getID())) return JsonLoader.createObjectBuilder()
.add("remoteAddress", toString(connection.getRemoteAddress())) .add(ConnectionField.CONNECTION_ID.getName(), toString(connection.getID()))
.add("users", StringUtil.joinStringList(users, ",")) .add(ConnectionField.REMOTE_ADDRESS.getName(), toString(connection.getRemoteAddress()))
.add("creationTime", new Date(connection.getCreationTime()).toString()) .add(ConnectionField.USERS.getName(), StringUtil.joinStringList(users, ","))
.add("implementation", toString(connection.getClass().getSimpleName())) .add(ConnectionField.CREATION_TIME.getName(), new Date(connection.getCreationTime()).toString())
.add("protocol", toString(connection.getProtocolName())) .add(ConnectionField.IMPLEMENTATION.getName(), toString(connection.getClass().getSimpleName()))
.add("clientID", toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID)) .add(ConnectionField.PROTOCOL.getName(), toString(connection.getProtocolName()))
.add("localAddress", toString(connection.getTransportLocalAddress())) .add(ConnectionField.CLIENT_ID.getName(), toString(connection.getClientID() != null ? connection.getClientID() : jmsSessionClientID))
.add("sessionCount", sessions.size()); .add(ConnectionField.LOCAL_ADDRESS.getName(), toString(connection.getTransportLocalAddress()))
.add(ConnectionField.SESSION_COUNT.getName(), sessions.size());
} }
@Override @Override
public Object getField(RemotingConnection connection, String fieldName) { public Object getField(RemotingConnection connection, String fieldName) {
switch (fieldName) { ConnectionField field = ConnectionField.valueOfName(fieldName);
case "connectionID":
switch (field) {
case CONNECTION_ID:
return connection.getID(); return connection.getID();
case "remoteAddress": case REMOTE_ADDRESS:
return connection.getRemoteAddress(); return connection.getRemoteAddress();
case "users": case USERS:
Set<String> users = new TreeSet<>(); Set<String> users = new TreeSet<>();
List<ServerSession> sessions = server.getSessions(connection.getID().toString()); List<ServerSession> sessions = server.getSessions(connection.getID().toString());
for (ServerSession session : sessions) { for (ServerSession session : sessions) {
@ -88,17 +91,17 @@ public class ConnectionView extends ActiveMQAbstractView<RemotingConnection> {
users.add(username); users.add(username);
} }
return StringUtil.joinStringList(users, ","); return StringUtil.joinStringList(users, ",");
case "creationTime": case CREATION_TIME:
return new Date(connection.getCreationTime()); return new Date(connection.getCreationTime());
case "implementation": case IMPLEMENTATION:
return connection.getClass().getSimpleName(); return connection.getClass().getSimpleName();
case "protocol": case PROTOCOL:
return connection.getProtocolName(); return connection.getProtocolName();
case "clientID": case CLIENT_ID:
return connection.getClientID(); return connection.getClientID();
case "localAddress": case LOCAL_ADDRESS:
return connection.getTransportLocalAddress(); return connection.getTransportLocalAddress();
case "sessionCount": case SESSION_COUNT:
return server.getSessions(connection.getID().toString()).size(); return server.getSessions(connection.getID().toString()).size();
default: default:
throw new IllegalArgumentException("Unsupported field, " + fieldName); throw new IllegalArgumentException("Unsupported field, " + fieldName);

View File

@ -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);
}
}

View File

@ -28,7 +28,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> { public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
private static final String defaultSortColumn = "id"; private static final String defaultSortColumn = ConsumerField.ID.getName();
private final ActiveMQServer server; private final ActiveMQServer server;
@ -52,24 +52,25 @@ public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
return null; return null;
} }
String jmsSessionClientID = null; String consumerClientID = consumer.getConnectionClientID();
//for the special case for JMS if (consumerClientID == null && session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
if (session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) { //for the special case for JMS
jmsSessionClientID = session.getMetaData("jms-client-id"); consumerClientID = session.getMetaData("jms-client-id");
} }
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(consumer.getSequentialID())) JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("session", toString(consumer.getSessionName())) .add(ConsumerField.ID.getName(), toString(consumer.getSequentialID()))
.add("clientID", toString(consumer.getConnectionClientID() != null ? consumer.getConnectionClientID() : jmsSessionClientID)) .add(ConsumerField.SESSION.getName(), toString(consumer.getSessionName()))
.add("user", toString(session.getUsername())) .add(ConsumerField.CLIENT_ID.getName(), toString(consumerClientID))
.add("protocol", toString(consumer.getConnectionProtocolName())) .add(ConsumerField.USER.getName(), toString(session.getUsername()))
.add("queue", toString(consumer.getQueueName())) .add(ConsumerField.PROTOCOL.getName(), toString(consumer.getConnectionProtocolName()))
.add("queueType", toString(consumer.getQueueType()).toLowerCase()) .add(ConsumerField.QUEUE.getName(), toString(consumer.getQueueName()))
.add("filter", toString(consumer.getFilterString())) .add(ConsumerField.QUEUE_TYPE.getName(), toString(consumer.getQueueType()).toLowerCase())
.add("address", toString(consumer.getQueueAddress())) .add(ConsumerField.FILTER.getName(), toString(consumer.getFilterString()))
.add("localAddress", toString(consumer.getConnectionLocalAddress())) .add(ConsumerField.ADDRESS.getName(), toString(consumer.getQueueAddress()))
.add("remoteAddress", toString(consumer.getConnectionRemoteAddress())) .add(ConsumerField.LOCAL_ADDRESS.getName(), toString(consumer.getConnectionLocalAddress()))
.add("creationTime", new Date(consumer.getCreationTime()).toString()); .add(ConsumerField.REMOTE_ADDRESS.getName(), toString(consumer.getConnectionRemoteAddress()))
.add(ConsumerField.CREATION_TIME.getName(), new Date(consumer.getCreationTime()).toString());
return obj; return obj;
} }
@ -82,28 +83,30 @@ public class ConsumerView extends ActiveMQAbstractView<ServerConsumer> {
return null; return null;
} }
switch (fieldName) { ConsumerField field = ConsumerField.valueOfName(fieldName);
case "id":
switch (field) {
case ID:
return consumer.getSequentialID(); return consumer.getSequentialID();
case "session": case SESSION:
return consumer.getSessionName(); return consumer.getSessionName();
case "user": case USER:
return session.getUsername(); return session.getUsername();
case "clientID": case CLIENT_ID:
return consumer.getConnectionClientID(); return consumer.getConnectionClientID();
case "protocol": case PROTOCOL:
return consumer.getConnectionProtocolName(); return consumer.getConnectionProtocolName();
case "queue": case QUEUE:
return consumer.getQueueName(); return consumer.getQueueName();
case "queueType": case QUEUE_TYPE:
return consumer.getQueueType(); return consumer.getQueueType();
case "filter": case FILTER:
return consumer.getFilterString(); return consumer.getFilterString();
case "localAddress": case LOCAL_ADDRESS:
return consumer.getConnectionLocalAddress(); return consumer.getConnectionLocalAddress();
case "remoteAddress": case REMOTE_ADDRESS:
return consumer.getConnectionRemoteAddress(); return consumer.getConnectionRemoteAddress();
case "creationTime": case CREATION_TIME:
return new Date(consumer.getCreationTime()); return new Date(consumer.getCreationTime());
default: default:
throw new IllegalArgumentException("Unsupported field, " + fieldName); throw new IllegalArgumentException("Unsupported field, " + fieldName);

View File

@ -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);
}
}

View File

@ -27,7 +27,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class ProducerView extends ActiveMQAbstractView<ServerProducer> { 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; private final ActiveMQServer server;
@ -51,21 +51,22 @@ public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
return null; return null;
} }
String jmsSessionClientID = null; String sessionClientID = session.getRemotingConnection().getClientID();
//for the special case for JMS //for the special case for JMS
if (session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) { if (sessionClientID == null && session.getMetaData(ClientSession.JMS_SESSION_IDENTIFIER_PROPERTY) != null) {
jmsSessionClientID = session.getMetaData("jms-client-id"); sessionClientID = session.getMetaData("jms-client-id");
} }
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(producer.getID())) JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("session", toString(session.getName())) .add(ProducerField.ID.getName(), toString(producer.getID()))
.add("clientID", toString(session.getRemotingConnection().getClientID() != null ? session.getRemotingConnection().getClientID() : jmsSessionClientID)) .add(ProducerField.SESSION.getName(), toString(session.getName()))
.add("user", toString(session.getUsername())) .add(ProducerField.CLIENT_ID.getName(), toString(sessionClientID))
.add("protocol", toString(session.getRemotingConnection().getProtocolName())) .add(ProducerField.USER.getName(), toString(session.getUsername()))
.add("address", toString(producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress())) .add(ProducerField.PROTOCOL.getName(), toString(session.getRemotingConnection().getProtocolName()))
.add("localAddress", toString(session.getRemotingConnection().getTransportConnection().getLocalAddress())) .add(ProducerField.ADDRESS.getName(), toString(producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress()))
.add("remoteAddress", toString(session.getRemotingConnection().getTransportConnection().getRemoteAddress())) .add(ProducerField.LOCAL_ADDRESS.getName(), toString(session.getRemotingConnection().getTransportConnection().getLocalAddress()))
.add("creationTime", toString(producer.getCreationTime())); .add(ProducerField.REMOTE_ADDRESS.getName(), toString(session.getRemotingConnection().getTransportConnection().getRemoteAddress()))
.add(ProducerField.CREATION_TIME.getName(), toString(producer.getCreationTime()));
return obj; return obj;
} }
@ -78,24 +79,26 @@ public class ProducerView extends ActiveMQAbstractView<ServerProducer> {
return null; return null;
} }
switch (fieldName) { ProducerField field = ProducerField.valueOfName(fieldName);
case "id":
switch (field) {
case ID:
return producer.getID(); return producer.getID();
case "session": case SESSION:
return session.getName(); return session.getName();
case "user": case USER:
return session.getUsername(); return session.getUsername();
case "clientID": case CLIENT_ID:
return session.getRemotingConnection().getClientID(); return session.getRemotingConnection().getClientID();
case "protocol": case PROTOCOL:
return session.getRemotingConnection().getProtocolName(); return session.getRemotingConnection().getProtocolName();
case "address": case ADDRESS:
return producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress(); return producer.getAddress() != null ? producer.getAddress() : session.getDefaultAddress();
case "localAddress": case LOCAL_ADDRESS:
return session.getRemotingConnection().getTransportConnection().getLocalAddress(); return session.getRemotingConnection().getTransportConnection().getLocalAddress();
case "remoteAddress": case REMOTE_ADDRESS:
return session.getRemotingConnection().getTransportConnection().getRemoteAddress(); return session.getRemotingConnection().getTransportConnection().getRemoteAddress();
case "creationTime": case CREATION_TIME:
return producer.getCreationTime(); return producer.getCreationTime();
default: default:
throw new IllegalArgumentException("Unsupported field, " + fieldName); throw new IllegalArgumentException("Unsupported field, " + fieldName);

View File

@ -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);
}
}

View File

@ -26,7 +26,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class QueueView extends ActiveMQAbstractView<QueueControl> { public class QueueView extends ActiveMQAbstractView<QueueControl> {
private static final String defaultSortColumn = "name"; private static final String defaultSortColumn = QueueField.NAME.getName();
private ActiveMQServer server; private ActiveMQServer server;
@ -44,105 +44,112 @@ public class QueueView extends ActiveMQAbstractView<QueueControl> {
@Override @Override
public JsonObjectBuilder toJson(QueueControl queue) { public JsonObjectBuilder toJson(QueueControl queue) {
Queue q = server.locateQueue(new SimpleString(queue.getName())); Queue q = server.locateQueue(new SimpleString(queue.getName()));
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(queue.getID())) JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("name", toString(queue.getName())).add("address", toString(queue.getAddress())) .add(QueueField.ID.getName(), toString(queue.getID()))
.add("filter", toString(queue.getFilter())).add("rate", toString(q.getRate())) .add(QueueField.NAME.getName(), toString(queue.getName()))
.add("durable", toString(queue.isDurable())).add("paused", toString(q.isPaused())) .add(QueueField.ADDRESS.getName(), toString(queue.getAddress()))
.add("temporary", toString(queue.isTemporary())) .add(QueueField.FILTER.getName(), toString(queue.getFilter()))
.add("purgeOnNoConsumers", toString(queue.isPurgeOnNoConsumers())) .add(QueueField.RATE.getName(), toString(q.getRate()))
.add("consumerCount", toString(queue.getConsumerCount())) .add(QueueField.DURABLE.getName(), toString(queue.isDurable()))
.add("maxConsumers", toString(queue.getMaxConsumers())) .add(QueueField.PAUSED.getName(), toString(q.isPaused()))
.add("autoCreated", toString(q.isAutoCreated())) .add(QueueField.TEMPORARY.getName(), toString(queue.isTemporary()))
.add("user", toString(q.getUser())) .add(QueueField.PURGE_ON_NO_CONSUMERS.getName(), toString(queue.isPurgeOnNoConsumers()))
.add("routingType", toString(queue.getRoutingType())) .add(QueueField.CONSUMER_COUNT.getName(), toString(queue.getConsumerCount()))
.add("messagesAdded", toString(queue.getMessagesAdded())) .add(QueueField.MAX_CONSUMERS.getName(), toString(queue.getMaxConsumers()))
.add("messageCount", toString(queue.getMessageCount())) .add(QueueField.AUTO_CREATED.getName(), toString(q.isAutoCreated()))
.add("messagesAcked", toString(queue.getMessagesAcknowledged())) .add(QueueField.USER.getName(), toString(q.getUser()))
.add("deliveringCount", toString(queue.getDeliveringCount())) .add(QueueField.ROUTING_TYPE.getName(), toString(queue.getRoutingType()))
.add("messagesKilled", toString(queue.getMessagesKilled())) .add(QueueField.MESSAGES_ADDED.getName(), toString(queue.getMessagesAdded()))
.add("directDeliver", toString(q.isDirectDeliver())) .add(QueueField.MESSAGE_COUNT.getName(), toString(queue.getMessageCount()))
.add("exclusive", toString(queue.isExclusive())) .add(QueueField.MESSAGES_ACKED.getName(), toString(queue.getMessagesAcknowledged()))
.add("lastValue", toString(queue.isLastValue())) .add(QueueField.DELIVERING_COUNT.getName(), toString(queue.getDeliveringCount()))
.add("lastValueKey", toString(queue.getLastValueKey())) .add(QueueField.MESSAGES_KILLED.getName(), toString(queue.getMessagesKilled()))
.add("scheduledCount", toString(queue.getScheduledCount())) .add(QueueField.DIRECT_DELIVER.getName(), toString(q.isDirectDeliver()))
.add("groupRebalance", toString(queue.isGroupRebalance())) .add(QueueField.EXCLUSIVE.getName(), toString(queue.isExclusive()))
.add("groupRebalancePauseDispatch", toString(queue.isGroupRebalancePauseDispatch())) .add(QueueField.LAST_VALUE.getName(), toString(queue.isLastValue()))
.add("groupBuckets", toString(queue.getGroupBuckets())) .add(QueueField.LAST_VALUE_KEY.getName(), toString(queue.getLastValueKey()))
.add("groupFirstKey", toString(queue.getGroupFirstKey())) .add(QueueField.SCHEDULED_COUNT.getName(), toString(queue.getScheduledCount()))
.add("enabled", toString(queue.isEnabled())) .add(QueueField.GROUP_REBALANCE.getName(), toString(queue.isGroupRebalance()))
.add("ringSize", toString(queue.getRingSize())) .add(QueueField.GROUP_REBALANCE_PAUSE_DISPATCH.getName(), toString(queue.isGroupRebalancePauseDispatch()))
.add("consumersBeforeDispatch", toString(queue.getConsumersBeforeDispatch())) .add(QueueField.GROUP_BUCKETS.getName(), toString(queue.getGroupBuckets()))
.add("delayBeforeDispatch", toString(queue.getDelayBeforeDispatch())); .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; return obj;
} }
@Override @Override
public Object getField(QueueControl queue, String fieldName) { public Object getField(QueueControl queue, String fieldName) {
Queue q = server.locateQueue(new SimpleString(queue.getName())); Queue q = server.locateQueue(new SimpleString(queue.getName()));
switch (fieldName) {
case "id": QueueField field = QueueField.valueOfName(fieldName);
switch (field) {
case ID:
return queue.getID(); return queue.getID();
case "name": case NAME:
return queue.getName(); return queue.getName();
case "address": case ADDRESS:
return queue.getAddress(); return queue.getAddress();
case "filter": case FILTER:
return queue.getFilter(); return queue.getFilter();
case "rate": case RATE:
return q.getRate(); return q.getRate();
case "durable": case DURABLE:
return queue.isDurable(); return queue.isDurable();
case "paused": case PAUSED:
return q.isPaused(); return q.isPaused();
case "temporary": case TEMPORARY:
return queue.isTemporary(); return queue.isTemporary();
case "purgeOnNoConsumers": case PURGE_ON_NO_CONSUMERS:
return queue.isPurgeOnNoConsumers(); return queue.isPurgeOnNoConsumers();
case "consumerCount": case CONSUMER_COUNT:
return queue.getConsumerCount(); return queue.getConsumerCount();
case "maxConsumers": case MAX_CONSUMERS:
return queue.getMaxConsumers(); return queue.getMaxConsumers();
case "autoCreated": case AUTO_CREATED:
return q.isAutoCreated(); return q.isAutoCreated();
case "user": case USER:
return q.getUser(); return q.getUser();
case "routingType": case ROUTING_TYPE:
return queue.getRoutingType(); return queue.getRoutingType();
case "messagesAdded": case MESSAGES_ADDED:
return queue.getMessagesAdded(); return queue.getMessagesAdded();
case "messageCount": case MESSAGE_COUNT:
return queue.getMessageCount(); return queue.getMessageCount();
case "messagesAcked": case MESSAGES_ACKED:
return queue.getMessagesAcknowledged(); return queue.getMessagesAcknowledged();
case "deliveringCount": case DELIVERING_COUNT:
return queue.getDeliveringCount(); return queue.getDeliveringCount();
case "messagesKilled": case MESSAGES_KILLED:
return queue.getMessagesKilled(); return queue.getMessagesKilled();
case "deliverDeliver": case DIRECT_DELIVER:
return q.isDirectDeliver(); return q.isDirectDeliver();
case "exclusive": case EXCLUSIVE:
return q.isExclusive(); return q.isExclusive();
case "lastValue": case LAST_VALUE:
return q.isLastValue(); return q.isLastValue();
case "lastValueKey": case LAST_VALUE_KEY:
return q.getLastValueKey(); return q.getLastValueKey();
case "scheduledCount": case SCHEDULED_COUNT:
return q.getScheduledCount(); return q.getScheduledCount();
case "groupRebalance": case GROUP_REBALANCE:
return queue.isGroupRebalance(); return queue.isGroupRebalance();
case "groupRebalancePauseDispatch": case GROUP_REBALANCE_PAUSE_DISPATCH:
return queue.isGroupRebalancePauseDispatch(); return queue.isGroupRebalancePauseDispatch();
case "groupBuckets": case GROUP_BUCKETS:
return queue.getGroupBuckets(); return queue.getGroupBuckets();
case "groupFirstKey": case GROUP_FIRST_KEY:
return queue.getGroupFirstKey(); return queue.getGroupFirstKey();
case "enabled": case ENABLED:
return q.isEnabled(); return q.isEnabled();
case "ringSize": case RING_SIZE:
return q.getRingSize(); return q.getRingSize();
case "consumersBeforeDispatch": case CONSUMERS_BEFORE_DISPATCH:
return q.getConsumersBeforeDispatch(); return q.getConsumersBeforeDispatch();
case "delayBeforeDispatch": case DELAY_BEFORE_DISPATCH:
return q.getDelayBeforeDispatch(); return q.getDelayBeforeDispatch();
default: default:
throw new IllegalArgumentException("Unsupported field, " + fieldName); throw new IllegalArgumentException("Unsupported field, " + fieldName);

View File

@ -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);
}
}

View File

@ -25,7 +25,7 @@ import org.apache.activemq.artemis.utils.JsonLoader;
public class SessionView extends ActiveMQAbstractView<ServerSession> { public class SessionView extends ActiveMQAbstractView<ServerSession> {
private static final String defaultSortColumn = "id"; private static final String defaultSortColumn = SessionField.ID.getName();
public SessionView() { public SessionView() {
super(); super();
@ -39,29 +39,32 @@ public class SessionView extends ActiveMQAbstractView<ServerSession> {
@Override @Override
public JsonObjectBuilder toJson(ServerSession session) { public JsonObjectBuilder toJson(ServerSession session) {
JsonObjectBuilder obj = JsonLoader.createObjectBuilder().add("id", toString(session.getName())) JsonObjectBuilder obj = JsonLoader.createObjectBuilder()
.add("user", toString(session.getUsername())) .add(SessionField.ID.getName(), toString(session.getName()))
.add("creationTime", new Date(session.getCreationTime()).toString()) .add(SessionField.USER.getName(), toString(session.getUsername()))
.add("consumerCount", session.getConsumerCount()) .add(SessionField.CREATION_TIME.getName(), new Date(session.getCreationTime()).toString())
.add("producerCount", session.getProducerCount()) .add(SessionField.CONSUMER_COUNT.getName(), session.getConsumerCount())
.add("connectionID", session.getConnectionID().toString()); .add(SessionField.PRODUCER_COUNT.getName(), session.getProducerCount())
.add(SessionField.CONNECTION_ID.getName(), session.getConnectionID().toString());
return obj; return obj;
} }
@Override @Override
public Object getField(ServerSession session, String fieldName) { public Object getField(ServerSession session, String fieldName) {
switch (fieldName) { SessionField field = SessionField.valueOfName(fieldName);
case "id":
switch (field) {
case ID:
return session.getName(); return session.getName();
case "user": case USER:
return session.getUsername(); return session.getUsername();
case "creationTime": case CREATION_TIME:
return new Date(session.getCreationTime()); return new Date(session.getCreationTime());
case "consumerCount": case CONSUMER_COUNT:
return session.getConsumerCount(); return session.getConsumerCount();
case "producerCount": case PRODUCER_COUNT:
return session.getProducerCount(); return session.getProducerCount();
case "connectionID": case CONNECTION_ID:
return session.getConnectionID(); return session.getConnectionID();
default: default:
throw new IllegalArgumentException("Unsupported field, " + fieldName); throw new IllegalArgumentException("Unsupported field, " + fieldName);

View File

@ -16,16 +16,13 @@
*/ */
package org.apache.activemq.artemis.core.management.impl.view.predicate; 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.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.AddressInfo;
public class AddressFilterPredicate extends ActiveMQFilterPredicate<AddressInfo> { public class AddressFilterPredicate extends ActiveMQFilterPredicate<AddressInfo> {
enum Field { private AddressField f;
ID, NAME, ROUTING_TYPES, PRODUCER_ID, QUEUE_COUNT
}
private Field f;
private final ActiveMQServer server; private final ActiveMQServer server;
@ -61,7 +58,12 @@ public class AddressFilterPredicate extends ActiveMQFilterPredicate<AddressInfo>
@Override @Override
public void setField(String field) { public void setField(String field) {
if (field != null && !field.equals("")) { 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);
}
} }
} }
} }

View File

@ -20,17 +20,14 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; 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.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerSession; import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingConnection> { public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingConnection> {
enum Field { private ConnectionField f;
CONNECTION_ID, CLIENT_ID, USERS, PROTOCOL, SESSION_COUNT, REMOTE_ADDRESS, LOCAL_ADDRESS, SESSION_ID
}
private Field f;
private ActiveMQServer server; private ActiveMQServer server;
@ -66,6 +63,10 @@ public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingC
return matches(connection.getTransportConnection().getLocalAddress()); return matches(connection.getTransportConnection().getLocalAddress());
case SESSION_ID: case SESSION_ID:
return matchAny(server.getSessions(connection.getID().toString())); return matchAny(server.getSessions(connection.getID().toString()));
case CREATION_TIME:
return matches(connection.getCreationTime());
case IMPLEMENTATION:
return matches(connection.getClass().getSimpleName());
} }
return true; return true;
} }
@ -73,7 +74,12 @@ public class ConnectionFilterPredicate extends ActiveMQFilterPredicate<RemotingC
@Override @Override
public void setField(String field) { public void setField(String field) {
if (field != null && !field.equals("")) { 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);
}
} }
} }
} }

View File

@ -16,16 +16,13 @@
*/ */
package org.apache.activemq.artemis.core.management.impl.view.predicate; 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.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerConsumer; import org.apache.activemq.artemis.core.server.ServerConsumer;
public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsumer> { public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsumer> {
enum Field { private ConsumerField f;
ID, SESSION_ID, QUEUE, FILTER, ADDRESS, USER, PROTOCOL, CLIENT_ID, LOCAL_ADDRESS, REMOTE_ADDRESS
}
private Field f;
private final ActiveMQServer server; private final ActiveMQServer server;
@ -42,7 +39,7 @@ public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsu
switch (f) { switch (f) {
case ID: case ID:
return matches(consumer.getSequentialID()); return matches(consumer.getSequentialID());
case SESSION_ID: case SESSION:
return matches(consumer.getSessionID()); return matches(consumer.getSessionID());
case USER: case USER:
return matches(server.getSessionByID(consumer.getSessionID()).getUsername()); return matches(server.getSessionByID(consumer.getSessionID()).getUsername());
@ -67,7 +64,12 @@ public class ConsumerFilterPredicate extends ActiveMQFilterPredicate<ServerConsu
@Override @Override
public void setField(String field) { public void setField(String field) {
if (field != null && !field.equals("")) { 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);
}
} }
} }
} }

View File

@ -16,16 +16,13 @@
*/ */
package org.apache.activemq.artemis.core.management.impl.view.predicate; 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.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ServerProducer; import org.apache.activemq.artemis.core.server.ServerProducer;
public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProducer> { public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProducer> {
enum Field { private ProducerField f;
ID, SESSION_ID, CONNECTION_ID, ADDRESS, USER, PROTOCOL, CLIENT_ID, LOCAL_ADDRESS, REMOTE_ADDRESS
}
private Field f;
private final ActiveMQServer server; private final ActiveMQServer server;
@ -44,7 +41,7 @@ public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProdu
return matches(producer.getID()); return matches(producer.getID());
case CONNECTION_ID: case CONNECTION_ID:
return matches(producer.getConnectionID()); return matches(producer.getConnectionID());
case SESSION_ID: case SESSION:
return matches(producer.getSessionID()); return matches(producer.getSessionID());
case USER: case USER:
return matches(server.getSessionByID(producer.getSessionID()).getUsername()); return matches(server.getSessionByID(producer.getSessionID()).getUsername());
@ -65,7 +62,12 @@ public class ProducerFilterPredicate extends ActiveMQFilterPredicate<ServerProdu
@Override @Override
public void setField(String field) { public void setField(String field) {
if (field != null && !field.equals("")) { 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);
}
} }
} }
} }

View File

@ -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.SimpleString;
import org.apache.activemq.artemis.api.core.management.QueueControl; 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.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Consumer; import org.apache.activemq.artemis.core.server.Consumer;
import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.Queue;
public class QueueFilterPredicate extends ActiveMQFilterPredicate<QueueControl> { public class QueueFilterPredicate extends ActiveMQFilterPredicate<QueueControl> {
enum Field { private QueueField f;
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 ActiveMQServer server; private ActiveMQServer server;
@ -109,7 +104,12 @@ public class QueueFilterPredicate extends ActiveMQFilterPredicate<QueueControl>
@Override @Override
public void setField(String field) { public void setField(String field) {
if (field != null && !field.equals("")) { 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);
}
} }
} }
} }

View File

@ -16,15 +16,12 @@
*/ */
package org.apache.activemq.artemis.core.management.impl.view.predicate; 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; import org.apache.activemq.artemis.core.server.ServerSession;
public class SessionFilterPredicate extends ActiveMQFilterPredicate<ServerSession> { public class SessionFilterPredicate extends ActiveMQFilterPredicate<ServerSession> {
enum Field { private SessionField f;
ID, CONNECTION_ID, CONSUMER_COUNT, PRODUCER_COUNT, USER, PROTOCOL, CLIENT_ID, LOCAL_ADDRESS, REMOTE_ADDRESS
}
private Field f;
public SessionFilterPredicate() { public SessionFilterPredicate() {
super(); super();
@ -59,7 +56,12 @@ public class SessionFilterPredicate extends ActiveMQFilterPredicate<ServerSessio
@Override @Override
public void setField(String field) { public void setField(String field) {
if (field != null && !field.equals("")) { 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);
}
} }
} }
} }