removed duplicated NodeAddress
This commit is contained in:
parent
96367d9575
commit
7f455fd92e
2 changed files with 3 additions and 39 deletions
|
|
@ -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é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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue