This closes #3524
This commit is contained in:
commit
7e6c9ebdf9
|
@ -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 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 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()));
|
||||
|
|
|
@ -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'},
|
||||
|
|
|
@ -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'},
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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'},
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue