activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1031633 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala
Date Fri, 05 Nov 2010 15:41:41 GMT
Author: chirino
Date: Fri Nov  5 15:41:40 2010
New Revision: 1031633

URL: http://svn.apache.org/viewvc?rev=1031633&view=rev
Log:
Better host-name configuration element support.  They are actually used.

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.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=1031633&r1=1031632&r2=1031633&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 Nov  5 15:41:40 2010
@@ -30,6 +30,7 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.ConcurrentHashMap
 import org.apache.activemq.apollo.util._
 import ReporterLevel._
+import collection.mutable.LinkedHashMap
 
 /**
  * <p>
@@ -167,9 +168,11 @@ class Broker() extends BaseService with 
 
   var config: BrokerDTO = defaultConfig
 
-  var dataDirectory: File = null
-  var defaultVirtualHost: VirtualHost = null
-  var virtualHosts: Map[AsciiBuffer, VirtualHost] = Map()
+  var data_directory: File = null
+  var default_virtual_host: VirtualHost = null
+  val virtual_hosts = LinkedHashMap[AsciiBuffer, VirtualHost]()
+  val virtual_hosts_by_hostname = new LinkedHashMap[AsciiBuffer, VirtualHost]()
+
   var connectors: List[Connector] = Nil
 
   val dispatchQueue = createQueue("broker");
@@ -206,15 +209,20 @@ class Broker() extends BaseService with 
 
     // create the runtime objects from the config
     {
-      dataDirectory = new File(config.basedir)
-      defaultVirtualHost = null
+      data_directory = new File(config.basedir)
+      default_virtual_host = null
       for (c <- config.virtual_hosts) {
         val host = new VirtualHost(this, virtual_host_id_counter.incrementAndGet)
         host.configure(c, this)
-        virtualHosts += ascii(c.id)-> host
+        virtual_hosts += ascii(c.id)-> host
         // first defined host is the default virtual host
-        if( defaultVirtualHost == null ) {
-          defaultVirtualHost = host
+        if( default_virtual_host == null ) {
+          default_virtual_host = host
+        }
+
+        // add all the host names of the virtual host to the virtual_hosts_by_hostname map..
+        c.host_names.foreach { name=>
+          virtual_hosts_by_hostname += ascii(name)->host
         }
       }
       for (c <- config.connectors) {
@@ -226,7 +234,7 @@ class Broker() extends BaseService with 
 
     // Start up the virtual hosts
     val tracker = new LoggingTracker("broker startup", dispatchQueue)
-    virtualHosts.valuesIterator.foreach( x=>
+    virtual_hosts.valuesIterator.foreach( x=>
       tracker.start(x)
     )
 
@@ -249,18 +257,18 @@ class Broker() extends BaseService with 
       tracker.stop(x)
     )
     // Shutdown the virtual host services
-    virtualHosts.valuesIterator.foreach( x=>
+    virtual_hosts.valuesIterator.foreach( x=>
       tracker.stop(x)
     )
     tracker.callback(onCompleted)
   }
 
   def getVirtualHost(name: AsciiBuffer) = dispatchQueue ! {
-    virtualHosts.getOrElse(name, null)
+    virtual_hosts_by_hostname.getOrElse(name, null)
   }
 
   def getDefaultVirtualHost = dispatchQueue ! {
-    defaultVirtualHost
+    default_virtual_host
   }
 
 }

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala?rev=1031633&r1=1031632&r2=1031633&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RuntimeResource.scala
Fri Nov  5 15:41:40 2010
@@ -53,7 +53,7 @@ case class RuntimeResource(parent:Broker
 
   private def with_virtual_host[T](id:Long)(func: (VirtualHost, Option[T]=>Unit)=>Unit):T
= {
     with_broker { case (broker, cb) =>
-      broker.virtualHosts.valuesIterator.find( _.id == id) match {
+      broker.virtual_hosts.valuesIterator.find( _.id == id) match {
         case Some(virtualHost)=>
           virtualHost.dispatchQueue {
             func(virtualHost, cb)
@@ -75,7 +75,7 @@ case class RuntimeResource(parent:Broker
       result.state_since = broker.serviceState.since
       result.config = broker.config
 
-      broker.virtualHosts.values.foreach{ host=>
+      broker.virtual_hosts.values.foreach{ host=>
         // TODO: may need to sync /w virtual host's dispatch queue
         result.virtual_hosts.add( new LongIdLabeledDTO(host.id, host.config.id) )
       }



Mime
View raw message