activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1470019 - in /activemq/activemq-apollo/trunk: apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DispatchQueueMetrics.java apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
Date Fri, 19 Apr 2013 20:14:49 GMT
Author: chirino
Date: Fri Apr 19 20:14:49 2013
New Revision: 1470019

URL: http://svn.apache.org/r1470019
Log:
Expose dispatch queue monitoring via the web admin interfaces.

Modified:
    activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DispatchQueueMetrics.java
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DispatchQueueMetrics.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DispatchQueueMetrics.java?rev=1470019&r1=1470018&r2=1470019&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DispatchQueueMetrics.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/DispatchQueueMetrics.java
Fri Apr 19 20:14:49 2013
@@ -1,11 +1,88 @@
+/**
+ * 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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
 /**
- * Created with IntelliJ IDEA.
- * User: chirino
- * Date: 4/19/13
- * Time: 2:13 PM
- * To change this template use File | Settings | File Templates.
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
+@XmlRootElement(name = "dispatch_queue_metrics")
+@XmlAccessorType(XmlAccessType.FIELD)
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class DispatchQueueMetrics {
-}
+
+    /**
+     * How long the metrics gathered
+     */
+    @XmlAttribute(name="duration")
+    public long duration;
+
+    /**
+     * The name of the dispatch queue associated with the metrics collected.
+     */
+    @XmlAttribute(name="queue")
+    public String queue;
+
+    /**
+     * The number of tasks waiting to execute
+     */
+    @XmlAttribute(name="waiting")
+    public long waiting;
+
+    /**
+     * The longest amount of time a task spent waiting to execute (in nanoseconds).
+     */
+    @XmlAttribute(name="wait_time_max")
+    public long wait_time_max;
+
+    /**
+     * The total time all tasks spent waiting to execute (in nanoseconds).
+     */
+    @XmlAttribute(name="wait_time_total")
+    public long wait_time_total;
+
+
+    /**
+     * The number of tasks executed.
+     */
+    @XmlAttribute(name="executed")
+    public long executed;
+
+    /**
+     * The longest amount of time a task spent executing (in nanoseconds).
+     */
+    @XmlAttribute(name="execute_time_max")
+    public long execute_time_max;
+
+    /**
+     *  The total time all tasks spent executing (in nanoseconds).
+     */
+    @XmlAttribute(name="execute_time_total")
+    public long execute_time_total;
+
+
+
+}
\ 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=1470019&r1=1470018&r2=1470019&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 Apr 19 20:14:49 2013
@@ -1024,4 +1024,40 @@ class BrokerResource() extends Resource 
     }
   }
 
+  @GET
+  @Path("/hawtdispatch/profile")
+  @ApiOperation(value="Enables or disables profiling")
+  def hawtdispatch_profile(@QueryParam("enabled") enabled : Boolean) = ok {
+    with_broker { broker =>
+      admining(broker) {
+        Dispatch.profile(enabled)
+      }
+    }
+  }
+
+  @GET
+  @Path("/hawtdispatch/metrics")
+  @ApiOperation(value="Enables or disables profiling")
+  def hawtdispatch_metrics(@QueryParam("enabled") enabled : Boolean):Array[DispatchQueueMetrics]
= {
+    with_broker { broker =>
+      monitoring(broker) {
+        val m = Dispatch.metrics()
+        m.toArray(new Array[Metrics](m.size())).sortWith{ case (l,r)=> l.totalRunTimeNS
> r.totalRunTimeNS }.map { x =>
+          val rc = new DispatchQueueMetrics
+          rc.queue = x.queue.getLabel
+          rc.duration = x.durationNS
+
+          rc.waiting = (x.enqueued - x.dequeued).max(0)
+          rc.wait_time_max = x.maxWaitTimeNS
+          rc.wait_time_total = x.totalWaitTimeNS
+
+          rc.execute_time_max = x.maxRunTimeNS
+          rc.execute_time_total = x.totalRunTimeNS
+          rc.executed = x.dequeued
+          rc
+        }
+      }
+    }
+  }
+
 }



Mime
View raw message