Fixing all %s into {} for logging
This commit is contained in:
parent
08abc15e8a
commit
bc1ae7814b
24 changed files with 101 additions and 97 deletions
|
|
@ -358,7 +358,7 @@ trait Actor extends Logging {
|
||||||
* log.slf4j.info("got a 'OneWay' message")
|
* log.slf4j.info("got a 'OneWay' message")
|
||||||
*
|
*
|
||||||
* case unknown =>
|
* case unknown =>
|
||||||
* log.slf4j.warn("unknown message [%s], ignoring", unknown)
|
* log.slf4j.warn("unknown message [{}], ignoring", unknown)
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -578,7 +578,7 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal
|
||||||
protected[akka] def checkReceiveTimeout = {
|
protected[akka] def checkReceiveTimeout = {
|
||||||
cancelReceiveTimeout
|
cancelReceiveTimeout
|
||||||
if (receiveTimeout.isDefined && dispatcher.mailboxSize(this) <= 0) { //Only reschedule if desired and there are currently no more messages to be processed
|
if (receiveTimeout.isDefined && dispatcher.mailboxSize(this) <= 0) { //Only reschedule if desired and there are currently no more messages to be processed
|
||||||
log.slf4j.debug("Scheduling timeout for %s", this)
|
log.slf4j.debug("Scheduling timeout for {}", this)
|
||||||
_futureTimeout = Some(Scheduler.scheduleOnce(this, ReceiveTimeout, receiveTimeout.get, TimeUnit.MILLISECONDS))
|
_futureTimeout = Some(Scheduler.scheduleOnce(this, ReceiveTimeout, receiveTimeout.get, TimeUnit.MILLISECONDS))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -587,7 +587,7 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal
|
||||||
if (_futureTimeout.isDefined) {
|
if (_futureTimeout.isDefined) {
|
||||||
_futureTimeout.get.cancel(true)
|
_futureTimeout.get.cancel(true)
|
||||||
_futureTimeout = None
|
_futureTimeout = None
|
||||||
log.slf4j.debug("Timeout canceled for %s", this)
|
log.slf4j.debug("Timeout canceled for {}", this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -764,7 +764,7 @@ class LocalActorRef private[akka] (
|
||||||
"Actor can only have one supervisor [" + actorRef + "], e.g. link(actor) fails")
|
"Actor can only have one supervisor [" + actorRef + "], e.g. link(actor) fails")
|
||||||
linkedActors.put(actorRef.uuid, actorRef)
|
linkedActors.put(actorRef.uuid, actorRef)
|
||||||
actorRef.supervisor = Some(this)
|
actorRef.supervisor = Some(this)
|
||||||
Actor.log.slf4j.debug("Linking actor [%s] to actor [%s]", actorRef, this)
|
Actor.log.slf4j.debug("Linking actor [{}] to actor [{}]", actorRef, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -777,7 +777,7 @@ class LocalActorRef private[akka] (
|
||||||
"Actor [" + actorRef + "] is not a linked actor, can't unlink")
|
"Actor [" + actorRef + "] is not a linked actor, can't unlink")
|
||||||
linkedActors.remove(actorRef.uuid)
|
linkedActors.remove(actorRef.uuid)
|
||||||
actorRef.supervisor = None
|
actorRef.supervisor = None
|
||||||
Actor.log.slf4j.debug("Unlinking actor [%s] from actor [%s]", actorRef, this)
|
Actor.log.slf4j.debug("Unlinking actor [{}] from actor [{}]", actorRef, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -911,14 +911,14 @@ class LocalActorRef private[akka] (
|
||||||
* Callback for the dispatcher. This is the single entry point to the user Actor implementation.
|
* Callback for the dispatcher. This is the single entry point to the user Actor implementation.
|
||||||
*/
|
*/
|
||||||
protected[akka] def invoke(messageHandle: MessageInvocation): Unit = guard.withGuard {
|
protected[akka] def invoke(messageHandle: MessageInvocation): Unit = guard.withGuard {
|
||||||
if (isShutdown) Actor.log.slf4j.warn("Actor [%s] is shut down,\n\tignoring message [%s]", toString, messageHandle)
|
if (isShutdown) Actor.log.slf4j.warn("Actor [{}] is shut down,\n\tignoring message [{}]", toString, messageHandle)
|
||||||
else {
|
else {
|
||||||
currentMessage = messageHandle
|
currentMessage = messageHandle
|
||||||
try {
|
try {
|
||||||
dispatch(messageHandle)
|
dispatch(messageHandle)
|
||||||
} catch {
|
} catch {
|
||||||
case e =>
|
case e =>
|
||||||
Actor.log.slf4j.error("Could not invoke actor [%s]", this)
|
Actor.log.slf4j.error("Could not invoke actor [{}]", this)
|
||||||
Actor.log.slf4j.error("Problem", e)
|
Actor.log.slf4j.error("Problem", e)
|
||||||
throw e
|
throw e
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -973,9 +973,9 @@ class LocalActorRef private[akka] (
|
||||||
protected[akka] def restart(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]) {
|
protected[akka] def restart(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]) {
|
||||||
|
|
||||||
def performRestart {
|
def performRestart {
|
||||||
Actor.log.slf4j.info("Restarting actor [%s] configured as PERMANENT.", id)
|
Actor.log.slf4j.info("Restarting actor [{}] configured as PERMANENT.", id)
|
||||||
val failedActor = actorInstance.get
|
val failedActor = actorInstance.get
|
||||||
Actor.log.slf4j.debug("Invoking 'preRestart' for failed actor instance [%s].", id)
|
Actor.log.slf4j.debug("Invoking 'preRestart' for failed actor instance [{}].", id)
|
||||||
failedActor.preRestart(reason)
|
failedActor.preRestart(reason)
|
||||||
val freshActor = newActor
|
val freshActor = newActor
|
||||||
setActorSelfFields(failedActor,null) //Only null out the references if we could instantiate the new actor
|
setActorSelfFields(failedActor,null) //Only null out the references if we could instantiate the new actor
|
||||||
|
|
@ -985,16 +985,16 @@ class LocalActorRef private[akka] (
|
||||||
case p: Proxyable => p.swapProxiedActor(freshActor)
|
case p: Proxyable => p.swapProxiedActor(freshActor)
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
Actor.log.slf4j.debug("Invoking 'postRestart' for new actor instance [%s].", id)
|
Actor.log.slf4j.debug("Invoking 'postRestart' for new actor instance [{}].", id)
|
||||||
freshActor.postRestart(reason)
|
freshActor.postRestart(reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
def tooManyRestarts {
|
def tooManyRestarts {
|
||||||
Actor.log.slf4j.warn(
|
Actor.log.slf4j.warn(
|
||||||
"Maximum number of restarts [%s] within time range [%s] reached." +
|
"Maximum number of restarts [{}] within time range [{}] reached." +
|
||||||
"\n\tWill *not* restart actor [%s] anymore." +
|
"\n\tWill *not* restart actor [{}] anymore." +
|
||||||
"\n\tLast exception causing restart was" +
|
"\n\tLast exception causing restart was" +
|
||||||
"\n\t[%s].",
|
"\n\t[{}].",
|
||||||
Array(maxNrOfRetries, withinTimeRange, this, reason))
|
Array(maxNrOfRetries, withinTimeRange, this, reason))
|
||||||
_supervisor.foreach { sup =>
|
_supervisor.foreach { sup =>
|
||||||
// can supervisor handle the notification?
|
// can supervisor handle the notification?
|
||||||
|
|
@ -1002,7 +1002,7 @@ class LocalActorRef private[akka] (
|
||||||
if (sup.isDefinedAt(notification)) notifySupervisorWithMessage(notification)
|
if (sup.isDefinedAt(notification)) notifySupervisorWithMessage(notification)
|
||||||
else Actor.log.slf4j.warn(
|
else Actor.log.slf4j.warn(
|
||||||
"No message handler defined for system message [MaximumNumberOfRestartsWithinTimeRangeReached]" +
|
"No message handler defined for system message [MaximumNumberOfRestartsWithinTimeRangeReached]" +
|
||||||
"\n\tCan't send the message to the supervisor [%s].", sup)
|
"\n\tCan't send the message to the supervisor [{}].", sup)
|
||||||
}
|
}
|
||||||
|
|
||||||
stop
|
stop
|
||||||
|
|
@ -1025,7 +1025,7 @@ class LocalActorRef private[akka] (
|
||||||
case e => false //An error or exception here should trigger a retry
|
case e => false //An error or exception here should trigger a retry
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor.log.slf4j.debug("Restart: %s for [%s].", success, id)
|
Actor.log.slf4j.debug("Restart: {} for [{}].", success, id)
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
_status = ActorRefInternals.RUNNING
|
_status = ActorRefInternals.RUNNING
|
||||||
|
|
@ -1080,7 +1080,7 @@ class LocalActorRef private[akka] (
|
||||||
}
|
}
|
||||||
|
|
||||||
private def dispatch[T](messageHandle: MessageInvocation) = {
|
private def dispatch[T](messageHandle: MessageInvocation) = {
|
||||||
Actor.log.slf4j.trace("Invoking actor with message: %s\n", messageHandle)
|
Actor.log.slf4j.trace("Invoking actor with message: {}\n", messageHandle)
|
||||||
val message = messageHandle.message //serializeMessage(messageHandle.message)
|
val message = messageHandle.message //serializeMessage(messageHandle.message)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -1096,14 +1096,14 @@ class LocalActorRef private[akka] (
|
||||||
}
|
}
|
||||||
|
|
||||||
private def shutDownTemporaryActor(temporaryActor: ActorRef) {
|
private def shutDownTemporaryActor(temporaryActor: ActorRef) {
|
||||||
Actor.log.slf4j.info("Actor [%s] configured as TEMPORARY and will not be restarted.", temporaryActor.id)
|
Actor.log.slf4j.info("Actor [{}] configured as TEMPORARY and will not be restarted.", temporaryActor.id)
|
||||||
temporaryActor.stop
|
temporaryActor.stop
|
||||||
linkedActors.remove(temporaryActor.uuid) // remove the temporary actor
|
linkedActors.remove(temporaryActor.uuid) // remove the temporary actor
|
||||||
// if last temporary actor is gone, then unlink me from supervisor
|
// if last temporary actor is gone, then unlink me from supervisor
|
||||||
if (linkedActors.isEmpty) {
|
if (linkedActors.isEmpty) {
|
||||||
Actor.log.slf4j.info(
|
Actor.log.slf4j.info(
|
||||||
"All linked actors have died permanently (they were all configured as TEMPORARY)" +
|
"All linked actors have died permanently (they were all configured as TEMPORARY)" +
|
||||||
"\n\tshutting down and unlinking supervisor actor as well [%s].",
|
"\n\tshutting down and unlinking supervisor actor as well [{}].",
|
||||||
temporaryActor.id)
|
temporaryActor.id)
|
||||||
notifySupervisorWithMessage(UnlinkAndStop(this))
|
notifySupervisorWithMessage(UnlinkAndStop(this))
|
||||||
}
|
}
|
||||||
|
|
@ -1112,7 +1112,7 @@ class LocalActorRef private[akka] (
|
||||||
}
|
}
|
||||||
|
|
||||||
private def handleExceptionInDispatch(reason: Throwable, message: Any) = {
|
private def handleExceptionInDispatch(reason: Throwable, message: Any) = {
|
||||||
Actor.log.slf4j.error("Exception when invoking \n\tactor [%s] \n\twith message [%s]", this, message)
|
Actor.log.slf4j.error("Exception when invoking \n\tactor [{}] \n\twith message [{}]", this, message)
|
||||||
Actor.log.slf4j.error("Problem", reason)
|
Actor.log.slf4j.error("Problem", reason)
|
||||||
|
|
||||||
//Prevent any further messages to be processed until the actor has been restarted
|
//Prevent any further messages to be processed until the actor has been restarted
|
||||||
|
|
@ -1170,7 +1170,7 @@ class LocalActorRef private[akka] (
|
||||||
|
|
||||||
private def initializeActorInstance = {
|
private def initializeActorInstance = {
|
||||||
actor.preStart // run actor preStart
|
actor.preStart // run actor preStart
|
||||||
Actor.log.slf4j.trace("[%s] has started", toString)
|
Actor.log.slf4j.trace("[{}] has started", toString)
|
||||||
ActorRegistry.register(this)
|
ActorRegistry.register(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ trait BootableActorLoaderService extends Bootable with Logging {
|
||||||
val DEPLOY = HOME.getOrElse(throwNoAkkaHomeException) + "/deploy"
|
val DEPLOY = HOME.getOrElse(throwNoAkkaHomeException) + "/deploy"
|
||||||
val DEPLOY_DIR = new File(DEPLOY)
|
val DEPLOY_DIR = new File(DEPLOY)
|
||||||
if (!DEPLOY_DIR.exists) {
|
if (!DEPLOY_DIR.exists) {
|
||||||
log.slf4j.error("Could not find a deploy directory at [%s]", DEPLOY)
|
log.slf4j.error("Could not find a deploy directory at [{}]", DEPLOY)
|
||||||
System.exit(-1)
|
System.exit(-1)
|
||||||
}
|
}
|
||||||
val filesToDeploy = DEPLOY_DIR.listFiles.toArray.toList
|
val filesToDeploy = DEPLOY_DIR.listFiles.toArray.toList
|
||||||
|
|
@ -42,8 +42,8 @@ trait BootableActorLoaderService extends Bootable with Logging {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val toDeploy = filesToDeploy.map(_.toURI.toURL)
|
val toDeploy = filesToDeploy.map(_.toURI.toURL)
|
||||||
log.slf4j.info("Deploying applications from [%s]: [%s]", DEPLOY, toDeploy)
|
log.slf4j.info("Deploying applications from [{}]: [{}]", DEPLOY, toDeploy)
|
||||||
log.slf4j.debug("Loading dependencies [%s]", dependencyJars)
|
log.slf4j.debug("Loading dependencies [{}]", dependencyJars)
|
||||||
val allJars = toDeploy ::: dependencyJars
|
val allJars = toDeploy ::: dependencyJars
|
||||||
|
|
||||||
new URLClassLoader(allJars.toArray,Thread.currentThread.getContextClassLoader)
|
new URLClassLoader(allJars.toArray,Thread.currentThread.getContextClassLoader)
|
||||||
|
|
@ -56,7 +56,7 @@ trait BootableActorLoaderService extends Bootable with Logging {
|
||||||
super.onLoad
|
super.onLoad
|
||||||
|
|
||||||
for (loader <- applicationLoader; clazz <- BOOT_CLASSES) {
|
for (loader <- applicationLoader; clazz <- BOOT_CLASSES) {
|
||||||
log.slf4j.info("Loading boot class [%s]", clazz)
|
log.slf4j.info("Loading boot class [{}]", clazz)
|
||||||
loader.loadClass(clazz).newInstance
|
loader.loadClass(clazz).newInstance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,17 +69,17 @@ trait FSM[S, D] {
|
||||||
|
|
||||||
private var handleEvent: StateFunction = {
|
private var handleEvent: StateFunction = {
|
||||||
case Event(value, stateData) =>
|
case Event(value, stateData) =>
|
||||||
log.slf4j.warn("Event %s not handled in state %s, staying at current state", value, currentState.stateName)
|
log.slf4j.warn("Event {} not handled in state {}, staying at current state", value, currentState.stateName)
|
||||||
stay
|
stay
|
||||||
}
|
}
|
||||||
|
|
||||||
private var terminateEvent: PartialFunction[Reason, Unit] = {
|
private var terminateEvent: PartialFunction[Reason, Unit] = {
|
||||||
case failure@Failure(_) => log.slf4j.error("Stopping because of a %s", failure)
|
case failure@Failure(_) => log.slf4j.error("Stopping because of a {}", failure)
|
||||||
case reason => log.slf4j.info("Stopping because of reason: %s", reason)
|
case reason => log.slf4j.info("Stopping because of reason: {}", reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var transitionEvent: PartialFunction[Transition, Unit] = {
|
private var transitionEvent: PartialFunction[Transition, Unit] = {
|
||||||
case Transition(from, to) => log.slf4j.debug("Transitioning from state %s to %s", from, to)
|
case Transition(from, to) => log.slf4j.debug("Transitioning from state {} to {}", from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
override final protected def receive: Receive = {
|
override final protected def receive: Receive = {
|
||||||
|
|
@ -123,7 +123,7 @@ trait FSM[S, D] {
|
||||||
def replying(replyValue:Any): State = {
|
def replying(replyValue:Any): State = {
|
||||||
self.sender match {
|
self.sender match {
|
||||||
case Some(sender) => sender ! replyValue
|
case Some(sender) => sender ! replyValue
|
||||||
case None => log.slf4j.error("Unable to send reply value %s, no sender reference to reply to", replyValue)
|
case None => log.slf4j.error("Unable to send reply value {}, no sender reference to reply to", replyValue)
|
||||||
}
|
}
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ object Scheduler extends Logging {
|
||||||
*/
|
*/
|
||||||
def schedule(receiver: ActorRef, message: AnyRef, initialDelay: Long, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
def schedule(receiver: ActorRef, message: AnyRef, initialDelay: Long, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
||||||
log.slf4j.trace(
|
log.slf4j.trace(
|
||||||
"Schedule scheduled event\n\tevent = [%s]\n\treceiver = [%s]\n\tinitialDelay = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]",
|
"Schedule scheduled event\n\tevent = [{}]\n\treceiver = [{}]\n\tinitialDelay = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]",
|
||||||
Array(message, receiver, initialDelay, delay, timeUnit))
|
Array(message, receiver, initialDelay, delay, timeUnit))
|
||||||
try {
|
try {
|
||||||
service.scheduleAtFixedRate(
|
service.scheduleAtFixedRate(
|
||||||
|
|
@ -60,7 +60,7 @@ object Scheduler extends Logging {
|
||||||
*/
|
*/
|
||||||
def schedule(runnable: Runnable, initialDelay: Long, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
def schedule(runnable: Runnable, initialDelay: Long, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
||||||
log.slf4j.trace(
|
log.slf4j.trace(
|
||||||
"Schedule scheduled event\n\trunnable = [%s]\n\tinitialDelay = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]",
|
"Schedule scheduled event\n\trunnable = [{}]\n\tinitialDelay = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]",
|
||||||
Array(runnable, initialDelay, delay, timeUnit))
|
Array(runnable, initialDelay, delay, timeUnit))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -75,7 +75,7 @@ object Scheduler extends Logging {
|
||||||
*/
|
*/
|
||||||
def scheduleOnce(receiver: ActorRef, message: AnyRef, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
def scheduleOnce(receiver: ActorRef, message: AnyRef, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
||||||
log.slf4j.trace(
|
log.slf4j.trace(
|
||||||
"Schedule one-time event\n\tevent = [%s]\n\treceiver = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]",
|
"Schedule one-time event\n\tevent = [{}]\n\treceiver = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]",
|
||||||
Array(message, receiver, delay, timeUnit))
|
Array(message, receiver, delay, timeUnit))
|
||||||
try {
|
try {
|
||||||
service.schedule(
|
service.schedule(
|
||||||
|
|
@ -99,7 +99,7 @@ object Scheduler extends Logging {
|
||||||
*/
|
*/
|
||||||
def scheduleOnce(runnable: Runnable, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
def scheduleOnce(runnable: Runnable, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = {
|
||||||
log.slf4j.trace(
|
log.slf4j.trace(
|
||||||
"Schedule one-time event\n\trunnable = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]",
|
"Schedule one-time event\n\trunnable = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]",
|
||||||
Array(runnable, delay, timeUnit))
|
Array(runnable, delay, timeUnit))
|
||||||
try {
|
try {
|
||||||
service.schedule(runnable,delay, timeUnit).asInstanceOf[ScheduledFuture[AnyRef]]
|
service.schedule(runnable,delay, timeUnit).asInstanceOf[ScheduledFuture[AnyRef]]
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ object Config extends Logging {
|
||||||
val configFile = System.getProperty("akka.config", "")
|
val configFile = System.getProperty("akka.config", "")
|
||||||
try {
|
try {
|
||||||
Configgy.configure(configFile)
|
Configgy.configure(configFile)
|
||||||
log.slf4j.info("Config loaded from -Dakka.config=%s", configFile)
|
log.slf4j.info("Config loaded from -Dakka.config={}", configFile)
|
||||||
} catch {
|
} catch {
|
||||||
case e: ParseException => throw new ConfigurationException(
|
case e: ParseException => throw new ConfigurationException(
|
||||||
"Config could not be loaded from -Dakka.config=" + configFile +
|
"Config could not be loaded from -Dakka.config=" + configFile +
|
||||||
|
|
@ -69,7 +69,7 @@ object Config extends Logging {
|
||||||
val configFile = HOME.getOrElse(throwNoAkkaHomeException) + "/config/" + confName
|
val configFile = HOME.getOrElse(throwNoAkkaHomeException) + "/config/" + confName
|
||||||
Configgy.configure(configFile)
|
Configgy.configure(configFile)
|
||||||
log.slf4j.info(
|
log.slf4j.info(
|
||||||
"AKKA_HOME is defined as [%s], config loaded from [%s].",
|
"AKKA_HOME is defined as [{}], config loaded from [{}].",
|
||||||
HOME.getOrElse(throwNoAkkaHomeException),
|
HOME.getOrElse(throwNoAkkaHomeException),
|
||||||
configFile)
|
configFile)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -82,7 +82,7 @@ object Config extends Logging {
|
||||||
} else if (getClass.getClassLoader.getResource(confName) ne null) {
|
} else if (getClass.getClassLoader.getResource(confName) ne null) {
|
||||||
try {
|
try {
|
||||||
Configgy.configureFromResource(confName, getClass.getClassLoader)
|
Configgy.configureFromResource(confName, getClass.getClassLoader)
|
||||||
log.slf4j.info("Config [%s] loaded from the application classpath.",confName)
|
log.slf4j.info("Config [{}] loaded from the application classpath.",confName)
|
||||||
} catch {
|
} catch {
|
||||||
case e: ParseException => throw new ConfigurationException(
|
case e: ParseException => throw new ConfigurationException(
|
||||||
"Can't load '" + confName + "' config file from application classpath," +
|
"Can't load '" + confName + "' config file from application classpath," +
|
||||||
|
|
|
||||||
|
|
@ -123,12 +123,12 @@ class ExecutorBasedEventDrivenDispatcher(
|
||||||
private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef =
|
private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef =
|
||||||
createMailbox(mailboxType.mailboxImplClassname, actorRef)
|
createMailbox(mailboxType.mailboxImplClassname, actorRef)
|
||||||
|
|
||||||
private[akka] def start = log.slf4j.debug("Starting up %s\n\twith throughput [%d]", toString, throughput)
|
private[akka] def start = log.slf4j.debug("Starting up {}\n\twith throughput [%d]", toString, throughput)
|
||||||
|
|
||||||
private[akka] def shutdown {
|
private[akka] def shutdown {
|
||||||
val old = executorService.getAndSet(config.createLazyExecutorService(threadFactory))
|
val old = executorService.getAndSet(config.createLazyExecutorService(threadFactory))
|
||||||
if (old ne null) {
|
if (old ne null) {
|
||||||
log.slf4j.debug("Shutting down %s", toString)
|
log.slf4j.debug("Shutting down {}", toString)
|
||||||
old.shutdownNow()
|
old.shutdownNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -144,17 +144,17 @@ class ExecutorBasedEventDrivenDispatcher(
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else log.slf4j.warn("%s is shut down,\n\tignoring the rest of the messages in the mailbox of\n\t%s", this, mbox)
|
} else log.slf4j.warn("{} is shut down,\n\tignoring the rest of the messages in the mailbox of\n\t{}", this, mbox)
|
||||||
|
|
||||||
override val toString = getClass.getSimpleName + "[" + name + "]"
|
override val toString = getClass.getSimpleName + "[" + name + "]"
|
||||||
|
|
||||||
def suspend(actorRef: ActorRef) {
|
def suspend(actorRef: ActorRef) {
|
||||||
log.slf4j.debug("Suspending %s",actorRef.uuid)
|
log.slf4j.debug("Suspending {}",actorRef.uuid)
|
||||||
getMailbox(actorRef).suspended.switchOn
|
getMailbox(actorRef).suspended.switchOn
|
||||||
}
|
}
|
||||||
|
|
||||||
def resume(actorRef: ActorRef) {
|
def resume(actorRef: ActorRef) {
|
||||||
log.slf4j.debug("Resuming %s",actorRef.uuid)
|
log.slf4j.debug("Resuming {}",actorRef.uuid)
|
||||||
val mbox = getMailbox(actorRef)
|
val mbox = getMailbox(actorRef)
|
||||||
mbox.suspended.switchOff
|
mbox.suspended.switchOff
|
||||||
registerForExecution(mbox)
|
registerForExecution(mbox)
|
||||||
|
|
|
||||||
|
|
@ -171,12 +171,12 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(
|
||||||
} else false
|
} else false
|
||||||
}
|
}
|
||||||
|
|
||||||
private[akka] def start = log.slf4j.debug("Starting up %s",toString)
|
private[akka] def start = log.slf4j.debug("Starting up {}",toString)
|
||||||
|
|
||||||
private[akka] def shutdown {
|
private[akka] def shutdown {
|
||||||
val old = executorService.getAndSet(config.createLazyExecutorService(threadFactory))
|
val old = executorService.getAndSet(config.createLazyExecutorService(threadFactory))
|
||||||
if (old ne null) {
|
if (old ne null) {
|
||||||
log.slf4j.debug("Shutting down %s", toString)
|
log.slf4j.debug("Shutting down {}", toString)
|
||||||
old.shutdownNow()
|
old.shutdownNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -244,7 +244,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher(
|
||||||
case Some(aType) =>
|
case Some(aType) =>
|
||||||
if (aType != actorOfId.actor.getClass)
|
if (aType != actorOfId.actor.getClass)
|
||||||
throw new IllegalActorStateException(String.format(
|
throw new IllegalActorStateException(String.format(
|
||||||
"Can't register actor %s in a work stealing dispatcher which already knows actors of type %s",
|
"Can't register actor {} in a work stealing dispatcher which already knows actors of type {}",
|
||||||
actorOfId.actor, aType))
|
actorOfId.actor, aType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,13 +179,13 @@ class MonitorableThread(runnable: Runnable, name: String)
|
||||||
|
|
||||||
override def run = {
|
override def run = {
|
||||||
val debug = MonitorableThread.debugLifecycle
|
val debug = MonitorableThread.debugLifecycle
|
||||||
log.slf4j.debug("Created thread %s", getName)
|
log.slf4j.debug("Created thread {}", getName)
|
||||||
try {
|
try {
|
||||||
MonitorableThread.alive.incrementAndGet
|
MonitorableThread.alive.incrementAndGet
|
||||||
super.run
|
super.run
|
||||||
} finally {
|
} finally {
|
||||||
MonitorableThread.alive.decrementAndGet
|
MonitorableThread.alive.decrementAndGet
|
||||||
log.slf4j.debug("Exiting thread %s", getName)
|
log.slf4j.debug("Exiting thread {}", getName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ object Helpers extends Logging {
|
||||||
narrow(o)
|
narrow(o)
|
||||||
} catch {
|
} catch {
|
||||||
case e: ClassCastException =>
|
case e: ClassCastException =>
|
||||||
log.slf4j.warn("Cannot narrow %s to expected type %s!", o, implicitly[Manifest[T]].erasure.getName)
|
log.slf4j.warn("Cannot narrow {} to expected type {}!", o, implicitly[Manifest[T]].erasure.getName)
|
||||||
log.slf4j.trace("narrowSilently", e)
|
log.slf4j.trace("narrowSilently", e)
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ trait ListenerManagement extends Logging {
|
||||||
while (iterator.hasNext) {
|
while (iterator.hasNext) {
|
||||||
val listener = iterator.next
|
val listener = iterator.next
|
||||||
if (listener.isRunning) listener ! msg
|
if (listener.isRunning) listener ! msg
|
||||||
else log.slf4j.warn("Can't notify [%s] since it is not running.", listener)
|
else log.slf4j.warn("Can't notify [{}] since it is not running.", listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +70,7 @@ trait ListenerManagement extends Logging {
|
||||||
while (iterator.hasNext) {
|
while (iterator.hasNext) {
|
||||||
val listener = iterator.next
|
val listener = iterator.next
|
||||||
if (listener.isRunning) f(listener)
|
if (listener.isRunning) f(listener)
|
||||||
else log.slf4j.warn("Can't notify [%s] since it is not running.", listener)
|
else log.slf4j.warn("Can't notify [{}] since it is not running.", listener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,17 @@ trait Logging {
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* class Foo extends Logging {
|
* class Foo extends Logging {
|
||||||
* log.slf4j.info("My foo is %s","alive")
|
* log.info("My foo is %s","alive")
|
||||||
* log.slf4j.error(new Exception(),"My foo is %s","broken")
|
* log.error(new Exception(),"My foo is %s","broken")
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* The logger uses String.format:
|
* The logger uses String.format:
|
||||||
* http://download-llnw.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)
|
* http://download-llnw.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...)
|
||||||
|
*
|
||||||
|
* If you want to use underlying slf4j Logger, do:
|
||||||
|
* log.slf4j.info("My foo is {}","alive")
|
||||||
|
* log.slf4j.error("My foo is broken",new Exception())
|
||||||
*/
|
*/
|
||||||
class Logger(val slf4j: SLFLogger) {
|
class Logger(val slf4j: SLFLogger) {
|
||||||
final def name = logger.getName
|
final def name = logger.getName
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ object ReflectiveAccess extends Logging {
|
||||||
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
||||||
} catch {
|
} catch {
|
||||||
case e =>
|
case e =>
|
||||||
log.slf4j.warn("Could not instantiate class [%s] due to [%s]", clazz.getName, e.getCause)
|
log.slf4j.warn("Could not instantiate class [{}] due to [{}]", clazz.getName, e.getCause)
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ object ReflectiveAccess extends Logging {
|
||||||
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
||||||
} catch {
|
} catch {
|
||||||
case e =>
|
case e =>
|
||||||
log.slf4j.warn("Could not instantiate class [%s] due to [%s]", fqn, e.getCause)
|
log.slf4j.warn("Could not instantiate class [{}] due to [{}]", fqn, e.getCause)
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ object ReflectiveAccess extends Logging {
|
||||||
Option(instance.get(null).asInstanceOf[T])
|
Option(instance.get(null).asInstanceOf[T])
|
||||||
} catch {
|
} catch {
|
||||||
case e: ClassNotFoundException =>
|
case e: ClassNotFoundException =>
|
||||||
log.slf4j.debug("Could not get object [%s] due to [%s]", fqn, e)
|
log.slf4j.debug("Could not get object [{}] due to [{}]", fqn, e)
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ object FSMActorSpec {
|
||||||
goto(Open) using CodeState("", code) until timeout
|
goto(Open) using CodeState("", code) until timeout
|
||||||
}
|
}
|
||||||
case wrong => {
|
case wrong => {
|
||||||
log.slf4j.error("Wrong code %s", wrong)
|
log.slf4j.error("Wrong code {}", wrong)
|
||||||
stay using CodeState("", code)
|
stay using CodeState("", code)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class AkkaLoader extends Logging {
|
||||||
log.slf4j.info(" ttt tt ttt ttt ttt ttt ttt ttt")
|
log.slf4j.info(" ttt tt ttt ttt ttt ttt ttt ttt")
|
||||||
log.slf4j.info(" tttttttt ttt ttt ttt ttt tttttttt")
|
log.slf4j.info(" tttttttt ttt ttt ttt ttt tttttttt")
|
||||||
log.slf4j.info("==================================================")
|
log.slf4j.info("==================================================")
|
||||||
log.slf4j.info(" Running version %s", Config.VERSION)
|
log.slf4j.info(" Running version {}", Config.VERSION)
|
||||||
log.slf4j.info("==================================================")
|
log.slf4j.info("==================================================")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging {
|
||||||
throw new WebApplicationException(r.asInstanceOf[Response])
|
throw new WebApplicationException(r.asInstanceOf[Response])
|
||||||
case None => throw new WebApplicationException(408)
|
case None => throw new WebApplicationException(408)
|
||||||
case unknown => {
|
case unknown => {
|
||||||
log.slf4j.warn("Authenticator replied with unexpected result [%s]", unknown);
|
log.slf4j.warn("Authenticator replied with unexpected result [{}]", unknown)
|
||||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR)
|
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ class RemoteClient private[akka] (
|
||||||
bootstrap.setOption("tcpNoDelay", true)
|
bootstrap.setOption("tcpNoDelay", true)
|
||||||
bootstrap.setOption("keepAlive", true)
|
bootstrap.setOption("keepAlive", true)
|
||||||
|
|
||||||
log.slf4j.info("Starting remote client connection to [%s:%s]", hostname, port)
|
log.slf4j.info("Starting remote client connection to [{}:{}]", hostname, port)
|
||||||
|
|
||||||
// Wait until the connection attempt succeeds or fails.
|
// Wait until the connection attempt succeeds or fails.
|
||||||
connection = bootstrap.connect(remoteAddress)
|
connection = bootstrap.connect(remoteAddress)
|
||||||
|
|
@ -247,14 +247,14 @@ class RemoteClient private[akka] (
|
||||||
|
|
||||||
if (!connection.isSuccess) {
|
if (!connection.isSuccess) {
|
||||||
notifyListeners(RemoteClientError(connection.getCause, this))
|
notifyListeners(RemoteClientError(connection.getCause, this))
|
||||||
log.slf4j.error("Remote client connection to [%s:%s] has failed", hostname, port)
|
log.slf4j.error("Remote client connection to [{}:{}] has failed", hostname, port)
|
||||||
log.slf4j.debug("Remote client connection failed", connection.getCause)
|
log.slf4j.debug("Remote client connection failed", connection.getCause)
|
||||||
}
|
}
|
||||||
notifyListeners(RemoteClientStarted(this))
|
notifyListeners(RemoteClientStarted(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
def shutdown = runSwitch switchOff {
|
def shutdown = runSwitch switchOff {
|
||||||
log.slf4j.info("Shutting down %s", name)
|
log.slf4j.info("Shutting down {}", name)
|
||||||
notifyListeners(RemoteClientShutdown(this))
|
notifyListeners(RemoteClientShutdown(this))
|
||||||
timer.stop
|
timer.stop
|
||||||
timer = null
|
timer = null
|
||||||
|
|
@ -263,7 +263,7 @@ class RemoteClient private[akka] (
|
||||||
bootstrap.releaseExternalResources
|
bootstrap.releaseExternalResources
|
||||||
bootstrap = null
|
bootstrap = null
|
||||||
connection = null
|
connection = null
|
||||||
log.slf4j.info("%s has been shut down", name)
|
log.slf4j.info("{} has been shut down", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@deprecated("Use addListener instead")
|
@deprecated("Use addListener instead")
|
||||||
|
|
@ -342,7 +342,7 @@ class RemoteClient private[akka] (
|
||||||
} else {
|
} else {
|
||||||
val timeLeft = reconnectionTimeWindow - (System.currentTimeMillis - reconnectionTimeWindowStart)
|
val timeLeft = reconnectionTimeWindow - (System.currentTimeMillis - reconnectionTimeWindowStart)
|
||||||
if (timeLeft > 0) {
|
if (timeLeft > 0) {
|
||||||
log.slf4j.info("Will try to reconnect to remote server for another [%s] milliseconds", timeLeft)
|
log.slf4j.info("Will try to reconnect to remote server for another [{}] milliseconds", timeLeft)
|
||||||
true
|
true
|
||||||
} else false
|
} else false
|
||||||
}
|
}
|
||||||
|
|
@ -418,7 +418,7 @@ class RemoteClientHandler(
|
||||||
if (result.isInstanceOf[RemoteMessageProtocol]) {
|
if (result.isInstanceOf[RemoteMessageProtocol]) {
|
||||||
val reply = result.asInstanceOf[RemoteMessageProtocol]
|
val reply = result.asInstanceOf[RemoteMessageProtocol]
|
||||||
val replyUuid = uuidFrom(reply.getUuid.getHigh, reply.getUuid.getLow)
|
val replyUuid = uuidFrom(reply.getUuid.getHigh, reply.getUuid.getLow)
|
||||||
log.slf4j.debug("Remote client received RemoteMessageProtocol[\n%s]".format(reply.toString))
|
log.debug("Remote client received RemoteMessageProtocol[\n{}]",reply)
|
||||||
val future = futures.get(replyUuid).asInstanceOf[CompletableFuture[Any]]
|
val future = futures.get(replyUuid).asInstanceOf[CompletableFuture[Any]]
|
||||||
if (reply.hasMessage) {
|
if (reply.hasMessage) {
|
||||||
if (future eq null) throw new IllegalActorStateException("Future mapped to UUID " + replyUuid + " does not exist")
|
if (future eq null) throw new IllegalActorStateException("Future mapped to UUID " + replyUuid + " does not exist")
|
||||||
|
|
@ -446,7 +446,7 @@ class RemoteClientHandler(
|
||||||
} catch {
|
} catch {
|
||||||
case e: Exception =>
|
case e: Exception =>
|
||||||
client.notifyListeners(RemoteClientError(e, client))
|
client.notifyListeners(RemoteClientError(e, client))
|
||||||
log.slf4j.error("Unexpected exception in remote client handler: %s", e)
|
log.slf4j.error("Unexpected exception in remote client handler: {}", e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -457,12 +457,12 @@ class RemoteClientHandler(
|
||||||
def run(timeout: Timeout) = {
|
def run(timeout: Timeout) = {
|
||||||
client.openChannels.remove(event.getChannel)
|
client.openChannels.remove(event.getChannel)
|
||||||
client.isAuthenticated.set(false)
|
client.isAuthenticated.set(false)
|
||||||
log.slf4j.debug("Remote client reconnecting to [%s]", remoteAddress)
|
log.slf4j.debug("Remote client reconnecting to [{}]", remoteAddress)
|
||||||
client.connection = bootstrap.connect(remoteAddress)
|
client.connection = bootstrap.connect(remoteAddress)
|
||||||
client.connection.awaitUninterruptibly // Wait until the connection attempt succeeds or fails.
|
client.connection.awaitUninterruptibly // Wait until the connection attempt succeeds or fails.
|
||||||
if (!client.connection.isSuccess) {
|
if (!client.connection.isSuccess) {
|
||||||
client.notifyListeners(RemoteClientError(client.connection.getCause, client))
|
client.notifyListeners(RemoteClientError(client.connection.getCause, client))
|
||||||
log.slf4j.error("Reconnection to [%s] has failed", remoteAddress)
|
log.slf4j.error("Reconnection to [{}] has failed", remoteAddress)
|
||||||
log.slf4j.debug("Reconnection failed", client.connection.getCause)
|
log.slf4j.debug("Reconnection failed", client.connection.getCause)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -473,7 +473,7 @@ class RemoteClientHandler(
|
||||||
override def channelConnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
override def channelConnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
||||||
def connect = {
|
def connect = {
|
||||||
client.notifyListeners(RemoteClientConnected(client))
|
client.notifyListeners(RemoteClientConnected(client))
|
||||||
log.slf4j.debug("Remote client connected to [%s]", ctx.getChannel.getRemoteAddress)
|
log.slf4j.debug("Remote client connected to [{}]", ctx.getChannel.getRemoteAddress)
|
||||||
client.resetReconnectionTimeWindow
|
client.resetReconnectionTimeWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,7 +490,7 @@ class RemoteClientHandler(
|
||||||
|
|
||||||
override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
||||||
client.notifyListeners(RemoteClientDisconnected(client))
|
client.notifyListeners(RemoteClientDisconnected(client))
|
||||||
log.slf4j.debug("Remote client disconnected from [%s]", ctx.getChannel.getRemoteAddress)
|
log.slf4j.debug("Remote client disconnected from [{}]", ctx.getChannel.getRemoteAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def exceptionCaught(ctx: ChannelHandlerContext, event: ExceptionEvent) = {
|
override def exceptionCaught(ctx: ChannelHandlerContext, event: ExceptionEvent) = {
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
try {
|
try {
|
||||||
if (!_isRunning) {
|
if (!_isRunning) {
|
||||||
address = Address(_hostname,_port)
|
address = Address(_hostname,_port)
|
||||||
log.slf4j.info("Starting remote server at [%s:%s]", hostname, port)
|
log.slf4j.info("Starting remote server at [{}:{}]", hostname, port)
|
||||||
RemoteServer.register(hostname, port, this)
|
RemoteServer.register(hostname, port, this)
|
||||||
|
|
||||||
val pipelineFactory = new RemoteServerPipelineFactory(name, openChannels, loader, this)
|
val pipelineFactory = new RemoteServerPipelineFactory(name, openChannels, loader, this)
|
||||||
|
|
@ -281,7 +281,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
* @param typedActor typed actor to register
|
* @param typedActor typed actor to register
|
||||||
*/
|
*/
|
||||||
def registerTypedActor(id: String, typedActor: AnyRef): Unit = synchronized {
|
def registerTypedActor(id: String, typedActor: AnyRef): Unit = synchronized {
|
||||||
log.slf4j.debug("Registering server side remote typed actor [%s] with id [%s]", typedActor.getClass.getName, id)
|
log.slf4j.debug("Registering server side remote typed actor [{}] with id [{}]", typedActor.getClass.getName, id)
|
||||||
if (id.startsWith(UUID_PREFIX)) registerTypedActor(id.substring(UUID_PREFIX.length), typedActor, typedActorsByUuid)
|
if (id.startsWith(UUID_PREFIX)) registerTypedActor(id.substring(UUID_PREFIX.length), typedActor, typedActorsByUuid)
|
||||||
else registerTypedActor(id, typedActor, typedActors)
|
else registerTypedActor(id, typedActor, typedActors)
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +297,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
* @param typedActor typed actor to register
|
* @param typedActor typed actor to register
|
||||||
*/
|
*/
|
||||||
def registerTypedPerSessionActor(id: String, factory: => AnyRef): Unit = synchronized {
|
def registerTypedPerSessionActor(id: String, factory: => AnyRef): Unit = synchronized {
|
||||||
log.slf4j.debug("Registering server side typed remote session actor with id [%s]", id)
|
log.slf4j.debug("Registering server side typed remote session actor with id [{}]", id)
|
||||||
registerTypedPerSessionActor(id, () => factory, typedActorsFactories)
|
registerTypedPerSessionActor(id, () => factory, typedActorsFactories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -312,7 +312,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
* NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself.
|
* NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself.
|
||||||
*/
|
*/
|
||||||
def register(id: String, actorRef: ActorRef): Unit = synchronized {
|
def register(id: String, actorRef: ActorRef): Unit = synchronized {
|
||||||
log.slf4j.debug("Registering server side remote actor [%s] with id [%s]", actorRef.actorClass.getName, id)
|
log.slf4j.debug("Registering server side remote actor [{}] with id [{}]", actorRef.actorClass.getName, id)
|
||||||
if (id.startsWith(UUID_PREFIX)) register(id.substring(UUID_PREFIX.length), actorRef, actorsByUuid)
|
if (id.startsWith(UUID_PREFIX)) register(id.substring(UUID_PREFIX.length), actorRef, actorsByUuid)
|
||||||
else register(id, actorRef, actors)
|
else register(id, actorRef, actors)
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +323,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
* NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself.
|
* NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself.
|
||||||
*/
|
*/
|
||||||
def registerPerSession(id: String, factory: => ActorRef): Unit = synchronized {
|
def registerPerSession(id: String, factory: => ActorRef): Unit = synchronized {
|
||||||
log.slf4j.debug("Registering server side remote session actor with id [%s]", id)
|
log.slf4j.debug("Registering server side remote session actor with id [{}]", id)
|
||||||
registerPerSession(id, () => factory, actorsFactories)
|
registerPerSession(id, () => factory, actorsFactories)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -354,7 +354,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
*/
|
*/
|
||||||
def unregister(actorRef: ActorRef):Unit = synchronized {
|
def unregister(actorRef: ActorRef):Unit = synchronized {
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
log.slf4j.debug("Unregistering server side remote actor [%s] with id [%s:%s]", Array(actorRef.actorClass.getName, actorRef.id, actorRef.uuid))
|
log.slf4j.debug("Unregistering server side remote actor [{}] with id [{}:{}]", Array(actorRef.actorClass.getName, actorRef.id, actorRef.uuid))
|
||||||
actors.remove(actorRef.id, actorRef)
|
actors.remove(actorRef.id, actorRef)
|
||||||
actorsByUuid.remove(actorRef.uuid, actorRef)
|
actorsByUuid.remove(actorRef.uuid, actorRef)
|
||||||
}
|
}
|
||||||
|
|
@ -367,7 +367,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
*/
|
*/
|
||||||
def unregister(id: String):Unit = synchronized {
|
def unregister(id: String):Unit = synchronized {
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
log.slf4j.info("Unregistering server side remote actor with id [%s]", id)
|
log.slf4j.info("Unregistering server side remote actor with id [{}]", id)
|
||||||
if (id.startsWith(UUID_PREFIX)) actorsByUuid.remove(id.substring(UUID_PREFIX.length))
|
if (id.startsWith(UUID_PREFIX)) actorsByUuid.remove(id.substring(UUID_PREFIX.length))
|
||||||
else {
|
else {
|
||||||
val actorRef = actors get id
|
val actorRef = actors get id
|
||||||
|
|
@ -384,7 +384,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
*/
|
*/
|
||||||
def unregisterPerSession(id: String):Unit = {
|
def unregisterPerSession(id: String):Unit = {
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
log.slf4j.info("Unregistering server side remote session actor with id [%s]", id)
|
log.slf4j.info("Unregistering server side remote session actor with id [{}]", id)
|
||||||
actorsFactories.remove(id)
|
actorsFactories.remove(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -396,7 +396,7 @@ class RemoteServer extends Logging with ListenerManagement {
|
||||||
*/
|
*/
|
||||||
def unregisterTypedActor(id: String):Unit = synchronized {
|
def unregisterTypedActor(id: String):Unit = synchronized {
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
log.slf4j.info("Unregistering server side remote typed actor with id [%s]", id)
|
log.slf4j.info("Unregistering server side remote typed actor with id [{}]", id)
|
||||||
if (id.startsWith(UUID_PREFIX)) typedActorsByUuid.remove(id.substring(UUID_PREFIX.length))
|
if (id.startsWith(UUID_PREFIX)) typedActorsByUuid.remove(id.substring(UUID_PREFIX.length))
|
||||||
else typedActors.remove(id)
|
else typedActors.remove(id)
|
||||||
}
|
}
|
||||||
|
|
@ -506,7 +506,7 @@ class RemoteServerHandler(
|
||||||
val clientAddress = getClientAddress(ctx)
|
val clientAddress = getClientAddress(ctx)
|
||||||
sessionActors.set(event.getChannel(), new ConcurrentHashMap[String, ActorRef]())
|
sessionActors.set(event.getChannel(), new ConcurrentHashMap[String, ActorRef]())
|
||||||
typedSessionActors.set(event.getChannel(), new ConcurrentHashMap[String, AnyRef]())
|
typedSessionActors.set(event.getChannel(), new ConcurrentHashMap[String, AnyRef]())
|
||||||
log.slf4j.debug("Remote client [%s] connected to [%s]", clientAddress, server.name)
|
log.slf4j.debug("Remote client [{}] connected to [{}]", clientAddress, server.name)
|
||||||
if (RemoteServer.SECURE) {
|
if (RemoteServer.SECURE) {
|
||||||
val sslHandler: SslHandler = ctx.getPipeline.get(classOf[SslHandler])
|
val sslHandler: SslHandler = ctx.getPipeline.get(classOf[SslHandler])
|
||||||
// Begin handshake.
|
// Begin handshake.
|
||||||
|
|
@ -524,7 +524,7 @@ class RemoteServerHandler(
|
||||||
|
|
||||||
override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
||||||
val clientAddress = getClientAddress(ctx)
|
val clientAddress = getClientAddress(ctx)
|
||||||
log.slf4j.debug("Remote client [%s] disconnected from [%s]", clientAddress, server.name)
|
log.slf4j.debug("Remote client [{}] disconnected from [{}]", clientAddress, server.name)
|
||||||
// stop all session actors
|
// stop all session actors
|
||||||
val channelActors = sessionActors.remove(event.getChannel)
|
val channelActors = sessionActors.remove(event.getChannel)
|
||||||
if (channelActors ne null) {
|
if (channelActors ne null) {
|
||||||
|
|
@ -546,7 +546,7 @@ class RemoteServerHandler(
|
||||||
|
|
||||||
override def channelClosed(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
override def channelClosed(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
||||||
val clientAddress = getClientAddress(ctx)
|
val clientAddress = getClientAddress(ctx)
|
||||||
log.slf4j.debug("Remote client [%s] channel closed from [%s]", clientAddress, server.name)
|
log.slf4j.debug("Remote client [{}] channel closed from [{}]", clientAddress, server.name)
|
||||||
server.notifyListeners(RemoteServerClientClosed(server, clientAddress))
|
server.notifyListeners(RemoteServerClientClosed(server, clientAddress))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,7 +580,7 @@ class RemoteServerHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
private def handleRemoteMessageProtocol(request: RemoteMessageProtocol, channel: Channel) = {
|
private def handleRemoteMessageProtocol(request: RemoteMessageProtocol, channel: Channel) = {
|
||||||
log.slf4j.debug("Received RemoteMessageProtocol[\n%s]".format(request.toString))
|
log.slf4j.debug("Received RemoteMessageProtocol[\n{}]",request)
|
||||||
request.getActorInfo.getActorType match {
|
request.getActorInfo.getActorType match {
|
||||||
case SCALA_ACTOR => dispatchToActor(request, channel)
|
case SCALA_ACTOR => dispatchToActor(request, channel)
|
||||||
case TYPED_ACTOR => dispatchToTypedActor(request, channel)
|
case TYPED_ACTOR => dispatchToTypedActor(request, channel)
|
||||||
|
|
@ -591,7 +591,7 @@ class RemoteServerHandler(
|
||||||
|
|
||||||
private def dispatchToActor(request: RemoteMessageProtocol, channel: Channel) {
|
private def dispatchToActor(request: RemoteMessageProtocol, channel: Channel) {
|
||||||
val actorInfo = request.getActorInfo
|
val actorInfo = request.getActorInfo
|
||||||
log.slf4j.debug("Dispatching to remote actor [%s:%s]", actorInfo.getTarget, actorInfo.getUuid)
|
log.slf4j.debug("Dispatching to remote actor [{}:{}]", actorInfo.getTarget, actorInfo.getUuid)
|
||||||
|
|
||||||
val actorRef =
|
val actorRef =
|
||||||
try {
|
try {
|
||||||
|
|
@ -627,7 +627,7 @@ class RemoteServerHandler(
|
||||||
val exception = f.exception
|
val exception = f.exception
|
||||||
|
|
||||||
if (exception.isDefined) {
|
if (exception.isDefined) {
|
||||||
log.slf4j.debug("Returning exception from actor invocation [%s]",exception.get)
|
log.slf4j.debug("Returning exception from actor invocation [{}]",exception.get)
|
||||||
try {
|
try {
|
||||||
channel.write(createErrorReplyMessage(exception.get, request, AkkaActorType.ScalaActor))
|
channel.write(createErrorReplyMessage(exception.get, request, AkkaActorType.ScalaActor))
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -635,7 +635,7 @@ class RemoteServerHandler(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (result.isDefined) {
|
else if (result.isDefined) {
|
||||||
log.slf4j.debug("Returning result from actor invocation [%s]".format(result.get))
|
log.slf4j.debug("Returning result from actor invocation [{}]",result.get)
|
||||||
val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder(
|
val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder(
|
||||||
Some(actorRef),
|
Some(actorRef),
|
||||||
Right(request.getUuid),
|
Right(request.getUuid),
|
||||||
|
|
@ -667,7 +667,7 @@ class RemoteServerHandler(
|
||||||
private def dispatchToTypedActor(request: RemoteMessageProtocol, channel: Channel) = {
|
private def dispatchToTypedActor(request: RemoteMessageProtocol, channel: Channel) = {
|
||||||
val actorInfo = request.getActorInfo
|
val actorInfo = request.getActorInfo
|
||||||
val typedActorInfo = actorInfo.getTypedActorInfo
|
val typedActorInfo = actorInfo.getTypedActorInfo
|
||||||
log.slf4j.debug("Dispatching to remote typed actor [%s :: %s]", typedActorInfo.getMethod, typedActorInfo.getInterface)
|
log.slf4j.debug("Dispatching to remote typed actor [{} :: {}]", typedActorInfo.getMethod, typedActorInfo.getInterface)
|
||||||
|
|
||||||
val typedActor = createTypedActor(actorInfo, channel)
|
val typedActor = createTypedActor(actorInfo, channel)
|
||||||
val args = MessageSerializer.deserialize(request.getMessage).asInstanceOf[Array[AnyRef]].toList
|
val args = MessageSerializer.deserialize(request.getMessage).asInstanceOf[Array[AnyRef]].toList
|
||||||
|
|
@ -693,7 +693,7 @@ class RemoteServerHandler(
|
||||||
None)
|
None)
|
||||||
if (request.hasSupervisorUuid) messageBuilder.setSupervisorUuid(request.getSupervisorUuid)
|
if (request.hasSupervisorUuid) messageBuilder.setSupervisorUuid(request.getSupervisorUuid)
|
||||||
channel.write(messageBuilder.build)
|
channel.write(messageBuilder.build)
|
||||||
log.slf4j.debug("Returning result from remote typed actor invocation [%s]", result)
|
log.slf4j.debug("Returning result from remote typed actor invocation [{}]", result)
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable => server.notifyListeners(RemoteServerError(e, server))
|
case e: Throwable => server.notifyListeners(RemoteServerError(e, server))
|
||||||
}
|
}
|
||||||
|
|
@ -798,7 +798,7 @@ class RemoteServerHandler(
|
||||||
if (RemoteServer.UNTRUSTED_MODE) throw new SecurityException(
|
if (RemoteServer.UNTRUSTED_MODE) throw new SecurityException(
|
||||||
"Remote server is operating is untrusted mode, can not create remote actors on behalf of the remote client")
|
"Remote server is operating is untrusted mode, can not create remote actors on behalf of the remote client")
|
||||||
|
|
||||||
log.slf4j.info("Creating a new remote actor [%s:%s]", name, uuid)
|
log.slf4j.info("Creating a new remote actor [{}:{}]", name, uuid)
|
||||||
val clazz = if (applicationLoader.isDefined) applicationLoader.get.loadClass(name)
|
val clazz = if (applicationLoader.isDefined) applicationLoader.get.loadClass(name)
|
||||||
else Class.forName(name)
|
else Class.forName(name)
|
||||||
val actorRef = Actor.actorOf(clazz.asInstanceOf[Class[_ <: Actor]])
|
val actorRef = Actor.actorOf(clazz.asInstanceOf[Class[_ <: Actor]])
|
||||||
|
|
@ -874,7 +874,7 @@ class RemoteServerHandler(
|
||||||
if (RemoteServer.UNTRUSTED_MODE) throw new SecurityException(
|
if (RemoteServer.UNTRUSTED_MODE) throw new SecurityException(
|
||||||
"Remote server is operating is untrusted mode, can not create remote actors on behalf of the remote client")
|
"Remote server is operating is untrusted mode, can not create remote actors on behalf of the remote client")
|
||||||
|
|
||||||
log.slf4j.info("Creating a new remote typed actor:\n\t[%s :: %s]", interfaceClassname, targetClassname)
|
log.slf4j.info("Creating a new remote typed actor:\n\t[{} :: {}]", interfaceClassname, targetClassname)
|
||||||
|
|
||||||
val (interfaceClass, targetClass) =
|
val (interfaceClass, targetClass) =
|
||||||
if (applicationLoader.isDefined) (applicationLoader.get.loadClass(interfaceClassname),
|
if (applicationLoader.isDefined) (applicationLoader.get.loadClass(interfaceClassname),
|
||||||
|
|
@ -913,7 +913,7 @@ class RemoteServerHandler(
|
||||||
|
|
||||||
private def createErrorReplyMessage(exception: Throwable, request: RemoteMessageProtocol, actorType: AkkaActorType): RemoteMessageProtocol = {
|
private def createErrorReplyMessage(exception: Throwable, request: RemoteMessageProtocol, actorType: AkkaActorType): RemoteMessageProtocol = {
|
||||||
val actorInfo = request.getActorInfo
|
val actorInfo = request.getActorInfo
|
||||||
log.slf4j.error("Could not invoke remote actor [%s]", actorInfo.getTarget)
|
log.slf4j.error("Could not invoke remote actor [{}]", actorInfo.getTarget)
|
||||||
log.slf4j.debug("Could not invoke remote actor", exception)
|
log.slf4j.debug("Could not invoke remote actor", exception)
|
||||||
val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder(
|
val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder(
|
||||||
None,
|
None,
|
||||||
|
|
@ -942,7 +942,7 @@ class RemoteServerHandler(
|
||||||
"The remote client [" + clientAddress + "] does not have a secure cookie.")
|
"The remote client [" + clientAddress + "] does not have a secure cookie.")
|
||||||
if (!(request.getCookie == RemoteServer.SECURE_COOKIE.get)) throw new SecurityException(
|
if (!(request.getCookie == RemoteServer.SECURE_COOKIE.get)) throw new SecurityException(
|
||||||
"The remote client [" + clientAddress + "] secure cookie is not the same as remote server secure cookie")
|
"The remote client [" + clientAddress + "] secure cookie is not the same as remote server secure cookie")
|
||||||
log.slf4j.info("Remote client [%s] successfully authenticated using secure cookie", clientAddress)
|
log.slf4j.info("Remote client [{}] successfully authenticated using secure cookie", clientAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ object RemoteActorSerialization {
|
||||||
* Deserializes a RemoteActorRefProtocol Protocol Buffers (protobuf) Message into an RemoteActorRef instance.
|
* Deserializes a RemoteActorRefProtocol Protocol Buffers (protobuf) Message into an RemoteActorRef instance.
|
||||||
*/
|
*/
|
||||||
private[akka] def fromProtobufToRemoteActorRef(protocol: RemoteActorRefProtocol, loader: Option[ClassLoader]): ActorRef = {
|
private[akka] def fromProtobufToRemoteActorRef(protocol: RemoteActorRefProtocol, loader: Option[ClassLoader]): ActorRef = {
|
||||||
Actor.log.slf4j.debug("Deserializing RemoteActorRefProtocol to RemoteActorRef:\n %s", protocol)
|
Actor.log.slf4j.debug("Deserializing RemoteActorRefProtocol to RemoteActorRef:\n {}", protocol)
|
||||||
RemoteActorRef(
|
RemoteActorRef(
|
||||||
protocol.getClassOrServiceName,
|
protocol.getClassOrServiceName,
|
||||||
protocol.getActorClassname,
|
protocol.getActorClassname,
|
||||||
|
|
@ -244,7 +244,7 @@ object RemoteActorSerialization {
|
||||||
val host = homeAddress.getHostName
|
val host = homeAddress.getHostName
|
||||||
val port = homeAddress.getPort
|
val port = homeAddress.getPort
|
||||||
|
|
||||||
Actor.log.slf4j.debug("Register serialized Actor [%s] as remote @ [%s:%s]", Array(actorClassName, host, port))
|
Actor.log.slf4j.debug("Register serialized Actor [{}] as remote @ [{}:{}]", Array(actorClassName, host, port))
|
||||||
RemoteServer.getOrCreateServer(homeAddress)
|
RemoteServer.getOrCreateServer(homeAddress)
|
||||||
ActorRegistry.registerActorByUuid(homeAddress, uuid.toString, ar)
|
ActorRegistry.registerActorByUuid(homeAddress, uuid.toString, ar)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ object ServerInitiatedRemoteActorClient extends Logging {
|
||||||
def run = {
|
def run = {
|
||||||
val actor = RemoteClient.actorFor("hello-service", "localhost", 2552)
|
val actor = RemoteClient.actorFor("hello-service", "localhost", 2552)
|
||||||
val result = actor !! "Hello"
|
val result = actor !! "Hello"
|
||||||
log.slf4j.info("Result from Remote Actor: %s", result)
|
log.slf4j.info("Result from Remote Actor: {}", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
def main(args: Array[String]) = run
|
def main(args: Array[String]) = run
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,4 @@ class Ticket506Spec extends Spec with ShouldMatchers {
|
||||||
s2.shutdown
|
s2.shutdown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ object ClientManagedRemoteActorClient extends Logging {
|
||||||
log.slf4j.info("Remote actor created, moved to the server")
|
log.slf4j.info("Remote actor created, moved to the server")
|
||||||
log.slf4j.info("Sending 'Hello' to remote actor")
|
log.slf4j.info("Sending 'Hello' to remote actor")
|
||||||
val result = actor !! "Hello"
|
val result = actor !! "Hello"
|
||||||
log.slf4j.info("Result from Remote Actor: '%s'", result.get)
|
log.slf4j.info("Result from Remote Actor: '{}'", result.get)
|
||||||
}
|
}
|
||||||
|
|
||||||
def main(args: Array[String]) = run
|
def main(args: Array[String]) = run
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ object ServerManagedRemoteActorClient extends Logging {
|
||||||
log.slf4j.info("Remote client created")
|
log.slf4j.info("Remote client created")
|
||||||
log.slf4j.info("Sending 'Hello' to remote actor")
|
log.slf4j.info("Sending 'Hello' to remote actor")
|
||||||
val result = actor !! "Hello"
|
val result = actor !! "Hello"
|
||||||
log.slf4j.info("Result from Remote Actor: '%s'", result.get)
|
log.slf4j.info("Result from Remote Actor: '{}'", result.get)
|
||||||
}
|
}
|
||||||
|
|
||||||
def main(args: Array[String]) = run
|
def main(args: Array[String]) = run
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ private[akka] class TypedActorGuiceConfigurator extends TypedActorConfiguratorBa
|
||||||
* @return the typed actors for the class
|
* @return the typed actors for the class
|
||||||
*/
|
*/
|
||||||
def getInstance[T](clazz: Class[T]): List[T] = synchronized {
|
def getInstance[T](clazz: Class[T]): List[T] = synchronized {
|
||||||
log.slf4j.debug("Retrieving typed actor [%s]", clazz.getName)
|
log.slf4j.debug("Retrieving typed actor [{}]", clazz.getName)
|
||||||
if (injector eq null) throw new IllegalActorStateException(
|
if (injector eq null) throw new IllegalActorStateException(
|
||||||
"inject() and/or supervise() must be called before invoking getInstance(clazz)")
|
"inject() and/or supervise() must be called before invoking getInstance(clazz)")
|
||||||
val (proxy, targetInstance, component) =
|
val (proxy, targetInstance, component) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue