Revision 2f474111
b/src/main/scala/gr/grnet/aquarium/Main.scala | ||
---|---|---|
36 | 36 |
package gr.grnet.aquarium |
37 | 37 |
|
38 | 38 |
import util.Loggable |
39 |
import akka.actor.Actor |
|
39 | 40 |
|
40 | 41 |
/** |
41 | 42 |
* Main method for Aquarium |
... | ... | |
54 | 55 |
def run = { |
55 | 56 |
logger.info("Shutting down Aquarium") |
56 | 57 |
Configurator.MasterConfigurator.stopServices() |
58 |
Actor.registry.shutdownAll() |
|
57 | 59 |
} |
58 | 60 |
})) |
59 | 61 |
|
b/src/main/scala/gr/grnet/aquarium/user/actor/UserActorManager.scala | ||
---|---|---|
89 | 89 |
case m @ AquariumPropertiesLoaded(props) ⇒ |
90 | 90 |
logger.debug("Received and ignoring %s".format(m)) |
91 | 91 |
|
92 |
case m @ ActorProviderConfigured(actorProvicer) ⇒
|
|
93 |
this._actorProvider = actorProvicer
|
|
92 |
case m @ ActorProviderConfigured(actorProvider) ⇒
|
|
93 |
this._actorProvider = actorProvider
|
|
94 | 94 |
logger.info("Configured %s with %s".format(this, m)) |
95 | 95 |
|
96 | 96 |
case m @ RequestUserBalance(userId, timestamp) ⇒ |
... | ... | |
105 | 105 |
case m @ ProcessUserEvent(userEvent) ⇒ |
106 | 106 |
_forwardToUserActor(userEvent.userId, m) |
107 | 107 |
} |
108 |
|
|
109 |
override def postStop = { |
|
110 |
logger.debug("Shutting down and stopping all user actors") |
|
111 |
userActorLRU.shutdownAll() |
|
112 |
} |
|
108 | 113 |
} |
b/src/main/scala/gr/grnet/aquarium/user/actor/UserActorsLRU.scala | ||
---|---|---|
38 | 38 |
import org.apache.solr.util.ConcurrentLRUCache |
39 | 39 |
import akka.actor.ActorRef |
40 | 40 |
import gr.grnet.aquarium.util.{Loggable, Lifecycle} |
41 |
import collection.JavaConversions._ |
|
41 | 42 |
|
42 | 43 |
/** |
43 | 44 |
* This class holds an LRU cache for the user actors. |
... | ... | |
70 | 71 |
} |
71 | 72 |
} |
72 | 73 |
|
74 |
def shutdownAll() = { |
|
75 |
val accessed = mapAsScalaMap(_cache.getLatestAccessedItems(_cache.size())) |
|
76 |
|
|
77 |
//Send the poison pill and make sure that all futures have been returned |
|
78 |
val futures = accessed.keys.map{x => _cache.get(x).stop()} |
|
79 |
} |
|
80 |
|
|
73 | 81 |
def size: Int = _cache.size() |
74 | 82 |
def clear: Unit = _cache.clear() |
75 | 83 |
|
... | ... | |
83 | 91 |
def evictedEntry(userId: String, userActor: ActorRef): Unit = { |
84 | 92 |
logger.debug("Parking UserActor for userId = %s".format(userId)) |
85 | 93 |
// Check this is received after any currently servicing business logic message. |
86 |
userActor ! UserActorStop
|
|
94 |
userActor.stop()
|
|
87 | 95 |
// Hopefully no need to further track these actors as they will now cause their own death. |
88 | 96 |
} |
89 | 97 |
} |
b/src/test/resources/log4j.properties | ||
---|---|---|
2 | 2 |
|
3 | 3 |
log4j.appender.console=org.apache.log4j.ConsoleAppender |
4 | 4 |
log4j.appender.console.layout=org.apache.log4j.PatternLayout |
5 |
log4j.appender.console.layout.ConversionPattern=%d %t %F:%L - %m%n |
|
5 |
log4j.appender.console.layout.ConversionPattern=[%-5p] %d %t %F:%L - %m%n
|
|
6 | 6 |
log4j.appender.console.threshold=DEBUG |
Also available in: Unified diff