summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/management-http
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-02-25 01:19:43 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-02-25 01:19:43 +0000
commitddba94d2538db03bdca182ab29309ebf83cd81c9 (patch)
tree4b0ef0435ddd2c4106af2b35982967b300082802 /qpid/java/broker-plugins/management-http
parent2c02e80ee4907c42764d76018e8bfa9a71641822 (diff)
downloadqpid-python-ddba94d2538db03bdca182ab29309ebf83cd81c9.tar.gz
QPID-5579 : Use annotations to generate statistics values
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1571510 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/management-http')
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java2
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java23
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java2
-rw-r--r--qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java13
4 files changed, 9 insertions, 31 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
index 14196310a5..047cdfc29b 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
@@ -430,7 +430,7 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem
@Override
public Collection<String> getAttributeNames()
{
- return Attribute.getAttributeNames(HttpManagement.class);
+ return getAttributeNames(HttpManagement.class);
}
@Override
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
index 0d5d868af2..2cf7f3f80c 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java
@@ -21,14 +21,12 @@ package org.apache.qpid.server.management.plugin.servlet.rest;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Model;
-import org.apache.qpid.server.model.Statistics;
public class ConfiguredObjectToMapConverter
{
@@ -81,25 +79,14 @@ public class ConfiguredObjectToMapConverter
private void incorporateStatisticsIntoMap(
final ConfiguredObject confObject, Map<String, Object> object)
{
- Statistics statistics = confObject.getStatistics();
- Map<String, Object> statMap = new HashMap<String, Object>();
- if (statistics != null)
- {
- for(String name : statistics.getStatisticNames())
- {
- Object value = statistics.getStatistic(name);
- if(value != null)
- {
- statMap.put(name, value);
- }
- }
+ Map<String, Object> statMap = confObject.getStatistics();
- if(!statMap.isEmpty())
- {
- object.put(STATISTICS_MAP_KEY, statMap);
- }
+ if(!statMap.isEmpty())
+ {
+ object.put(STATISTICS_MAP_KEY, statMap);
}
+
}
private void incorporateChildrenIntoMap(
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
index fa7fb06077..d28338b354 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/MessageServlet.java
@@ -106,7 +106,7 @@ public class MessageServlet extends AbstractServlet
response.setContentType("application/json");
final List<Map<String, Object>> messages = messageCollector.getMessages();
- int queueSize = ((Number) queue.getStatistics().getStatistic(Queue.QUEUE_DEPTH_MESSAGES)).intValue();
+ int queueSize = (int) queue.getQueueDepthMessages();
String min = messages.isEmpty() ? "0" : messages.get(0).get("position").toString();
String max = messages.isEmpty() ? "0" : messages.get(messages.size()-1).get("position").toString();
response.setHeader("Content-Range", (min + "-" + max + "/" + queueSize));
diff --git a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
index 8e5c5e1c10..0c2b6a5385 100644
--- a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
+++ b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java
@@ -25,6 +25,7 @@ import static org.apache.qpid.server.management.plugin.servlet.rest.ConfiguredOb
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -32,7 +33,6 @@ import junit.framework.TestCase;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Model;
-import org.apache.qpid.server.model.Statistics;
public class ConfiguredObjectToMapConverterTest extends TestCase
{
@@ -50,8 +50,7 @@ public class ConfiguredObjectToMapConverterTest extends TestCase
final String statisticName = "statisticName";
final int statisticValue = 10;
- Statistics mockStatistics = createMockStatistics(statisticName, statisticValue);
- when(_configuredObject.getStatistics()).thenReturn(mockStatistics);
+ when(_configuredObject.getStatistics()).thenReturn(Collections.singletonMap(statisticName, (Number) statisticValue));
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, 0);
Map<String, Object> statsAsMap = (Map<String, Object>) resultMap.get(STATISTICS_MAP_KEY);
@@ -127,14 +126,6 @@ public class ConfiguredObjectToMapConverterTest extends TestCase
when(mockConfiguredObject.getAttribute(attributeName)).thenReturn(attributeValue);
}
- private Statistics createMockStatistics(String statName, int statValue)
- {
- Statistics mockStatistics = mock(Statistics.class);
- when(mockStatistics.getStatisticNames()).thenReturn(Arrays.asList(statName));
- when(mockStatistics.getStatistic(statName)).thenReturn(statValue);
- return mockStatistics;
- }
-
private static interface TestChild extends ConfiguredObject
{
}