You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2012/02/01 17:22:58 UTC

svn commit: r1239193 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/ apollo-util/src/main/scala/org/apache/activemq/apollo/util/ apollo-web/src/main/scala/org/apache/activemq/apollo/web/resour...

Author: chirino
Date: Wed Feb  1 16:22:58 2012
New Revision: 1239193

URL: http://svn.apache.org/viewvc?rev=1239193&view=rev
Log:
Fixes APLO-147: Error browsing destinations related pages via the web console

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/WebSocketTransportFactory.scala
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/WebSocketTransportFactory.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/WebSocketTransportFactory.scala?rev=1239193&r1=1239192&r2=1239193&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/WebSocketTransportFactory.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/jetty/WebSocketTransportFactory.scala Wed Feb  1 16:22:58 2012
@@ -221,6 +221,12 @@ object WebSocketTransportFactory extends
       inbound_dispatch_queue.suspend();
       drain_outbound_events.setTargetQueue(dispatchQueue)
       transportListener.onTransportConnected();
+
+      inbound.synchronized {
+        inbound_capacity_remaining = 1024*64
+        inbound.notify();
+      }
+
       on_completed.run()
     }
   
@@ -275,10 +281,10 @@ object WebSocketTransportFactory extends
       onMessage(buffer.data, buffer.offset, buffer.length)
     }
 
-    var inbound_capacity_remaining = 1024 * 64;
+    var inbound_capacity_remaining = 0;
     val inbound = ListBuffer[Buffer]()
 
-    var inbound_dispatch_queue = dispatchQueue
+    var inbound_dispatch_queue:DispatchQueue = _
 
     def resumeRead() = {
       inbound_dispatch_queue.resume()
@@ -292,7 +298,7 @@ object WebSocketTransportFactory extends
     def onMessage(data: Array[Byte], offset: Int, length: Int): Unit = {
       inbound.synchronized {
         // flow control check..
-        while (inbound_capacity_remaining <= 0 && service_state.is_started) {
+        while (inbound_capacity_remaining <= 0 && service_state.is_upward ) {
           inbound.wait();
         }
         inbound_capacity_remaining -= length;
@@ -360,7 +366,7 @@ object WebSocketTransportFactory extends
 
   
     protected def drain_inbound: Unit = {
-      dispatch_queue.assertExecuting()
+      inbound_dispatch_queue.assertExecuting()
       try {
         //        var initial = protocolCodec.getReadCounter
         //        while (codec.getReadCounter - initial < codec.getReadBufferSize << 2) {

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala?rev=1239193&r1=1239192&r2=1239193&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/BaseService.scala Wed Feb  1 16:22:58 2012
@@ -41,12 +41,14 @@ trait BaseService extends Service with D
     def is_created = false
     def is_starting = false
     def is_started = false
+    def is_upward = is_started | is_starting | is_created
 
     def is_starting_or_started = is_starting | is_started
 
     def is_stopping = false
     def is_stopped= false
     def is_failed= false
+    def is_downward = is_stopped | is_stopping | is_failed
   }
 
   protected class CREATED extends State { override def is_created = true  }

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala?rev=1239193&r1=1239192&r2=1239193&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala Wed Feb  1 16:22:58 2012
@@ -33,6 +33,7 @@ import org.apache.activemq.apollo.util._
 import java.net.{InetSocketAddress, URI}
 import java.security.cert.X509Certificate
 import org.apache.activemq.apollo.dto.ErrorDTO
+import org.fusesource.hawtdispatch._
 
 object Resource extends Log {
 
@@ -112,7 +113,7 @@ abstract class Resource(parent:Resource=
   }
 
 
-  def authorize[T](authenticator:Authenticator, authorizer:Authorizer, action:String, resource:SecuredResource, block: =>FutureResult[T]):FutureResult[T] = {
+  def authorize[T](authenticator:Authenticator, authorizer:Authorizer, action:String, resource:SecuredResource)(block: =>FutureResult[T]):FutureResult[T] = {
     if ( authenticator != null ) {
       val rc = FutureResult[T]()
       authenticate(authenticator) { security_context =>
@@ -138,36 +139,72 @@ abstract class Resource(parent:Resource=
   }
 
   protected def monitoring[T](broker:Broker)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(broker.authenticator, broker.authorizer, "monitor", broker, func)
+    authorize(broker.authenticator, broker.authorizer, "monitor", broker) {
+      broker.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
 
   protected def admining[T](broker:Broker)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(broker.authenticator, broker.authorizer, "admin", broker, func)
+    authorize(broker.authenticator, broker.authorizer, "admin", broker) {
+      broker.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
 
   protected def configing[T](broker:Broker)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(broker.authenticator, broker.authorizer, "config", broker, func)
+    authorize(broker.authenticator, broker.authorizer, "config", broker) {
+      broker.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
 
   protected def admining[T](host:VirtualHost)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(host.authenticator, host.authorizer, "admin", host, func)
+    authorize(host.authenticator, host.authorizer, "admin", host) {
+      host.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
   protected def monitoring[T](host:VirtualHost)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(host.authenticator, host.authorizer, "monitor", host, func)
+    authorize(host.authenticator, host.authorizer, "monitor", host){
+      host.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
 
   protected def admining[T](dest:Queue)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer, "admin", dest, func)
+    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer, "admin", dest) {
+      dest.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
   protected def monitoring[T](dest:Queue)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer, "monitor", dest, func)
+    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer, "monitor", dest){
+      dest.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
 
   protected def admining[T](dest:Topic)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer,"admin", dest, func)
+    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer,"admin", dest) {
+      dest.virtual_host.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
   protected def monitoring[T](dest:Topic)(func: =>FutureResult[T]):FutureResult[T] = {
-    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer, "monitor", dest, func)
+    authorize(dest.virtual_host.authenticator, dest.virtual_host.authorizer, "monitor", dest) {
+      dest.virtual_host.dispatch_queue.flatFuture {
+        func
+      }
+    }
   }
 
   protected def authenticate[T](authenticator:Authenticator)(func: (SecurityContext)=>Unit): Unit = {