Author: chirino
Date: Fri Aug 26 03:46:00 2011
New Revision: 1161981
URL: http://svn.apache.org/viewvc?rev=1161981&view=rev
Log:
Fixes https://issues.apache.org/jira/browse/APLO-77 :
/broker/connection-metrics aggregates the connection statistics.
Added:
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AggregateConnectionMetricsDTO.java
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Topic.scala
activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala?rev=1161981&r1=1161980&r2=1161981&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
Fri Aug 26 03:46:00 2011
@@ -344,7 +344,7 @@ class Broker() extends BaseService {
}
def schedule_periodic_maintenance:Unit = dispatch_queue.after(1,
TimeUnit.SECONDS) {
- if( service_state.is_started ) {
+ if( service_state.is_starting_or_started ) {
now = System.currentTimeMillis
schedule_periodic_maintenance
}
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Topic.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Topic.scala?rev=1161981&r1=1161980&r2=1161981&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Topic.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Topic.scala
Fri Aug 26 03:46:00 2011
@@ -50,12 +50,12 @@ class Topic(val router:LocalRouter, val
def add_counters(to:LinkDTO, from:(Long,Long,Long)):Unit = {
to.enqueue_item_counter += from._1
to.enqueue_size_counter += from._2
- to.enqueue_ts = to.enqueue_ts max from._2
+ to.enqueue_ts = to.enqueue_ts max from._3
}
def add_counters(to:Topic, from:(Long,Long,Long)):Unit = {
to.enqueue_item_counter += from._1
to.enqueue_size_counter += from._2
- to.enqueue_ts = to.enqueue_ts max from._2
+ to.enqueue_ts = to.enqueue_ts max from._3
}
case class ProxyDeliverySession(session:DeliverySession) extends
DeliverySession with SinkFilter[Delivery] {
Added:
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AggregateConnectionMetricsDTO.java
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AggregateConnectionMetricsDTO.java?rev=1161981&view=auto
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AggregateConnectionMetricsDTO.java
(added)
+++
activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AggregateConnectionMetricsDTO.java
Fri Aug 26 03:46:00 2011
@@ -0,0 +1,66 @@
+/**
+ * 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.apollo.dto;
+
+
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+@XmlRootElement(name="aggregate_connection_metrics")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class AggregateConnectionMetricsDTO {
+
+ /**
+ * The current time on the broker machine. In milliseconds since the
epoch.
+ */
+ @XmlAttribute(name="current_time")
+ public long current_time;
+
+ /**
+ * Total number of bytes that have been read from the connections.
+ */
+ @XmlAttribute(name="read_counter")
+ public long read_counter;
+
+ /**
+ * Total number of bytes that have been written to the connections.
+ */
+ @XmlAttribute(name="write_counter")
+ public long write_counter;
+
+ /**
+ * Total number of subscriptions opened by the connections.
+ */
+ @XmlAttribute(name="subscription_count")
+ public long subscription_count;
+
+ /**
+ * Total number of opened connections.
+ */
+ @XmlAttribute(name="objects")
+ public long objects;
+
+}
Modified:
activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index?rev=1161981&r1=1161980&r2=1161981&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
(original)
+++
activemq/activemq-apollo/trunk/apollo-dto/src/main/resources/org/apache/activemq/apollo/dto/jaxb.index
Fri Aug 26 03:46:00 2011
@@ -48,4 +48,5 @@ StringListDTO
DataPageDTO
AggregateTopicMetricsDTO
AggregateQueueMetricsDTO
-DestinationMetricsDTO
\ No newline at end of file
+DestinationMetricsDTO
+AggregateConnectionMetricsDTO
\ No newline at end of file
Modified:
activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
URL:
http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala?rev=1161981&r1=1161980&r2=1161981&view=diff
==============================================================================
---
activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
(original)
+++
activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
Fri Aug 26 03:46:00 2011
@@ -32,7 +32,7 @@ import javax.management.openmbean.Compos
import org.josql.{QueryResults, Query}
import java.util.regex.Pattern
import javax.servlet.http.HttpServletResponse
-import java.util.ArrayList
+import java.util.{Collections, ArrayList}
/**
* <p>
@@ -730,6 +730,33 @@ case class BrokerResource() extends Reso
result(strip_resolve(".."))
}
+ @GET
+ @Path("connection-metrics")
+ def get_connection_metrics(): AggregateConnectionMetricsDTO = {
+ val f = new ArrayList[String]()
+ f.add("read_counter")
+ f.add("write_counter")
+ f.add("subscription_count")
+ val rs = connections(f, null, null, Integer.MAX_VALUE,
Collections.emptyList())
+ val rc = new AggregateConnectionMetricsDTO
+ import collection.JavaConversions._
+ for( row <- rs.rows ) {
+ val info = row.asInstanceOf[java.util.List[_]]
+ def read(index:Int) = try {
+ info.get(0).asInstanceOf[java.lang.Number].longValue()
+ } catch {
+ case e:Throwable => 0L
+ }
+ rc.read_counter += read(0)
+ rc.write_counter += read(1)
+ rc.subscription_count += read(2)
+ }
+ rc.objects = rs.rows.length
+ rc.current_time = System.currentTimeMillis()
+ rc
+ }
+
+
@GET @Path("connections")
@Produces(Array("application/json"))
def connections(@QueryParam("f") f:java.util.List[String], @QueryParam("q")
q:String,