summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFraser Adams <fadams@apache.org>2014-03-08 12:02:00 +0000
committerFraser Adams <fadams@apache.org>2014-03-08 12:02:00 +0000
commitf1f43b9eecb7bfc60207408afaccb3b89c0480ba (patch)
treea2d093ce416bc4cd8f0e2003abf06203c168a082
parentdca02f49f5e3d30d6565862c001d347bf380b457 (diff)
downloadqpid-python-f1f43b9eecb7bfc60207408afaccb3b89c0480ba.tar.gz
QPID-5614: Initial fix of the issues. The QMF2 Plugin compiles again and mostly works, but there are issues with the bindings and subscriptions - though I think that this might be a problem with the Java Broker Management Model
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1575530 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/agent/Agent.java1
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java51
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java83
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Binding.java20
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Broker.java12
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Connection.java54
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Exchange.java14
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Queue.java62
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java10
-rw-r--r--qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Subscription.java10
10 files changed, 156 insertions, 161 deletions
diff --git a/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/agent/Agent.java b/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/agent/Agent.java
index ef94a306c3..f0a8f67cae 100644
--- a/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/agent/Agent.java
+++ b/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/agent/Agent.java
@@ -1154,6 +1154,7 @@ public class Agent extends QmfData implements MessageListener, SubscribableAgent
response.setStringProperty("qmf.content", "_event");
response.setStringProperty("qmf.agent", _name);
response.setStringProperty("qpid.subject", subject);
+
List<Map> results = new ArrayList<Map>();
results.add(event.mapEncode());
AMQPMessage.setList(response, results);
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java
index fb91d7a4a3..9b0aaafba3 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java
@@ -62,18 +62,18 @@ import org.apache.qpid.server.model.VirtualHost;
/**
* This class implements a QMF2 Agent providing access to the Java broker Management Objects via QMF2 thus
- * allowing the Java broker to be managed in the same way to the C++ broker.
+ * allowing the Java Broker to be managed in the same way to the C++ Broker.
* <p>
- * The intention is for the QmfManagementAgent to conform to the same Management Schema as the C++ broker
- * (e.g. as specified in <qpid>/specs/management-schema.xml) in order to provide maximum cohesion between
- * the to broker implementations, however that's not entirely possible given differences between the underlying
- * Management models.
+ * The intention is for the QmfManagementAgent to conform to the same Management Schema as the C++ Broker
+ * (e.g. as specified in management-schema.xml) in order to provide maximum cohesion between the
+ * two Broker implementations, however that's not entirely possible given differences between the underlying
+ * Management Models.
* <p>
* This Plugin attempts to map properties from the Java org.apache.qpid.server.model.* classes to equivalent
* properties and statistics in the C++ broker's Management Schema rather than expose them "natively", this is
- * in order to try and maximise alignment between the two implementations and to try to allow the Java broker
- * to be managed by the Command Line tools used with the C++ broker such as qpid-config etc. it's also to
- * enable the Java broker to be accessed via the QMF2 REST API and GUI.
+ * in order to try and maximise alignment between the two implementations and to try to allow the Java Broker
+ * to be managed by the Command Line tools used with the C++ Broker such as qpid-config etc. it's also to
+ * enable the Java Broker to be accessed via the QMF2 REST API and GUI.
*
* @author Fraser Adams
*/
@@ -87,11 +87,11 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
private Agent _agent = null;
// The first Connection Object relates to the QmfManagementAgent, we use this flag to avoid mapping that Connection
- // to a QMF Object thus hiding it from Consoles. This is done to provide consistency with the C++ broker which
+ // to a QMF Object thus hiding it from Consoles. This is done to provide consistency with the C++ Broker which
// also "hides" its own private AMQP Connections, Queues & Bindings.
private boolean agentConnection = true;
- private final Broker _broker; // Passed in by Plugin bootstrapping.
+ private final Broker<?> _broker; // Passed in by Plugin bootstrapping.
private final String _defaultVirtualHost; // Pulled from the broker attributes.
/**
@@ -115,10 +115,10 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
private Map<ConfiguredObject, QmfAgentData> _objects = new ConcurrentHashMap<ConfiguredObject, QmfAgentData>(100);
/**
- * Constructor. Creates the AMQP Connection to the broker and starts the QMF2 Agent.
+ * Constructor. Creates the AMQP Connection to the Broker and starts the QMF2 Agent.
* @param url the Connection URL to be used to construct the AMQP Connection.
* @param broker the root Broker Management Object from which the other Management Objects may be obtained.
- * to work without explicitly setting a Virtual Host, which I think is necessary because the C++ broker and
+ * to work without explicitly setting a Virtual Host, which I think is necessary because the C++ Broker and
* the python command line tools aren't currently Virtual Host aware (are they?). The intention is to mark
* queues and exchanges with [vhost:<vhost-name>/]<object-name> in other words if we want to add things to
* the non-default Virtual Host prefix their names with [vhost:<vhost-name>/]. This approach *ought* to allow
@@ -208,26 +208,26 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
}
/**
- * This method initialises the initial set of QmfAgentData Objects and tracks changes to the broker Management
+ * This method initialises the initial set of QmfAgentData Objects and tracks changes to the Broker Management
* Objects via the childAdded() method call.
*/
private void registerConfigurationChangeListeners()
{
childAdded(null, _broker);
- for (VirtualHost vhost : _broker.getVirtualHosts())
+ for (VirtualHost<?> vhost : _broker.getVirtualHosts())
{
// We don't add QmfAgentData VirtualHost objects. Possibly TODO, but it's a bit awkward at the moment
- // because (as of Qpid 0.20) the C++ broker doesn't *seem* to do much with them and the command line
- // tools such as qpid-config don't appear to be VirtualHost aware. A way to stay compatible is to
- // mark queues, exchanges etc with [vhost:<vhost-name>/]<object-name> (see Constructor comments).
+ // because the C++ Broker doesn't *seem* to do much with them and the command line tools such
+ // as qpid-config don't appear to be VirtualHost aware. A way to stay compatible is to mark queues,
+ // exchanges etc with [vhost:<vhost-name>/]<object-name> (see Constructor comments).
vhost.addChangeListener(this);
- for (Connection connection : vhost.getConnections())
+ for (Connection<?> connection : vhost.getConnections())
{
childAdded(vhost, connection);
- for (Session session : connection.getSessions())
+ for (Session<?> session : connection.getSessions())
{
childAdded(connection, session);
@@ -245,7 +245,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
// relates to Queues or Bindings for the QmfManagementAgent. If they are QmfManagementAgent related
// we avoid registering the Object as a QMF Object, in other words we "hide" QmfManagementAgent QMF Objects.
// This is done to be consistent with the C++ broker which also "hides" its own Connection, Queue & Binding.
- for (Exchange exchange : vhost.getExchanges())
+ for (Exchange<?> exchange : vhost.getExchanges())
{
childAdded(vhost, exchange);
@@ -263,7 +263,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
}
}
- for (Queue queue : vhost.getQueues())
+ for (Queue<?> queue : vhost.getQueues())
{
boolean agentQueue = false;
for (Binding binding : queue.getBindings())
@@ -288,7 +288,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
childAdded(queue, binding);
}
- for (Consumer subscription : queue.getConsumers())
+ for (Consumer subscription : queue.getChildren(Consumer.class))
{
childAdded(queue, subscription);
}
@@ -342,7 +342,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
@Override
public void childAdded(final ConfiguredObject object, final ConfiguredObject child)
{
-//System.out.println("childAdded() " + child.getClass().getSimpleName() + "." + child.getName());
+//System.out.println("childAdded: " + child.getClass().getSimpleName() + "." + child.getName());
QmfAgentData data = null;
@@ -414,7 +414,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
data = new org.apache.qpid.server.qmf2.agentdata.Binding((Binding)child);
_objects.put(child, data);
- String eName = child.getAttribute("exchange").toString();
+ String eName = ((Binding)child).getExchange().getName();
if (!eName.equals("<<default>>")) // Don't send Event for Binding to default direct.
{
// Raise a Bind Event.
@@ -504,6 +504,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
// Look up the associated QmfAgentData and mark it for deletion by the Agent.
QmfAgentData data = _objects.get(child);
+
if (data != null)
{
if (child instanceof Connection)
@@ -527,7 +528,7 @@ public class QmfManagementAgent implements ConfigurationChangeListener, QmfEvent
}
else if (child instanceof Binding)
{
- String eName = child.getAttribute("exchange").toString();
+ String eName = ((Binding)child).getExchange().getName();
if (!eName.equals("<<default>>")) // Don't send Event for Unbinding from default direct.
{
// Raise an Unbind Event.
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java
index 5a923c19a2..be4b9e1c4f 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java
@@ -42,6 +42,7 @@ import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.LifetimePolicy;
+import org.apache.qpid.server.model.ManagedAttribute;
import org.apache.qpid.server.model.Plugin;
import org.apache.qpid.server.model.State;
import org.apache.qpid.server.model.VirtualHost;
@@ -54,20 +55,20 @@ import org.apache.qpid.server.util.MapValueConverter;
* This class is a Qpid Java Broker Plugin which follows the Plugin API added in Qpid 0.22 it implements
* org.apache.qpid.server.model.Plugin and extends org.apache.qpid.server.model.adapter.AbstractPluginAdapter.
* <p>
- * This Plugin provides access to the Java broker Management Objects via QMF2 thus allowing the Java broker to
- * be managed and monitored in the same way as the C++ broker.
+ * This Plugin provides access to the Java Broker Management Objects via QMF2 thus allowing the Java Broker to
+ * be managed and monitored in the same way as the C++ Broker.
* <p>
- * The intention is for the Java broker QmfManagementPlugin to conform to the same Management Schema as the C++
- * broker (e.g. as specified in <qpid>/specs/management-schema.xml) in order to provide maximum cohesion between
- * the to broker implementations, however that's not entirely possible given differences between the underlying
- * Management models. The ultimate aim is to align the Management models of the two Qpid brokers and migrate
+ * The intention is for the Java Broker QmfManagementPlugin to conform to the same Management Schema as the C++
+ * Broker (e.g. as specified in the management-schema.xml) in order to provide maximum cohesion between the
+ * two Broker implementations, however that's not entirely possible given differences between the underlying
+ * Management Models. The ultimate aim is to align the Management Models of the two Qpid Brokers and migrate
* to the AMQP 1.0 Management architecture when it becomes available.
* <p>
* This Plugin attempts to map properties from the Java org.apache.qpid.server.model.* classes to equivalent
- * properties and statistics in the C++ broker's Management Schema rather than expose them "natively", this is
- * in order to try and maximise alignment between the two implementations and to try to allow the Java broker
- * to be managed by the Command Line tools used with the C++ broker such as qpid-config etc. it's also to
- * enable the Java broker to be accessed via the QMF2 REST API and GUI.
+ * properties and statistics in the C++ Broker's Management Schema rather than expose them "natively", this is
+ * in order to try and maximise alignment between the two implementations and to try to allow the Java Broker
+ * to be managed by the Command Line tools used with the C++ Broker such as qpid-config etc. it's also to
+ * enable the Java Broker to be accessed via the QMF2 REST API and GUI.
* <p>
* This class only bootstraps the ManagementPlugin, the actual business logic is run from QmfManagementAgent.
* It's worth also mentioning that this Plugin actually establishes an AMQP Connection to the Broker via JMS.
@@ -88,7 +89,7 @@ import org.apache.qpid.server.util.MapValueConverter;
* </pre>
* @author Fraser Adams
*/
-public class QmfManagementPlugin extends AbstractPluginAdapter
+public class QmfManagementPlugin extends AbstractPluginAdapter<QmfManagementPlugin>
{
private static final Logger _log = LoggerFactory.getLogger(QmfManagementPlugin.class);
@@ -107,30 +108,24 @@ public class QmfManagementPlugin extends AbstractPluginAdapter
public static final String DEFAULT_CONNECTION_URL = "amqp://guest:guest@/?brokerlist='tcp://0.0.0.0:5672'";
@SuppressWarnings("serial")
- private static final Collection<String> AVAILABLE_ATTRIBUTES = Collections.unmodifiableCollection(
- new HashSet<String>(Plugin.AVAILABLE_ATTRIBUTES){{
- add(NAME);
- add(CONNECTION_URL);
- add(PluginFactory.PLUGIN_TYPE);
- }});
-
- @SuppressWarnings("serial")
- private static final Map<String, Object> DEFAULTS = new HashMap<String, Object>(){{
+ private static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>()
+ {{
put(NAME, DEFAULT_NAME);
put(CONNECTION_URL, DEFAULT_CONNECTION_URL);
put(PluginFactory.PLUGIN_TYPE, PLUGIN_TYPE);
- }};
+ }});
@SuppressWarnings("serial")
- private static final Map<String, Type> ATTRIBUTE_TYPES = new HashMap<String, Type>(){{
+ private static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>()
+ {{
put(NAME, String.class);
put(CONNECTION_URL, String.class);
put(PluginFactory.PLUGIN_TYPE, String.class);
- }};
+ }});
/************************************ End of Static initialiser *************************************/
- private final Broker _broker; // Passed in by Plugin bootstrapping.
+ private final Broker<?> _broker; // Passed in by Plugin bootstrapping.
private final String _defaultVirtualHost; // Pulled from the broker attributes.
private final String _connectionURL; // Pulled from the Plugin config.
private QmfManagementAgent _agent;
@@ -147,7 +142,7 @@ public class QmfManagementPlugin extends AbstractPluginAdapter
addParent(Broker.class, broker);
_broker = broker;
_defaultVirtualHost = (String)broker.getAttribute("defaultVirtualHost");
- _connectionURL = (String)getAttribute("connectionURL");
+ _connectionURL = (String)getAttribute(CONNECTION_URL);
}
/**
@@ -201,7 +196,7 @@ public class QmfManagementPlugin extends AbstractPluginAdapter
// Iterate through the Virtual Hosts looking for the default Virtual Host. When we find the default
// we create the QMF exchanges then construct the QmfManagementAgent passing it the ConnectionURL.
boolean foundDefaultVirtualHost = false;
- for (VirtualHost vhost : _broker.getVirtualHosts())
+ for (VirtualHost<?> vhost : _broker.getVirtualHosts())
{
if (vhost.getName().equals(_defaultVirtualHost))
{
@@ -228,13 +223,13 @@ public class QmfManagementPlugin extends AbstractPluginAdapter
if (needDefaultDirect)
{
vhost.createExchange("qmf.default.direct", State.ACTIVE, true,
- LifetimePolicy.PERMANENT, 0l, "direct", attributes);
+ LifetimePolicy.PERMANENT, "direct", attributes);
}
if (needDefaultTopic)
{
vhost.createExchange("qmf.default.topic", State.ACTIVE, true,
- LifetimePolicy.PERMANENT, 0l, "topic", attributes);
+ LifetimePolicy.PERMANENT, "topic", attributes);
}
// Now create the *real* Agent which maps Broker Management Objects to QmdAgentData Objects.
@@ -277,16 +272,6 @@ public class QmfManagementPlugin extends AbstractPluginAdapter
}
/**
- * Get the name of this Plugin.
- * @return the Plugin name (default is "qmf2Management").
- */
- @Override // From org.apache.qpid.server.model.ConfiguredObject
- public String getName()
- {
- return (String)getAttribute(NAME);
- }
-
- /**
* Accessor to retrieve the names of the available attributes. It is important to provide this overridden
* method because the Constructor uses this information when populating the underlying AbstractPlugin
* information. If we don't provide this override method getAttribute(name) will return the default values.
@@ -295,6 +280,26 @@ public class QmfManagementPlugin extends AbstractPluginAdapter
@Override // From org.apache.qpid.server.model.adapter.AbstractPluginAdapter
public Collection<String> getAttributeNames()
{
- return AVAILABLE_ATTRIBUTES;
+ return getAttributeNames(QmfManagementPlugin.class);
+ }
+
+ /**
+ * Accessor to retrieve the Plugin Type.
+ * @return the Plugin Type e.g. the String "MANAGEMENT-QMF2".
+ */
+ @Override // From org.apache.qpid.server.model.Plugin
+ public String getPluginType()
+ {
+ return PLUGIN_TYPE;
+ }
+
+ /**
+ * Accessor to retrieve the connectionURL attribute.
+ * @return the JMS connectionURL of the Plugin.
+ */
+ @ManagedAttribute
+ public String getConnectionURL()
+ {
+ return (String)getAttribute(CONNECTION_URL);
}
}
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Binding.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Binding.java
index 23d5ce5663..5feca96bc2 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Binding.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Binding.java
@@ -38,8 +38,6 @@ import org.apache.qpid.qmf2.common.SchemaEventClass;
import org.apache.qpid.qmf2.common.SchemaObjectClass;
//import org.apache.qpid.qmf2.common.SchemaProperty;
-import org.apache.qpid.server.model.Statistics;
-
/**
* This class provides a concrete implementation of QmfAgentData for the Binding Management Object.
* In general it's possible to use QmfAgentData without sub-classing as it's really a "bean" style class
@@ -112,6 +110,7 @@ public class Binding extends QmfAgentData
* Constructor.
* @param binding the Binding ConfiguredObject from the broker model.
*/
+ @SuppressWarnings("unchecked")
public Binding(final org.apache.qpid.server.model.Binding binding)
{
super(getSchema());
@@ -125,8 +124,7 @@ public class Binding extends QmfAgentData
{
setValue("arguments", arguments);
}
-
- // origin not implemented in Qpid 0.20 - not really sure what the origin property means anyway???
+ // origin not implemented in Java Broker - not really sure what the origin property means anyway???
}
/**
@@ -156,9 +154,9 @@ public class Binding extends QmfAgentData
QmfEvent bind = new QmfEvent(_bindSchema);
bind.setSeverity("info");
bind.setValue("args", _binding.getArguments());
- bind.setValue("exName", _binding.getAttribute("exchange"));
+ bind.setValue("exName", _binding.getExchange().getName());
bind.setValue("key", _binding.getName());
- bind.setValue("qName", _binding.getAttribute("queue"));
+ bind.setValue("qName", _binding.getQueue().getName());
// TODO Not sure of a way to get these for Java Broker Exchange.
//bind.setValue("rhost", _connection.getName());
//bind.setValue("user", getStringValue("authIdentity"));
@@ -173,9 +171,9 @@ public class Binding extends QmfAgentData
{
QmfEvent unbind = new QmfEvent(_unbindSchema);
unbind.setSeverity("info");
- unbind.setValue("exName", _binding.getAttribute("exchange"));
+ unbind.setValue("exName", _binding.getExchange().getName());
unbind.setValue("key", _binding.getName());
- unbind.setValue("qName", _binding.getAttribute("queue"));
+ unbind.setValue("qName", _binding.getQueue().getName());
// TODO Not sure of a way to get these for Java Broker Exchange.
//unbind.setValue("rhost", _connection.getName());
//unbind.setValue("user", getStringValue("authIdentity"));
@@ -193,11 +191,9 @@ public class Binding extends QmfAgentData
public Map<String, Object> mapEncode()
{
// Statistics
- //Statistics stats = _binding.getStatistics();
- // not implemented in Qpid 0.20 despite the property actually existing!!
- //setValue("msgMatched", stats.getStatistic("matchedMessages"));
+ setValue("msgMatched", _binding.getMatches());
- //update(); // No statistics have been updated ('cause there aren't any yet...)
+ update(); // TODO only set update if a statistic has actually changed value.
return super.mapEncode();
}
}
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Broker.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Broker.java
index d6be065c81..644b25fd03 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Broker.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Broker.java
@@ -90,7 +90,7 @@ public class Broker extends QmfAgentData
//_schema.addProperty(new SchemaProperty("whatHappened", QmfType.TYPE_STRING));
}
- private final org.apache.qpid.server.model.Broker _broker; // Passed in by Plugin bootstrapping.
+ private final org.apache.qpid.server.model.Broker<?> _broker; // Passed in by Plugin bootstrapping.
private final String _defaultVirtualHost; // Pulled from the broker attributes.
/**
@@ -113,9 +113,9 @@ public class Broker extends QmfAgentData
private class NameParser
{
private String _vhostName = _defaultVirtualHost;
- private VirtualHost _vhost = null;
+ private VirtualHost<?> _vhost = null;
private String _exchangeName = "";
- private Exchange _exchange = null;
+ private Exchange<?> _exchange = null;
private String _queueName = "";
private Queue _queue = null;
private String _bindingKey = "";
@@ -346,6 +346,7 @@ public class Broker extends QmfAgentData
public Broker(final org.apache.qpid.server.model.Broker broker)
{
super(getSchema());
+
_broker = broker;
_defaultVirtualHost = (String)broker.getAttribute("defaultVirtualHost");
int amqpPort = 5672; // Default AMQP Port.
@@ -355,7 +356,7 @@ public class Broker extends QmfAgentData
// it might be good to return more detailed info, but for QMF the "port" property description for the
// Broker Object says "TCP Port for AMQP Service" so doing anything fancier might break consumers.
// TODO The C++ and Java Brokers should really return consistent information.
- for (Port port : _broker.getPorts())
+ for (Port<?> port : _broker.getPorts())
{
boolean isAMQP = false;
boolean isTCP = false;
@@ -472,6 +473,7 @@ public class Broker extends QmfAgentData
* @param methodName the name of the QMF method being invoked.
* @param inArgs a Map of input arguments wrapped in a QmfData Object.
*/
+ @SuppressWarnings("unchecked")
public void invokeMethod(Agent agent, Handle handle, String methodName, QmfData inArgs)
{
if (methodName.equals("create") || methodName.equals("delete"))
@@ -548,7 +550,7 @@ System.out.println("properties = " + properties);
// Note that for Qpid 0.20 the "qpid.msg_sequence=1" and "qpid.ive=1" properties are
// not suppored, indeed no exchange properties seem to be supported yet.
vhost.createExchange(nameParser.getExchangeName(), State.ACTIVE, durable,
- LifetimePolicy.PERMANENT, 0l, exchangeType, properties);
+ LifetimePolicy.PERMANENT, exchangeType, properties);
if (alternateExchange != null)
{
// TODO set Alternate Exchange. There doesn't seem to be a way to do this yet!!!
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Connection.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Connection.java
index a2b03c7c20..0dc9ba4975 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Connection.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Connection.java
@@ -36,8 +36,6 @@ import org.apache.qpid.qmf2.common.SchemaEventClass;
import org.apache.qpid.qmf2.common.SchemaObjectClass;
//import org.apache.qpid.qmf2.common.SchemaProperty;
-import org.apache.qpid.server.model.Statistics;
-
/**
* This class provides a concrete implementation of QmfAgentData for the Connection Management Object.
* In general it's possible to use QmfAgentData without sub-classing as it's really a "bean" style class
@@ -122,22 +120,23 @@ public class Connection extends QmfAgentData
// TODO vhostRef - currently just use its name to try and get things working with standard command line tools.
setValue("address", address);
- setValue("incoming", true); // incoming not supported in Qpid 0.20
-
- // Although not implemented in Qpid 0.20 it's reasonable for them to be false
- setValue("SystemConnection", false); // Is the S in System really a capital? not implemented in Qpid 0.20
- setValue("userProxyAuth", false); // Not implemented in Qpid 0.20
- setValue("federationLink", false); // Not implemented in Qpid 0.20
-
- setValue("authIdentity", connection.getAttribute("principal"));
- setValue("remoteProcessName", "unknown"); // remoteProcessName not supported in Qpid 0.20
- setValue("remotePid", "unknown"); // remoteProcessName not supported in Qpid 0.20
- setValue("remoteParentPid", "unknown"); // remoteProcessName not supported in Qpid 0.20
-
- // shadow Not implemented in Qpid 0.20
- // saslMechanism Not implemented in Qpid 0.20
- // saslSsf Not implemented in Qpid 0.20
- // protocol Not implemented in Qpid 0.20
+ setValue("incoming", connection.isIncoming());
+
+ // Although not implemented in Java Broker it's reasonable for them to be false
+ setValue("SystemConnection", false); // Is the S in System really a capital? not implemented in Java Broker
+ setValue("userProxyAuth", false); // Not implemented in Java Broker
+ setValue("federationLink", false); // Not implemented in Java Broker
+ setValue("authIdentity", (connection.getPrincipal() == null ? "unknown" : connection.getPrincipal()));
+ setValue("remoteProcessName", (connection.getRemoteProcessName() == null ?
+ "unknown" : connection.getRemoteProcessName()));
+ setValue("remotePid", (connection.getRemoteProcessPid() == null ?
+ "unknown" : connection.getRemoteProcessPid()));
+ setValue("remoteParentPid", "unknown"); // remoteProcessName not supported in Java Broker
+
+ // shadow Not implemented in Java Broker
+ // saslMechanism Not implemented in Java Broker
+ // saslSsf Not implemented in Java Broker
+ // protocol Not implemented in Java Broker
}
/**
@@ -179,16 +178,15 @@ public class Connection extends QmfAgentData
public Map<String, Object> mapEncode()
{
// Statistics
- Statistics stats = _connection.getStatistics();
- // closing Not implemented in Qpid 0.20
- setValue("framesFromClient", 0); // framesFromClient Not implemented in Qpid 0.20
- setValue("framesToClient", 0); // framesToClient Not implemented in Qpid 0.20
- setValue("bytesFromClient", stats.getStatistic("bytesIn"));
- setValue("bytesToClient", stats.getStatistic("bytesOut"));
- setValue("msgsFromClient", stats.getStatistic("messagesIn"));
- setValue("msgsToClient", stats.getStatistic("messagesOut"));
-
- update(); // TODO set update if statistics change.
+ // closing Not implemented in Java Broker
+ setValue("framesFromClient", 0); // framesFromClient Not implemented in Java Broker
+ setValue("framesToClient", 0); // framesToClient Not implemented in Java Broker
+ setValue("bytesFromClient", _connection.getBytesIn());
+ setValue("bytesToClient", _connection.getBytesOut());
+ setValue("msgsFromClient", _connection.getMessagesIn());
+ setValue("msgsToClient", _connection.getMessagesOut());
+
+ update(); // TODO only set update if statistics change.
return super.mapEncode();
}
}
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Exchange.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Exchange.java
index 3dbf4332ad..e86140b8cd 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Exchange.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Exchange.java
@@ -39,7 +39,6 @@ import org.apache.qpid.qmf2.common.SchemaObjectClass;
//import org.apache.qpid.qmf2.common.SchemaProperty;
import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Statistics;
/**
* This class provides a concrete implementation of QmfAgentData for the Exchange Management Object.
@@ -214,21 +213,20 @@ public class Exchange extends QmfAgentData
public Map<String, Object> mapEncode()
{
// Statistics
- Statistics stats = _exchange.getStatistics();
- long msgReceives = ((Long)stats.getStatistic("messagesIn")).longValue();
- long msgDrops = ((Long)stats.getStatistic("messagesDropped")).longValue();
+ long msgReceives = _exchange.getMessagesIn();
+ long msgDrops = _exchange.getMessagesDropped();
long msgRoutes = msgReceives - msgDrops;
- long byteReceives = ((Long)stats.getStatistic("bytesIn")).longValue();
- long byteDrops = ((Long)stats.getStatistic("bytesDropped")).longValue();
+ long byteReceives = _exchange.getBytesIn();
+ long byteDrops = _exchange.getBytesDropped();
long byteRoutes = byteReceives - byteDrops;
- setValue("producerCount", "Not yet implemented"); // In Qpid 0.20 producerCount statistic returns null.
+ setValue("producerCount", _exchange.getPublishers().size());
// We have to modify the value of bindingCount for Exchange because the QmfManagementAgent "hides" the
// QMF Objects that relate to its own AMQP Connection/Queues/Bindings so the bindingCount for default direct
// qmf.default.direct and qmf.default.topic is different to the actual number of QMF bindings.
- long bindingCount = ((Long)stats.getStatistic("bindingCount")).longValue();
+ long bindingCount = _exchange.getBindingCount();
if (_name.equals(""))
{
bindingCount -= 3;
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Queue.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Queue.java
index 17e5f0a041..5fef3216da 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Queue.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Queue.java
@@ -44,7 +44,6 @@ import org.apache.qpid.qmf2.common.SchemaObjectClass;
import org.apache.qpid.server.model.Exchange;
import org.apache.qpid.server.model.ExclusivityPolicy;
import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Statistics;
/**
* This class provides a concrete implementation of QmfAgentData for the Queue Management Object.
@@ -258,39 +257,38 @@ public class Queue extends QmfAgentData
}
// Statistics
- Statistics stats = _queue.getStatistics();
- setValue("msgTotalEnqueues", stats.getStatistic("totalEnqueuedMessages"));
- setValue("msgTotalDequeues", stats.getStatistic("totalDequeuedMessages"));
- // msgTxnEnqueues not implemented in Qpid 0.20
- // msgTxnDequeues not implemented in Qpid 0.20
- setValue("msgPersistEnqueues", stats.getStatistic("persistentEnqueuedMessages"));
- setValue("msgPersistDequeues", stats.getStatistic("persistentDequeuedMessages"));
- setValue("msgDepth", stats.getStatistic("queueDepthMessages"));
- setValue("byteDepth", stats.getStatistic("queueDepthBytes"));
- setValue("byteTotalEnqueues", stats.getStatistic("totalEnqueuedBytes"));
- setValue("byteTotalDequeues", stats.getStatistic("totalDequeuedBytes"));
- // byteTxnEnqueues not implemented in Qpid 0.20
- // byteTxnDequeues not implemented in Qpid 0.20
- setValue("bytePersistEnqueues", stats.getStatistic("persistentEnqueuedBytes"));
- setValue("bytePersistDequeues", stats.getStatistic("persistentDequeuedBytes"));
-
- // Flow-to-disk Statistics not implemented in Qpid 0.20
- // releases & acquires not implemented in Qpid 0.20
- // discardsTtl (discardsTtlMessages) not implemented in Qpid 0.20
- // discardsRing not implemented in Qpid 0.20
- // discardsLvq not implemented in Qpid 0.20
- // discardsOverflow not implemented in Qpid 0.20
- // discardsSubscriber not implemented in Qpid 0.20
- // discardsPurge not implemented in Qpid 0.20
- // reroutes not implemented in Qpid 0.20
-
- setValue("consumerCount", stats.getStatistic("consumerCount"));
- setValue("bindingCount", stats.getStatistic("bindingCount"));
- setValue("unackedMessages", stats.getStatistic("unacknowledgedMessages"));
+ setValue("msgTotalEnqueues", _queue.getTotalEnqueuedMessages());
+ setValue("msgTotalDequeues", _queue.getTotalDequeuedMessages());
+ // msgTxnEnqueues not implemented in Java Broker
+ // msgTxnDequeues not implemented in Java Broker
+ setValue("msgPersistEnqueues", _queue.getPersistentEnqueuedMessages());
+ setValue("msgPersistDequeues", _queue.getPersistentDequeuedMessages());
+ setValue("msgDepth", _queue.getQueueDepthMessages());
+ setValue("byteDepth", _queue.getQueueDepthBytes());
+ setValue("byteTotalEnqueues", _queue.getTotalEnqueuedBytes());
+ setValue("byteTotalDequeues", _queue.getTotalDequeuedBytes());
+ // byteTxnEnqueues not implemented in Java Broker
+ // byteTxnDequeues not implemented in Java Broker
+ setValue("bytePersistEnqueues", _queue.getPersistentEnqueuedBytes());
+ setValue("bytePersistDequeues", _queue.getPersistentDequeuedBytes());
+
+ // Flow-to-disk Statistics not implemented in Java Broker
+ // releases & acquires not implemented in Java Broker
+ // discardsTtl (discardsTtlMessages) not implemented in Java Broker
+ // discardsRing not implemented in Java Broker
+ // discardsLvq not implemented in Java Broker
+ // discardsOverflow not implemented in Java Broker
+ // discardsSubscriber not implemented in Java Broker
+ // discardsPurge not implemented in Java Broker
+ // reroutes not implemented in Java Broker
+
+ setValue("consumerCount", _queue.getConsumerCount());
+ setValue("bindingCount", _queue.getBindingCount());
+ setValue("unackedMessages", _queue.getUnacknowledgedMessages());
setValue("messageLatency", "Not yet implemented");
- // flowStopped not implemented in Qpid 0.20
- // flowStoppedCount not implemented in Qpid 0.20
+ // flowStopped not implemented in Java Broker
+ // flowStoppedCount not implemented in Java Broker
update(); // TODO only update if statistics have actually changed.
return super.mapEncode();
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java
index cea6619bad..7c4f121503 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java
@@ -37,8 +37,6 @@ import org.apache.qpid.qmf2.common.ObjectId;
import org.apache.qpid.qmf2.common.SchemaObjectClass;
//import org.apache.qpid.qmf2.common.SchemaProperty;
-import org.apache.qpid.server.model.Statistics;
-
/**
* This class provides a concrete implementation of QmfAgentData for the Session Management Object.
* In general it's possible to use QmfAgentData without sub-classing as it's really a "bean" style class
@@ -89,7 +87,7 @@ public class Session extends QmfAgentData
public Session(final org.apache.qpid.server.model.Session session, final ObjectId connectionRef)
{
super(getSchema());
- _session = session; // Will eventually be used in mapEncode() to retrieve statistics.
+ _session = session;
setValue("name", session.getAttribute("id")); // Use ID to be consistent with C++ Broker.
setValue("channelId", session.getName()); // The Java Broker name uses the channelId.
@@ -107,9 +105,9 @@ public class Session extends QmfAgentData
public Map<String, Object> mapEncode()
{
// Statistics
-
- Statistics stats = _session.getStatistics();
- setValue("unackedMessages", stats.getStatistic("unacknowledgedMessages"));
+ setValue("unackedMessages", _session.getUnacknowledgedMessages());
+ setValue("TxnStarts", _session.getLocalTransactionBegins());
+ setValue("TxnRejects", _session.getLocalTransactionRollbacks());
update(); // TODO Only Update if statistics have changes.
diff --git a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Subscription.java b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Subscription.java
index 4b074ec985..6e12949c31 100644
--- a/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Subscription.java
+++ b/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Subscription.java
@@ -41,7 +41,6 @@ import org.apache.qpid.qmf2.common.SchemaObjectClass;
import org.apache.qpid.server.model.ExclusivityPolicy;
import org.apache.qpid.server.model.Queue;
-import org.apache.qpid.server.model.Statistics;
/**
* This class provides a concrete implementation of QmfAgentData for the Subscription Management Object.
@@ -124,9 +123,9 @@ public class Subscription extends QmfAgentData
_subscription = subscription; // Will eventually be used in mapEncode() to retrieve statistics.
setValue("name", subscription.getName());
- setValue("browsing", false); // TODO not supported in Qpid 0.20.
- setValue("acknowledged", true); // TODO not supported in Qpid 0.20.
- setValue("creditMode", "WINDOW"); // TODO not supported in Qpid 0.20.
+ setValue("browsing", false); // TODO not supported in Java Broker.
+ setValue("acknowledged", true); // TODO not supported in Java Broker.
+ setValue("creditMode", "WINDOW"); // TODO not supported in Java Broker.
}
/**
@@ -202,8 +201,7 @@ public class Subscription extends QmfAgentData
public Map<String, Object> mapEncode()
{
// Statistics
- Statistics stats = _subscription.getStatistics();
- setValue("delivered", stats.getStatistic("messagesOut"));
+ setValue("delivered", _subscription.getMessagesOut());
setValue("exclusive", _exclusive);