Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 23197E742 for ; Fri, 8 Feb 2013 21:19:11 +0000 (UTC) Received: (qmail 31238 invoked by uid 500); 8 Feb 2013 21:19:11 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 31216 invoked by uid 500); 8 Feb 2013 21:19:11 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 31207 invoked by uid 99); 8 Feb 2013 21:19:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2013 21:19:10 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2013 21:19:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B79E62388ADA; Fri, 8 Feb 2013 21:18:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1444246 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-dto/src/main/java/org/apache/activemq/apollo/dto/ apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/le... Date: Fri, 08 Feb 2013 21:18:49 -0000 To: commits@activemq.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130208211849.B79E62388ADA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: chirino Date: Fri Feb 8 21:18:48 2013 New Revision: 1444246 URL: http://svn.apache.org/r1444246 Log: Improve the display of topic message browsing. Added: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrowsePageDTO.java Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Subscription.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/java/org/apache/activemq/apollo/dto/TopicStatusDTO.java activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/index.html activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/js/app.js Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala (original) +++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/LocalRouter.scala Fri Feb 8 21:18:48 2013 @@ -123,6 +123,8 @@ object RouterListenerFactory { } } +case class BrowseResult(first_seq:Long, last_seq:Long, total_entries:Long, entries:Array[(EntryStatusDTO, Delivery)]) + /** *

*

@@ -136,6 +138,9 @@ trait DomainDestination extends SecuredR def virtual_host:VirtualHost + def browse(from_seq:Long, to:Option[Long], max:Long)(func: (BrowseResult)=>Unit):Unit + + def bind (bind_address:BindAddress, consumer:DeliveryConsumer):Unit def unbind (consumer:DeliveryConsumer, persistent:Boolean):Unit Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala (original) +++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Queue.scala Fri Feb 8 21:18:48 2013 @@ -332,14 +332,14 @@ class Queue(val router: LocalRouter, val rc } - def browse(from_seq:Long, to:Option[Long], max:Long)(func: (Array[(EntryStatusDTO, Delivery)])=>Unit):Unit = { + def browse(from_seq:Long, to:Option[Long], max:Long)(func: (BrowseResult)=>Unit):Unit = { var result = ListBuffer[(EntryStatusDTO, Delivery)]() def load_from(start:Long):Unit = { assert_executing var cur = head_entry.getNext while(true) { if( cur == null || result.size >= max || ( to.isDefined && cur.seq > to.get) ) { - func(result.toArray) + func(BrowseResult(head_entry.seq, head_entry.getPreviousCircular.seq, enqueue_item_counter, result.toArray)) return } val next = cur.getNext Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Subscription.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Subscription.scala?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Subscription.scala (original) +++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Subscription.scala Fri Feb 8 21:18:48 2013 @@ -370,6 +370,8 @@ class Subscription(val queue:Queue, val return } + val next = entry.getNext + total_ack_count += 1 total_ack_size += entry.size entry.dequeue(uow) @@ -383,11 +385,11 @@ class Subscription(val queue:Queue, val // we may now be able to prefetch some messages.. acquired_size -= entry.size - val next = entry.nextOrTail entry.remove // entry size changes to 0 - queue.trigger_swap - next.task.run + if( next!=null ) { + next.task.run + } check_drained } 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=1444246&r1=1444245&r2=1444246&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 Feb 8 21:18:48 2013 @@ -279,6 +279,10 @@ class Topic(val router:LocalRouter, val add_enqueue_counters(rc.metrics, link) } + if( retained_message!=null ) { + rc.retained = 1 + } + if( !show_producers ) { rc.producers = null } @@ -337,17 +341,17 @@ class Topic(val router:LocalRouter, val } } - def browse(from_seq:Long, max:Long)(func: (Array[(EntryStatusDTO, Delivery)])=>Unit):Unit = { + def browse(from_seq:Long, to:Option[Long], max:Long)(func: (BrowseResult)=>Unit):Unit = { val msg = retained_message if ( msg==null ) { - func(Array()) + func(BrowseResult(0, 0, 0, Array())) } else { val status = new EntryStatusDTO() status.seq = retained_message.seq status.size = retained_message.size status.state = "loaded" status.is_prefetched = true; - func(Array((status, retained_message))) + func(BrowseResult(status.seq, status.seq, 1, Array((status, retained_message)))) } } Added: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrowsePageDTO.java URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrowsePageDTO.java?rev=1444246&view=auto ============================================================================== --- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrowsePageDTO.java (added) +++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/BrowsePageDTO.java Fri Feb 8 21:18:48 2013 @@ -0,0 +1,77 @@ +/** + * 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.*; +import java.util.ArrayList; +import java.util.List; + +/** + *

Holds a page of data browsed from a destination.

+ * + * @author Hiram Chirino + */ +@XmlRootElement(name="browse_page") +@XmlAccessorType(XmlAccessType.FIELD) +@JsonIgnoreProperties(ignoreUnknown = true) +public class BrowsePageDTO { + + /** + */ + @XmlAttribute(name="first_seq") + public long first_seq; + + /** + */ + @XmlAttribute(name="last_seq") + public long last_seq; + + /** + */ + @XmlAttribute(name="total_messages") + public long total_messages; + + @XmlElement(name="messages") + public List messages = new ArrayList(); + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BrowsePageDTO)) return false; + + BrowsePageDTO that = (BrowsePageDTO) o; + + if (first_seq != that.first_seq) return false; + if (last_seq != that.last_seq) return false; + if (total_messages != that.total_messages) return false; + if (messages != null ? !messages.equals(that.messages) : that.messages != null) + return false; + + return true; + } + + @Override + public int hashCode() { + int result = (int) (first_seq ^ (first_seq >>> 32)); + result = 31 * result + (int) (last_seq ^ (last_seq >>> 32)); + result = 31 * result + (int) (total_messages ^ (total_messages >>> 32)); + result = 31 * result + (messages != null ? messages.hashCode() : 0); + return result; + } +} Modified: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/TopicStatusDTO.java URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/TopicStatusDTO.java?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/TopicStatusDTO.java (original) +++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/TopicStatusDTO.java Fri Feb 8 21:18:48 2013 @@ -36,6 +36,9 @@ public class TopicStatusDTO extends Serv @XmlElement public TopicDTO config; + @XmlElement(name="retained") + public long retained; + /** * Ids of all connections that are producing to the destination */ Modified: activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala (original) +++ activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala Fri Feb 8 21:18:48 2013 @@ -77,9 +77,13 @@ class LevelDBStore(val config: LevelDBSt } } - protected def store(uows: Seq[DelayableUOW])(callback: => Unit) = { - write_executor { + protected def store(uows: Seq[DelayableUOW])(callback: => Unit) = write_executor { + try { client.store(uows) + } catch { + case e => + warn(e, "Failure occured while storing units of work: "+e) + } finally { dispatch_queue { callback } 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=1444246&r1=1444245&r2=1444246&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 Feb 8 21:18:48 2013 @@ -618,17 +618,24 @@ class BrokerResource() extends Resource def topic_messages(@PathParam("id") id : String, @PathParam("name") name : String, @QueryParam("from") _from:java.lang.Long, @QueryParam("max") _max:java.lang.Long, - @QueryParam("max_body") _max_body:java.lang.Integer):Array[MessageStatusDTO] = { + @QueryParam("max_body") _max_body:java.lang.Integer):BrowsePageDTO = { var from = OptionSupport(_from).getOrElse(0L) var max = OptionSupport(_max).getOrElse(100L) var max_body = OptionSupport(_max_body).getOrElse(0) with_virtual_host(id) { host => - val rc = FutureResult[Array[MessageStatusDTO]]() + val rc = FutureResult[BrowsePageDTO]() val router: LocalRouter = host val node = router.local_topic_domain.destination_by_id.get(name).getOrElse(result(NOT_FOUND)) monitoring(node) { - node.browse(from, max) { deliveries => - rc.set(Success(deliveries.map(message_convert(max_body, _)))) + node.browse(from, None, max) { browse_result => + val page = new BrowsePageDTO() + for( entry <- browse_result.entries ) { + page.messages.add(message_convert(max_body, entry)) + } + page.first_seq = browse_result.first_seq + page.last_seq = browse_result.last_seq + page.total_messages = browse_result.total_entries + rc.set(Success(page)) } } rc @@ -673,18 +680,25 @@ class BrokerResource() extends Resource @QueryParam("from") _from:java.lang.Long, @QueryParam("to") _to:java.lang.Long, @QueryParam("max") _max:java.lang.Long, - @QueryParam("max_body") _max_body:java.lang.Integer):Array[MessageStatusDTO] = { + @QueryParam("max_body") _max_body:java.lang.Integer):BrowsePageDTO = { var from = OptionSupport(_from).getOrElse(0L) var to = OptionSupport(_to) var max = OptionSupport(_max).getOrElse(100L) var max_body = OptionSupport(_max_body).getOrElse(0) with_virtual_host(id) { host => - val rc = FutureResult[Array[MessageStatusDTO]]() + val rc = FutureResult[BrowsePageDTO]() val router: LocalRouter = host val node = router.local_queue_domain.destination_by_id.get(name).getOrElse(result(NOT_FOUND)) monitoring(node) { - node.browse(from, to, max) { deliveries => - rc.set(Success(deliveries.map(message_convert(max_body, _)))) + node.browse(from, to, max) { browe_result => + val page = new BrowsePageDTO() + for( entry <- browe_result.entries ) { + page.messages.add(message_convert(max_body, entry)) + } + page.first_seq = browe_result.first_seq + page.last_seq = browe_result.last_seq + page.total_messages = browe_result.total_entries + rc.set(Success(page)) } } rc @@ -742,6 +756,7 @@ class BrokerResource() extends Resource rc.codec = delivery.message.codec.id() rc.headers = delivery.message.headers_as_json; rc.expiration = delivery.expiration + rc.persistent = delivery.persistent rc.entry = entry if( max_body > 0 ) { @@ -818,19 +833,26 @@ class BrokerResource() extends Resource @QueryParam("from") _from:java.lang.Long, @QueryParam("to") _to:java.lang.Long, @QueryParam("max") _max:java.lang.Long, - @QueryParam("max_body") _max_body:java.lang.Integer):Array[MessageStatusDTO] = { + @QueryParam("max_body") _max_body:java.lang.Integer):BrowsePageDTO = { var from = OptionSupport(_from).getOrElse(0L) var to = OptionSupport(_to) var max = OptionSupport(_max).getOrElse(100L) var max_body = OptionSupport(_max_body).getOrElse(0) with_virtual_host(id) { host => - val rc = FutureResult[Array[MessageStatusDTO]]() + val rc = FutureResult[BrowsePageDTO]() val router: LocalRouter = host val node = router.local_dsub_domain.destination_by_id.get(name).getOrElse(result(NOT_FOUND)) monitoring(node) { - node.browse(from, to, max) { deliveries => - rc.set(Success(deliveries.map(message_convert(max_body, _)))) + node.browse(from, to, max) { browse_result => + val page = new BrowsePageDTO() + for( entry <- browse_result.entries ) { + page.messages.add(message_convert(max_body, entry)) + } + page.first_seq = browse_result.first_seq + page.last_seq = browse_result.last_seq + page.total_messages = browse_result.total_entries + rc.set(Success(page)) } } rc Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml (original) +++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/web.xml Fri Feb 8 21:18:48 2013 @@ -72,5 +72,9 @@ woff font/woff + + ttf + font/ttf + Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/index.html URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/index.html?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/index.html (original) +++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/index.html Fri Feb 8 21:18:48 2013 @@ -220,16 +220,16 @@ {{/if}} Queue Size: {{App.destination.metrics.queue_items}} messages Enqueued: {{App.destination.metrics.enqueue_item_counter}} items / {{memory App.destination.metrics.enqueue_size_counter}} - + {{#view App.Tooltip titleBinding="App.destination.metrics.enqueue_date"}}{{/view}} Dequeued: {{App.destination.metrics.dequeue_item_counter}} / {{memory App.destination.metrics.dequeue_size_counter}} - + {{#view App.Tooltip titleBinding="App.destination.metrics.dequeue_date"}}{{/view}} Nacked: {{App.destination.metrics.nack_item_counter}} / {{memory App.destination.metrics.nack_size_counter}} - + {{#view App.Tooltip titleBinding="App.destination.metrics.nack_date"}}{{/view}} Expired: {{App.destination.metrics.expired_item_counter}} / {{memory App.destination.metrics.expired_size_counter}} - + {{#view App.Tooltip titleBinding="App.destination.metrics.expired_date"}}{{/view}} Enqueue Rate Throttle: {{App.destination.metrics.max_enqueue_rate}} Swapped In: {{App.destination.metrics.swapped_in_items}} msgs {{memory App.destination.metrics.swapped_in_size}} @@ -244,7 +244,7 @@
@@ -304,12 +304,12 @@ {{/if}} - {{entry.seq}}:{{count}} + {{entry.seq}} {{codec}} {{persistent}} {{expiration}} {{entry.is_prefetched}} - {{entry.acquirer}} + {{entry.acquirer.kind}} {{entry.acquirer.label}} {{memory entry.size}} {{#if show_details}} @@ -354,22 +354,21 @@ Name - Kind
 
Transfers Size - Last Transfer {{#each App.destination.producers}} - {{label}} - {{kind}} - {{enqueue_item_counter}} + {{kind}}: {{label}} + + {{enqueue_item_counter}} + {{#view App.Tooltip titleBinding="enqueue_date"}}{{/view}} + {{memory enqueue_size_counter}} - {{enqueue_date}} {{/each}} @@ -383,11 +382,9 @@ - - @@ -395,11 +392,11 @@ {{#each App.destination.consumers}} - - - + + - Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/js/app.js URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/js/app.js?rev=1444246&r1=1444245&r2=1444246&view=diff ============================================================================== --- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/js/app.js (original) +++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/console/js/app.js Fri Feb 8 21:18:48 2013 @@ -1,94 +1,10 @@ - -// Install a base64 decoding function if one is not available. -if( !window.atob ) { - window.atob = function(text){ - text = text.replace(/\s/g,""); - if(!(/^[a-z0-9\+\/\s]+\={0,2}$/i.test(text)) || text.length % 4 > 0){ - throw new Error("Not a base64-encoded string."); - } - var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - cur, prev, digitNum, - i=0, - result = []; - text = text.replace(/=/g, ""); - while(i < text.length){ - cur = digits.indexOf(text.charAt(i)); - digitNum = i % 4; - switch(digitNum){ - case 1: - result.push(String.fromCharCode(prev << 2 | cur >> 4)); - break; - case 2: - result.push(String.fromCharCode((prev & 0x0f) << 4 | cur >> 2)); - break; - case 3: - result.push(String.fromCharCode((prev & 3) << 6 | cur)); - break; - } - prev = cur; - i++; - } - return result.join(""); - } -} - -Ember.Handlebars.registerHelper("key_value", function(name, fn) { - var obj = this[name]; - var buffer = "", key; - for (key in obj) { - if (obj.hasOwnProperty(key)) { - buffer += fn({key: key, value: obj[key]}); - } - } - return buffer; -}); - -Ember.Handlebars.registerHelper('memory', function(property, options) { - options.fn = function(size) { - if( (typeof size)=="number" ) { - var units = "bytes" - if( size > 1024 ) { - size = size / 1024; - units = "kb" - if( size > 1024 ) { - size = size / 1024; - units = "mb" - if( size > 1024 ) { - size = size / 1024; - units = "gb" - if( size > 1024 ) { - size = size / 1024; - units = "tb" - } - } - } - size = size.toFixed(2); - } else { - if( (""+size).indexOf(".") !== -1 ) { - size = size.toFixed(2); - } - } - return size+" "+units; - } - return size; - } - return Ember.Handlebars.helpers.bind(property, options); -}); - -$(window).resize(function() { - App.set("window_size", { - height:$(window).height(), - width:$(window).width(), - }) -}); - App = Em.Application.create({ window_size:{ height:$(window).height(), width:$(window).width(), }, - refresh_interval:2, + refresh_interval:30, ready: function() { this.schedule_refresh(); @@ -113,9 +29,6 @@ App = Em.Application.create({ App.VirtualHostController.auto_refresh(); App.ConnectorController.auto_refresh(); App.ConfigurationController.auto_refresh(); - Ember.run(function(){ - $(".tooltip-link").tooltip(); - }); }, refresh: function() { @@ -588,6 +501,7 @@ App.DestinationController = Em.Controlle tabs:["Messages","Producers","Consumers"], selected_tab:"Messages", + browse_count:0, destinationBinding:"App.destination", selectedBinding:"App.DestinationsController.selected", @@ -603,6 +517,12 @@ App.DestinationController = Em.Controlle var virtual_host = App.DestinationsController.get("virtual_host"); var kind = App.DestinationsController.get("kind"); App.ajax("GET", "/broker/virtual-hosts/"+virtual_host+"/"+kind+"/"+selected+"?consumers=true&producers=true", function(data) { + + if( kind == "topics ") { + App.set('browse_count', data.retained); + } else { + App.set('browse_count', data.metrics.queue_items); + } data.state_date = date_to_string(data.state_since); data.metrics.enqueue_date = date_to_string(data.metrics.enqueue_ts); data.metrics.dequeue_date = date_to_string(data.metrics.dequeue_ts); @@ -730,9 +650,10 @@ App.MessagesController = Ember. ArrayCon auto_refresh:function() { var virtual_host = App.DestinationsController.get("virtual_host"); var kind = App.DestinationsController.get("kind"); + var content = this.get("content"); var selected = App.DestinationController.get("selected") var destination_path = "/broker/virtual-hosts/"+virtual_host+"/"+kind+"/"+selected; - if( destination_path != this.get("destination_path") ) { + if( destination_path != this.get("destination_path") || content.get("length")==0 ) { this.refresh(); } }, @@ -745,7 +666,8 @@ App.MessagesController = Ember. ArrayCon var from = this.get("from"); var max = this.get("max"); var destination_path = "/broker/virtual-hosts/"+virtual_host+"/"+kind+"/"+selected; - App.ajax("GET", destination_path+"/messages?from="+from+"&max="+max+"&max_body="+max_body, function(data) { + App.ajax("GET", destination_path+"/messages?from="+from+"&max="+max+"&max_body="+max_body, function(page) { + var data = page.messages; data.forEach(function(item, index){ if( item.base64_body ) { var rc = atob(item.base64_body); @@ -938,6 +860,25 @@ App.NumberField = Ember.TextField.extend }.observes('value') }); +App.Tooltip = Ember.View.extend({ + tagName:'a', + attributeBindings: ['href', 'title'], + href:'#', + title:'Example', + didInsertElement: function() { + this.$().tooltip(); + }, + click: function(event){ + this.$().tooltip('toggle') + }, + mouseEnter: function(event){ + this.$().tooltip('show') + }, + mouseLeave: function(event){ + this.$().tooltip('hide') + }, +}); + App.AceView = Ember.View.extend({ editor: null, @@ -1080,4 +1021,89 @@ App.Router = Ember.Router.extend({ }), }) }) + + +// Install a base64 decoding function if one is not available. +if( !window.atob ) { + window.atob = function(text){ + text = text.replace(/\s/g,""); + if(!(/^[a-z0-9\+\/\s]+\={0,2}$/i.test(text)) || text.length % 4 > 0){ + throw new Error("Not a base64-encoded string."); + } + var digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + cur, prev, digitNum, + i=0, + result = []; + text = text.replace(/=/g, ""); + while(i < text.length){ + cur = digits.indexOf(text.charAt(i)); + digitNum = i % 4; + switch(digitNum){ + case 1: + result.push(String.fromCharCode(prev << 2 | cur >> 4)); + break; + case 2: + result.push(String.fromCharCode((prev & 0x0f) << 4 | cur >> 2)); + break; + case 3: + result.push(String.fromCharCode((prev & 3) << 6 | cur)); + break; + } + prev = cur; + i++; + } + return result.join(""); + } +} + +Ember.Handlebars.registerHelper("key_value", function(name, fn) { + var obj = this[name]; + var buffer = "", key; + for (key in obj) { + if (obj.hasOwnProperty(key)) { + buffer += fn({key: key, value: obj[key]}); + } + } + return buffer; +}); + +Ember.Handlebars.registerHelper('memory', function(property, options) { + options.fn = function(size) { + if( (typeof size)=="number" ) { + var units = "bytes" + if( size > 1024 ) { + size = size / 1024; + units = "kb" + if( size > 1024 ) { + size = size / 1024; + units = "mb" + if( size > 1024 ) { + size = size / 1024; + units = "gb" + if( size > 1024 ) { + size = size / 1024; + units = "tb" + } + } + } + size = size.toFixed(2); + } else { + if( (""+size).indexOf(".") !== -1 ) { + size = size.toFixed(2); + } + } + return size+" "+units; + } + return size; + } + return Ember.Handlebars.helpers.bind(property, options); +}); + +$(window).resize(function() { + App.set("window_size", { + height:$(window).height(), + width:$(window).width(), + }) +}); + App.initialize();
Kind Name Transfers SizeLast Transfer Acks Nacks Ack Rate
{{kind}}{{label}}{{enqueue_item_counter}}{{kind}}: {{label}}{{enqueue_item_counter}} + {{#view App.Tooltip titleBinding="enqueue_date"}}{{/view}} + {{memory enqueue_size_counter}}{{enqueue_date}} {{total_ack_count}} {{total_nack_count}} {{ack_item_rate}} msgs/sec {{memory ack_size_rate}}/sec