removed duplicated NodeAddress

This commit is contained in:
Jonas Bonér 2011-05-23 23:48:25 +02:00
parent 96367d9575
commit 7f455fd92e
2 changed files with 3 additions and 39 deletions

View file

@ -10,6 +10,7 @@ import akka.actor._
import akka.dispatch.Future
import akka.config.Config
import akka.util._
import akka.AkkaException
import com.eaio.uuid.UUID
@ -20,6 +21,8 @@ import java.util.concurrent.{ ConcurrentSkipListSet, ConcurrentHashMap }
import scala.collection.mutable.ConcurrentMap
import scala.collection.JavaConversions._
class ClusterException(message: String) extends AkkaException(message)
object ChangeListener {
/**

View file

@ -48,45 +48,6 @@ import java.util.{ List ⇒ JList }
// FIXME add watch for each node that when the entry for the node is removed then the node shuts itself down
// FIXME Provisioning data in ZK (file names etc) and files in S3 and on disk
class ClusterException(message: String) extends AkkaException(message)
/**
* Node address holds the node name and the cluster name and can be used as a hash lookup key for a Node instance.
*
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
class NodeAddress(
val clusterName: String,
val nodeName: String,
val hostname: String,
val port: Int) {
if ((hostname eq null) || hostname == "") throw new NullPointerException("Host name must not be null or empty string")
if ((nodeName eq null) || nodeName == "") throw new NullPointerException("Node name must not be null or empty string")
if ((clusterName eq null) || clusterName == "") throw new NullPointerException("Cluster name must not be null or empty string")
if (port < 1) throw new NullPointerException("Port can not be negative")
override def toString = "%s:%s:%s:%s".format(clusterName, nodeName, hostname, port)
override def hashCode = 0 + clusterName.## + nodeName.## + hostname.## + port.##
override def equals(other: Any) = NodeAddress.unapply(this) == NodeAddress.unapply(other)
}
object NodeAddress {
def apply(
clusterName: String = Cluster.name,
nodeName: String = Config.nodename,
hostname: String = Config.hostname,
port: Int = Config.remoteServerPort): NodeAddress =
new NodeAddress(clusterName, nodeName, hostname, port)
def unapply(other: Any) = other match {
case address: NodeAddress Some((address.clusterName, address.nodeName, address.hostname, address.port))
case _ None
}
}
/**
* JMX MBean for the cluster service.
*