Skip to content

Commit

Permalink
URLEncode heartbeat sender child names
Browse files Browse the repository at this point in the history
* Names can be url encoded now, instead of MD5
  • Loading branch information
patriknw committed Oct 8, 2012
1 parent cecde67 commit 7557433
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions akka-cluster/src/main/scala/akka/cluster/ClusterHeartbeat.scala
Expand Up @@ -6,12 +6,12 @@ package akka.cluster
import language.postfixOps import language.postfixOps
import scala.collection.immutable.SortedSet import scala.collection.immutable.SortedSet
import akka.actor.{ ReceiveTimeout, ActorLogging, ActorRef, Address, Actor, RootActorPath, Props } import akka.actor.{ ReceiveTimeout, ActorLogging, ActorRef, Address, Actor, RootActorPath, Props }
import java.security.MessageDigest
import akka.pattern.{ CircuitBreaker, CircuitBreakerOpenException } import akka.pattern.{ CircuitBreaker, CircuitBreakerOpenException }
import scala.concurrent.util.duration._ import scala.concurrent.util.duration._
import scala.concurrent.util.Deadline import scala.concurrent.util.Deadline
import scala.concurrent.util.FiniteDuration import scala.concurrent.util.FiniteDuration
import akka.cluster.ClusterEvent._ import akka.cluster.ClusterEvent._
import java.net.URLEncoder


/** /**
* Sent at regular intervals for failure detection. * Sent at regular intervals for failure detection.
Expand Down Expand Up @@ -99,16 +99,10 @@ private[cluster] final class ClusterHeartbeatSender extends Actor with ActorLogg
def clusterHeartbeatConnectionFor(address: Address): ActorRef = def clusterHeartbeatConnectionFor(address: Address): ActorRef =
context.actorFor(RootActorPath(address) / "system" / "cluster" / "heartbeatReceiver") context.actorFor(RootActorPath(address) / "system" / "cluster" / "heartbeatReceiver")


val digester = MessageDigest.getInstance("MD5")

/** /**
* Child name is MD5 hash of the address. * Child name URL encoded target address.
* FIXME Change to URLEncode when ticket #2123 has been fixed
*/ */
def encodeChildName(name: String): String = { def encodeChildName(name: String): String = URLEncoder.encode(name, "UTF-8")
digester update name.getBytes("UTF-8")
digester.digest.map { h "%02x".format(0xFF & h) }.mkString
}


def receive = { def receive = {
case state: CurrentClusterState init(state) case state: CurrentClusterState init(state)
Expand Down

0 comments on commit 7557433

Please sign in to comment.