activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1349060 - in /activemq/activemq-apollo/trunk/apollo-network/src: main/resources/META-INF/services/org.apache.activemq.apollo/ main/resources/org/apache/activemq/apollo/broker/network/dto/ main/scala/org/apache/activemq/apollo/broker/networ...
Date Mon, 11 Jun 2012 22:51:00 GMT
Author: chirino
Date: Mon Jun 11 22:50:59 2012
New Revision: 1349060

URL: http://svn.apache.org/viewvc?rev=1349060&view=rev
Log:
Added a simple JVM level membership monitor so that test brokers can use dynamic ports even
in the test configurations.

Added:
    activemq/activemq-apollo/trunk/apollo-network/src/main/resources/META-INF/services/org.apache.activemq.apollo/cluster-membership-factory.index
      - copied, changed from r1348133, activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/MembershipMonitor.scala
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/JVMMembershipMonitorDTO.java
      - copied, changed from r1348133, activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/MembershipMonitorDTO.java
Removed:
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/ClusterMembershipMonitor.scala
Modified:
    activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/NetworkManager.scala
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterServiceDTO.java
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/Module.scala
    activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/NetworkManagerDTO.java
    activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-1.xml
    activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-2.xml

Copied: activemq/activemq-apollo/trunk/apollo-network/src/main/resources/META-INF/services/org.apache.activemq.apollo/cluster-membership-factory.index
(from r1348133, activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/resources/META-INF/services/org.apache.activemq.apollo/cluster-membership-factory.index?p2=activemq/activemq-apollo/trunk/apollo-network/src/main/resources/META-INF/services/org.apache.activemq.apollo/cluster-membership-factory.index&p1=activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index&r1=1348133&r2=1349060&rev=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/resources/META-INF/services/org.apache.activemq.apollo/cluster-membership-factory.index
Mon Jun 11 22:50:59 2012
@@ -14,5 +14,4 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
-NetworkManagerDTO
-BridgeDTO
\ No newline at end of file
+org.apache.activemq.apollo.broker.network.JVMMembershipMonitorFactory
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/resources/org/apache/activemq/apollo/broker/network/dto/jaxb.index
Mon Jun 11 22:50:59 2012
@@ -15,4 +15,6 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 NetworkManagerDTO
-BridgeDTO
\ No newline at end of file
+BridgeDTO
+MembershipMonitorDTO
+JVMMembershipMonitorDTO
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/MembershipMonitor.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/MembershipMonitor.scala?rev=1349060&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/MembershipMonitor.scala
(added)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/MembershipMonitor.scala
Mon Jun 11 22:50:59 2012
@@ -0,0 +1,164 @@
+/**
+ * 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.broker.network
+
+import dto.{MembershipMonitorDTO, NetworkManagerDTO, JVMMembershipMonitorDTO, ClusterMemberDTO}
+import org.fusesource.hawtdispatch._
+import org.apache.activemq.apollo.dto.{CustomServiceDTO, VirtualHostDTO}
+import java.util.concurrent.TimeUnit
+import org.apache.activemq.apollo.broker.{BrokerRegistry, Broker}
+import collection.mutable.HashSet
+import org.apache.activemq.apollo.util._
+
+trait MembershipMonitor extends Service {
+  var listener:MembershipListener = _
+}
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+object MembershipMonitorFactory {
+
+  trait SPI {
+    def create(broker:Broker, dto:MembershipMonitorDTO):MembershipMonitor
+  }
+
+  val finder = new ClassFinder[SPI]("META-INF/services/org.apache.activemq.apollo/cluster-membership-factory.index",classOf[SPI])
+
+  def create(broker:Broker, dto:MembershipMonitorDTO):MembershipMonitor = {
+    if( dto == null ) {
+      return null
+    }
+    finder.singletons.foreach { provider=>
+      val rc = provider.create(broker, dto)
+      if( rc!=null ) {
+        return rc;
+      }
+    }
+    return null
+  }
+}
+
+
+trait MembershipListener {
+  def on_membership_change(members:collection.Set[ClusterMemberDTO])
+}
+
+case class StaticMembershipMonitor(members:collection.Set[ClusterMemberDTO]) extends BaseService
with MembershipMonitor {
+  val dispatch_queue = createQueue("static cluster membership manager")
+  protected def _start(on_completed: Task) = {
+    dispatch_queue {
+      listener.on_membership_change(members)
+    }
+    on_completed.run()
+  }
+  protected def _stop(on_completed: Task) = {
+    on_completed.run()
+  }
+}
+
+object JVMMembershipMonitorFactory extends MembershipMonitorFactory.SPI {
+  def create(broker: Broker, dto: MembershipMonitorDTO): MembershipMonitor = dto match {
+    case dto:JVMMembershipMonitorDTO=> new JVMMembershipMonitor
+    case _ => null
+  }
+}
+
+class JVMMembershipMonitor extends BaseService with MembershipMonitor {
+  val dispatch_queue = createQueue("jvm cluster membership manager")
+  protected def _start(on_completed: Task) = {
+    schedule_reoccurring(1, TimeUnit.SECONDS) {
+      val brokers = HashSet[ClusterMemberDTO]()
+      for( broker <- BrokerRegistry.list() ) {
+        import collection.JavaConversions._
+        broker.config.services.foreach(_ match {
+          case x:NetworkManagerDTO=>
+            if(x.self!=null ) {
+              if(NetworkManager.has_variables(x.self.id)) {
+                for( host <- broker.virtual_hosts.values ) {
+                  var resolved = NetworkManager.resolve_variables(x.self, broker, host)
+                  if( !NetworkManager.has_variables(resolved) ) {
+                    brokers += resolved
+                  } else {
+                    println("not resolved")
+                  }
+                }
+              } else {
+                var resolved = NetworkManager.resolve_variables(x.self, broker, null)
+                if( !NetworkManager.has_variables(resolved) ) {
+                  brokers += resolved
+                } else {
+                  println("not resolved")
+                }
+              }
+            }
+          case _ =>
+        })
+      }
+      listener.on_membership_change(brokers)
+    }
+    on_completed.run()
+  }
+
+  protected def _stop(on_completed: Task) = on_completed.run()
+}
+
+case class MulitMonitor(monitors:Seq[MembershipMonitor]) extends BaseService with MembershipMonitor
{
+
+  val dispatch_queue = createQueue("static cluster membership manager")
+
+  case class MonitorData(monitor:MembershipMonitor) {
+    var last:collection.Set[ClusterMemberDTO] = HashSet[ClusterMemberDTO]();
+  }
+  
+  val monitor_data = monitors.map(MonitorData(_))
+
+  protected def _start(on_completed: Task) = {
+    val tracker = new LoggingTracker("membership monitor start")
+    for( data <- monitor_data ) {
+      data.monitor.listener = new MembershipListener {
+        def on_membership_change(members: collection.Set[ClusterMemberDTO]) = dispatch_queue
{
+          if( data.last != members ) {
+            data.last = members
+            fire_changes
+          }
+        }
+      }
+      tracker.start(data.monitor)
+    }
+    tracker.callback(on_completed)
+  }
+
+  def fire_changes = {
+    val members = HashSet[ClusterMemberDTO]()
+    monitor_data.foreach(x=> members ++= x.last )
+    listener.on_membership_change(members)
+  }
+
+  protected def _stop(on_completed: Task) = {
+    val tracker = new LoggingTracker("membership monitor stop")
+    for( data <- monitor_data ) {
+      tracker.stop(data.monitor)
+    }
+    tracker.callback(^{
+      on_completed.run()
+    })
+  }
+}
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/NetworkManager.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/NetworkManager.scala?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/NetworkManager.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/NetworkManager.scala
Mon Jun 11 22:50:59 2012
@@ -22,8 +22,9 @@ import org.apache.activemq.apollo.broker
 import CollectionsSupport._
 import java.util.concurrent.TimeUnit._
 import collection.mutable.{LinkedHashMap, HashSet, ListBuffer, HashMap}
-import org.apache.activemq.apollo.broker.{Broker, CustomServiceFactory}
 import org.apache.activemq.apollo.dto.{LoadStatusDTO, CustomServiceDTO}
+import org.apache.activemq.apollo.broker.{AcceptingConnector, VirtualHost, Broker, CustomServiceFactory}
+import java.net.InetSocketAddress
 
 /**
  * <p>
@@ -41,16 +42,60 @@ object NetworkManagerFactory extends Cus
   }
 }
 
-object NetworkManager extends Log
+object NetworkManager extends Log {
+  
+  def has_variables(x:String) = x.contains("{{"):Boolean
 
-class NetworkManager(broker: Broker) extends BaseService with ClusterMembershipListener with
BrokerLoadListener {
+  def has_variables(dto:ClusterMemberDTO):Boolean = {
+    import collection.JavaConversions._
+    has_variables(dto.id) || dto.services.foldLeft(false){ case (x,y) =>
+      x || has_variables(y.address)
+    }
+  }
+  
+  def resolve_variables(dto:ClusterMemberDTO, broker:Broker, host:VirtualHost):ClusterMemberDTO
= {
+    import collection.JavaConversions._
+    def resolve(x:String) = if( !x.contains("{{") ) { x } else {
+      var rc = x;
+      if( host!=null ) {
+        rc = rc.replaceAllLiterally("{{host}}", host.id)
+      }
+      if( broker.web_server!=null && broker.web_server.uris()!=null && !broker.web_server.uris().isEmpty)
{
+        rc = rc.replaceAllLiterally("{{web_admin.url}}", broker.web_server.uris()(0).toString.stripSuffix("/"))
+      }
+      for( (id, connector) <- broker.connectors ) {
+        connector match {
+          case connector:AcceptingConnector =>
+            connector.socket_address match {
+              case address:InetSocketAddress =>
+                rc = rc.replaceAllLiterally("{{connector."+id+".port}}", ""+address.getPort)
+            }
+          case _ =>
+        }
+      }
+      rc
+    }
+
+    val rc = new ClusterMemberDTO
+    rc.id = resolve(dto.id)
+    for( service <- dto.services) {
+      val s = new ClusterServiceDTO
+      s.kind = service.kind
+      s.address = resolve(service.address)
+      rc.services.add(s)
+    }
+    rc
+  }
+}
+
+class NetworkManager(broker: Broker) extends BaseService with MembershipListener with BrokerLoadListener
{
   import NetworkManager._
 
   val dispatch_queue = createQueue("bridge manager")
 
   var config = new NetworkManagerDTO
-  var membership_monitor:ClusterMembershipMonitor = _
-  var members = Set[ClusterMemberDTO]()
+  var membership_monitor:MembershipMonitor = _
+  var members = collection.Set[ClusterMemberDTO]()
   var members_by_id = HashMap[String, ClusterMemberDTO]()
   var load_monitor: BrokerLoadMonitor = _
   var metrics_map = HashMap[String, BrokerMetrics]()
@@ -64,8 +109,22 @@ class NetworkManager(broker: Broker) ext
     import collection.JavaConversions._
 
     // TODO: also support dynamic membership discovery..
-    membership_monitor = StaticClusterMembershipMonitor(config.members.toSet)
+    var monitors = List[MembershipMonitor]()
+    var static_set = config.members.toSet
+    if( !has_variables(config.self) ) {
+      static_set += config.self
+    }
+
+    monitors ::= StaticMembershipMonitor(static_set)
+
+    for( monitor_dto <- config.membership_monitors ) {
+      var monitor = MembershipMonitorFactory.create(broker, monitor_dto)
+      if(monitor!=null) {
+        monitors ::= monitor
+      }
+    }
 
+    membership_monitor = MulitMonitor(monitors)
     membership_monitor.listener = this
     membership_monitor.start(NOOP)
 
@@ -84,7 +143,7 @@ class NetworkManager(broker: Broker) ext
     on_completed.run()
   }
 
-  def on_cluster_change(value: Set[ClusterMemberDTO]) = dispatch_queue {
+  def on_membership_change(value: collection.Set[ClusterMemberDTO]) = dispatch_queue {
     val (added, _, removed) = diff(members, value)
     for( m <- removed ) {
       load_monitor.remove(m)
@@ -157,11 +216,21 @@ class NetworkManager(broker: Broker) ext
 
   }
 
-  def local_broker_id = config.self
+  def is_local_broker_id(id:String):Boolean = {
+    if( has_variables(config.self.id) ) {
+      for( host <- broker.virtual_hosts.values ) {
+        if( config.self.id.replaceAllLiterally("{{host}}", host.id) == id )
+          return true
+      }
+      false
+    } else {
+      config.self.id == id
+    }
+  }
 
-  def can_bridge_from(broker:String):Boolean = broker==local_broker_id
+  def can_bridge_from(broker:String):Boolean = is_local_broker_id(broker)
   def can_bridge_to(broker:String):Boolean = {
-    if ( broker == local_broker_id) {
+    if ( is_local_broker_id(broker) ) {
       OptionSupport(config.duplex).getOrElse(false)
     } else {
       true

Modified: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java
Mon Jun 11 22:50:59 2012
@@ -34,4 +34,24 @@ public class ClusterMemberDTO {
     @XmlElement(name="service")
     public ArrayList<ClusterServiceDTO> services = new ArrayList<ClusterServiceDTO>();
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ClusterMemberDTO)) return false;
+
+        ClusterMemberDTO that = (ClusterMemberDTO) o;
+
+        if (id != null ? !id.equals(that.id) : that.id != null) return false;
+        if (services != null ? !services.equals(that.services) : that.services != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = id != null ? id.hashCode() : 0;
+        result = 31 * result + (services != null ? services.hashCode() : 0);
+        return result;
+    }
 }

Modified: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterServiceDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterServiceDTO.java?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterServiceDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterServiceDTO.java
Mon Jun 11 22:50:59 2012
@@ -37,4 +37,25 @@ public class ClusterServiceDTO {
     @XmlAttribute(name="address")
     public String address;
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof ClusterServiceDTO)) return false;
+
+        ClusterServiceDTO that = (ClusterServiceDTO) o;
+
+        if (address != null ? !address.equals(that.address) : that.address != null)
+            return false;
+        if (kind != null ? !kind.equals(that.kind) : that.kind != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = kind != null ? kind.hashCode() : 0;
+        result = 31 * result + (address != null ? address.hashCode() : 0);
+        return result;
+    }
 }

Copied: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/JVMMembershipMonitorDTO.java
(from r1348133, activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/JVMMembershipMonitorDTO.java?p2=activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/JVMMembershipMonitorDTO.java&p1=activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java&r1=1348133&r2=1349060&rev=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/ClusterMemberDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/JVMMembershipMonitorDTO.java
Mon Jun 11 22:50:59 2012
@@ -19,19 +19,12 @@ package org.apache.activemq.apollo.broke
 import org.codehaus.jackson.annotate.JsonIgnoreProperties;
 
 import javax.xml.bind.annotation.*;
-import java.util.ArrayList;
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
+@XmlRootElement(name="jvm_membership")
 @XmlAccessorType(XmlAccessType.FIELD)
 @JsonIgnoreProperties(ignoreUnknown = true)
-public class ClusterMemberDTO {
-
-    @XmlAttribute(name="id")
-    public String id;
-
-    @XmlElement(name="service")
-    public ArrayList<ClusterServiceDTO> services = new ArrayList<ClusterServiceDTO>();
-
+public class JVMMembershipMonitorDTO extends MembershipMonitorDTO {
 }

Added: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/MembershipMonitorDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/MembershipMonitorDTO.java?rev=1349060&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/MembershipMonitorDTO.java
(added)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/MembershipMonitorDTO.java
Mon Jun 11 22:50:59 2012
@@ -0,0 +1,30 @@
+package org.apache.activemq.apollo.broker.network.dto;
+
+import org.apache.activemq.apollo.dto.ApolloTypeIdResolver;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonTypeInfo;
+import org.codehaus.jackson.map.annotate.JsonTypeIdResolver;
+
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+@XmlType(name = "membership_monitor_type")
+@JsonTypeInfo(use=JsonTypeInfo.Id.CUSTOM, include=JsonTypeInfo.As.PROPERTY, property="@class")
+@JsonTypeIdResolver(ApolloTypeIdResolver.class)
+@JsonIgnoreProperties(ignoreUnknown = true)
+abstract public class MembershipMonitorDTO {
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof MembershipMonitorDTO)) return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return 0;
+    }
+}
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/Module.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/Module.scala?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/Module.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/Module.scala
Mon Jun 11 22:50:59 2012
@@ -24,6 +24,9 @@ import org.apache.activemq.apollo.util.D
 class Module extends DtoModule {
 
   def dto_package = "org.apache.activemq.apollo.broker.network.dto"
-  def extension_classes = Array(classOf[NetworkManagerDTO])
+  def extension_classes = Array(
+    classOf[NetworkManagerDTO],
+    classOf[JVMMembershipMonitorDTO]
+  )
 
 }
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/NetworkManagerDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/NetworkManagerDTO.java?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/NetworkManagerDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/main/scala/org/apache/activemq/apollo/broker/network/dto/NetworkManagerDTO.java
Mon Jun 11 22:50:59 2012
@@ -17,7 +17,6 @@
 package org.apache.activemq.apollo.broker.network.dto;
 
 import org.apache.activemq.apollo.dto.CustomServiceDTO;
-import org.apache.activemq.apollo.dto.ServiceDTO;
 import org.codehaus.jackson.annotate.JsonIgnoreProperties;
 
 import javax.xml.bind.annotation.*;
@@ -37,15 +36,54 @@ public class NetworkManagerDTO extends C
     @XmlAttribute(name="password")
     public String password;
 
-    @XmlAttribute(name="self")
-    public String self;
-
     @XmlAttribute(name="duplex")
     public Boolean duplex;
 
     @XmlAttribute(name="monitoring_interval")
     public Integer monitoring_interval;
 
+    @XmlElement(name="self")
+    public ClusterMemberDTO self = null;
+
     @XmlElement(name="member")
     public ArrayList<ClusterMemberDTO> members = new ArrayList<ClusterMemberDTO>();
+
+    @XmlElementRef()
+    public ArrayList<MembershipMonitorDTO> membership_monitors = new ArrayList<MembershipMonitorDTO>();
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (!(o instanceof NetworkManagerDTO)) return false;
+        if (!super.equals(o)) return false;
+
+        NetworkManagerDTO that = (NetworkManagerDTO) o;
+
+        if (duplex != null ? !duplex.equals(that.duplex) : that.duplex != null)
+            return false;
+        if (members != null ? !members.equals(that.members) : that.members != null)
+            return false;
+        if (monitoring_interval != null ? !monitoring_interval.equals(that.monitoring_interval)
: that.monitoring_interval != null)
+            return false;
+        if (password != null ? !password.equals(that.password) : that.password != null)
+            return false;
+        if (self != null ? !self.equals(that.self) : that.self != null)
+            return false;
+        if (user != null ? !user.equals(that.user) : that.user != null)
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = super.hashCode();
+        result = 31 * result + (user != null ? user.hashCode() : 0);
+        result = 31 * result + (password != null ? password.hashCode() : 0);
+        result = 31 * result + (self != null ? self.hashCode() : 0);
+        result = 31 * result + (duplex != null ? duplex.hashCode() : 0);
+        result = 31 * result + (monitoring_interval != null ? monitoring_interval.hashCode()
: 0);
+        result = 31 * result + (members != null ? members.hashCode() : 0);
+        return result;
+    }
 }

Modified: activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-1.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-1.xml?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-1.xml
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-1.xml
Mon Jun 11 22:50:59 2012
@@ -22,19 +22,15 @@
     <host_name>localhost</host_name>
   </virtual_host>
 
-  <!-- once we get dynamic discovery working we can avoid using fixed ports -->
-  <web_admin bind="http://0.0.0.0:41000"/>
-  <connector id="tcp" bind="tcp://0.0.0.0:41001"/>
+  <web_admin bind="http://0.0.0.0:0"/>
+  <connector id="tcp" bind="tcp://0.0.0.0:0"/>
 
-  <network_manager self="broker1">
-    <member id="broker1">
-      <service kind="web_admin" address="http://0.0.0.0:41000/api/json/broker/virtual-hosts/broker1/load-status"/>
-      <service kind="stomp" address="tcp://0.0.0.0:41001"/>
-    </member>
-    <member id="broker2">
-      <service kind="web_admin" address="http://0.0.0.0:42000/api/json/broker/virtual-hosts/broker2/load-status"/>
-      <service kind="stomp" address="tcp://0.0.0.0:42001"/>
-    </member>
+  <network_manager>
+    <self id="{{host}}">
+      <service kind="web_admin" address="{{web_admin.url}}/api/json/broker/virtual-hosts/{{host}}/load-status"/>
+      <service kind="stomp" address="tcp://0.0.0.0:{{connector.tcp.port}}"/>
+    </self>
+    <jvm_membership/>
   </network_manager>
 
 </broker>
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-2.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-2.xml?rev=1349060&r1=1349059&r2=1349060&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-2.xml
(original)
+++ activemq/activemq-apollo/trunk/apollo-network/src/test/resources/apollo-network-2.xml
Mon Jun 11 22:50:59 2012
@@ -22,19 +22,15 @@
     <host_name>localhost</host_name>
   </virtual_host>
 
-  <!-- once we get dynamic discovery working we can avoid using fixed ports -->
-  <web_admin bind="http://0.0.0.0:42000"/>
-  <connector id="tcp" bind="tcp://0.0.0.0:42001"/>
+  <web_admin bind="http://0.0.0.0:0"/>
+  <connector id="tcp" bind="tcp://0.0.0.0:0"/>
 
   <network_manager self="broker2">
-    <member id="broker1">
-      <service kind="web_admin" address="http://0.0.0.0:41000/api/json/broker/virtual-hosts/broker1/load-status"/>
-      <service kind="stomp" address="tcp://0.0.0.0:41001"/>
-    </member>
-    <member id="broker2">
-      <service kind="web_admin" address="http://0.0.0.0:42000/api/json/broker/virtual-hosts/broker2/load-status"/>
-      <service kind="stomp" address="tcp://0.0.0.0:42001"/>
-    </member>
+    <self id="{{host}}">
+      <service kind="web_admin" address="{{web_admin.url}}/api/json/broker/virtual-hosts/{{host}}/load-status"/>
+      <service kind="stomp" address="tcp://0.0.0.0:{{connector.tcp.port}}"/>
+    </self>
+    <jvm_membership/>
   </network_manager>
 
 </broker>
\ No newline at end of file



Mime
View raw message