You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by fa...@apache.org on 2013/07/19 18:55:55 UTC
svn commit: r1504940 - in
/qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2:
QmfManagementFactory.java agentdata/Session.java
Author: fadams
Date: Fri Jul 19 16:55:55 2013
New Revision: 1504940
URL: http://svn.apache.org/r1504940
Log:
JIRA: QPID-5008 Add Session.java class to 0.24 branch and merge QPID-5005 fix from trunk to 0.24
Added:
qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java (with props)
Modified:
qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementFactory.java
Modified: qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementFactory.java?rev=1504940&r1=1504939&r2=1504940&view=diff
==============================================================================
--- qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementFactory.java (original)
+++ qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/QmfManagementFactory.java Fri Jul 19 16:55:55 2013
@@ -76,4 +76,10 @@ public class QmfManagementFactory implem
return null;
}
}
+
+ @Override
+ public String getType()
+ {
+ return "QMF2 Management";
+ }
}
Added: qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java?rev=1504940&view=auto
==============================================================================
--- qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java (added)
+++ qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java Fri Jul 19 16:55:55 2013
@@ -0,0 +1,118 @@
+/*
+ *
+ * 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.qpid.server.qmf2.agentdata;
+
+// Misc Imports
+import java.util.Collections;
+import java.util.Map;
+
+// Simple Logging Facade 4 Java
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+// QMF2 Imports
+import org.apache.qpid.qmf2.agent.QmfAgentData;
+import org.apache.qpid.qmf2.common.ObjectId;
+//import org.apache.qpid.qmf2.common.SchemaEventClass;
+//import org.apache.qpid.qmf2.common.SchemaMethod;
+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
+ * that retains its properties in a Map, but in the case of the Java Broker Management Agent it's useful
+ * to sub-class as we need to map between the properties/statistics as specified in the Java Broker
+ * management model and those specified in qpid/spec/management-schema.xml which is what the C++ broker
+ * uses. This class retains a reference to its peer org.apache.qpid.server.model.Consumer and does the
+ * necessary mapping when its mapEncode() method is called (which is used to serialise the QmfAgentData).
+ *
+ * @author Fraser Adams
+ */
+public class Session extends QmfAgentData
+{
+ private static final Logger _log = LoggerFactory.getLogger(Session.class);
+
+ /**
+ * This static initialiser block initialises the QMF2 Schema information needed by the Agent to find
+ * QmfAgentData and QmfEvent Objects of a given type.
+ */
+ private static final SchemaObjectClass _schema;
+
+ /**
+ * Returns the schema for the Session class.
+ * @return the SchemaObjectClass for the Session class.
+ */
+ public static SchemaObjectClass getSchema()
+ {
+ return _schema;
+ }
+
+ static
+ {
+ // Declare the schema for the QMF2 session class.
+ _schema = new SchemaObjectClass("org.apache.qpid.broker", "session");
+
+ // TODO
+ //_schema.addProperty(new SchemaProperty("whatHappened", QmfType.TYPE_STRING));
+ }
+ // End of static initialiser.
+
+ private final org.apache.qpid.server.model.Session _session;
+
+ /**
+ * Constructor.
+ * @param session the Session ConfiguredObject from the broker model.
+ * @param connectionRef the ObjectId of the Connection Object that is the parent of the Session.
+ */
+ 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.
+
+ setValue("name", session.getAttribute("id")); // Use ID to be consistent with C++ Broker.
+ setValue("channelId", session.getName()); // The Java Broker name uses the channelId.
+ setRefValue("connectionRef", connectionRef);
+ }
+
+ /**
+ * This method maps the org.apache.qpid.server.model.Session to QMF2 subscribe properties where possible then
+ * serialises into the underlying Map for transmission via AMQP. This method is called by handleQueryRequest()
+ * in the org.apache.qpid.qmf2.agent.Agent class implementing the main QMF2 Agent behaviour.
+ *
+ * @return the underlying map.
+ */
+ @Override
+ public Map<String, Object> mapEncode()
+ {
+ // Statistics
+
+ Statistics stats = _session.getStatistics();
+ setValue("unackedMessages", stats.getStatistic("unacknowledgedMessages"));
+
+ update(); // TODO Only Update if statistics have changes.
+
+ return super.mapEncode();
+ }
+}
Propchange: qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/branches/0.24/qpid/tools/src/java/src/qpid-broker-plugins-management-qmf2/java/org/apache/qpid/server/qmf2/agentdata/Session.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org