diff --git a/config/akka-reference.conf b/config/akka-reference.conf index 60aefb99fc..ed4a29fbfb 100644 --- a/config/akka-reference.conf +++ b/config/akka-reference.conf @@ -1,62 +1,73 @@ -#################### -# Akka Config File # -#################### - -# This file has all the default settings, so all these could be remove with no visible effect. -# Modify as needed. - - - filename = "./logs/akka.log" - roll = "daily" # Options: never, hourly, daily, sunday/monday/... - level = "debug" # Options: fatal, critical, error, warning, info, debug, trace - console = on - # syslog_host = "" - # syslog_server_name = "" - - - - version = "v0.5" - - #boot = ["sample.scala.Boot"] # FQN to the class doing initial active object/actor - boot = ["sample.java.Boot", "sample.scala.Boot"] # FQN to the class doing initial active object/actor - # supervisor bootstrap, should be defined in default constructor - - timeout = 5000 # default timeout for future based invocations - serialize-messages = off # does a deep clone of (non-primitive) messages to ensure immutability - - - - service = on - restart-on-collision = off # (not implemented yet) if 'on' then it reschedules the transaction, - # if 'off' then throws an exception or rollback for user to handle - wait-for-completion = 100 # how long time in millis a transaction should be given time to complete when a collision is detected - wait-nr-of-times = 3 # the number of times it should check for completion of a pending transaction upon collision - distributed = off # not implemented yet - - - - service = on - hostname = "localhost" - port = 9999 - connection-timeout = 1000 # in millis - - - - service = on - hostname = "localhost" - port = 9998 - - - - system = "cassandra" # Options: cassandra (coming: terracotta, mongodb, redis, tokyo-cabinet, voldemort, memcached) - - - service = on - hostname = "127.0.0.1" # ip address or hostname of one of the Cassandra cluster's seeds - port = 9160 - storage-format = "java" # Options: java, scala-json, java-json, protobuf - consistency-level = 1 # - - - - +#################### +# Akka Config File # +#################### + +# This file has all the default settings, so all these could be remove with no visible effect. +# Modify as needed. + + + filename = "./logs/akka.log" + roll = "daily" # Options: never, hourly, daily, sunday/monday/... + level = "debug" # Options: fatal, critical, error, warning, info, debug, trace + console = on + # syslog_host = "" + # syslog_server_name = "" + + + + version = "v0.5" + + #boot = ["sample.scala.Boot"] # FQN to the class doing initial active object/actor + boot = ["sample.java.Boot", "sample.scala.Boot"] # FQN to the class doing initial active object/actor + # supervisor bootstrap, should be defined in default constructor + + timeout = 5000 # default timeout for future based invocations + serialize-messages = off # does a deep clone of (non-primitive) messages to ensure immutability + + + + service = on + restart-on-collision = off # (not implemented yet) if 'on' then it reschedules the transaction, + # if 'off' then throws an exception or rollback for user to handle + wait-for-completion = 100 # how long time in millis a transaction should be given time to complete when a collision is detected + wait-nr-of-times = 3 # the number of times it should check for completion of a pending transaction upon collision + distributed = off # not implemented yet + + + + service = on + hostname = "localhost" + port = 9999 + connection-timeout = 1000 # in millis + + + + service = on + hostname = "localhost" + port = 9998 + + + + system = "cassandra" # Options: cassandra (coming: terracotta, mongodb, redis, tokyo-cabinet, voldemort, memcached) + + + service = on + hostname = "127.0.0.1" # ip address or hostname of one of the Cassandra cluster's seeds + port = 9160 + storage-format = "java" # Options: java, scala-json, java-json, protobuf + consistency-level = 1 # + + + + system = "mongodb" + + + service = on + hostname = "127.0.0.1" # ip address or hostname of one of the Cassandra cluster's seeds + port = 27017 + dbname = "mydb" + storage-format = "scala-json" # Options: java, scala-json, java-json, protobuf + + + + diff --git a/kernel/src/main/scala/state/MongoStorage.scala b/kernel/src/main/scala/state/MongoStorage.scala index ec903aa2e9..657a6ec9fc 100644 --- a/kernel/src/main/scala/state/MongoStorage.scala +++ b/kernel/src/main/scala/state/MongoStorage.scala @@ -3,6 +3,7 @@ package se.scalablesolutions.akka.kernel.state import com.mongodb._ import se.scalablesolutions.akka.kernel.util.Logging import serialization.{Serializer} +import kernel.Kernel.config import java.util.{Map=>JMap, List=>JList, ArrayList=>JArrayList} @@ -23,18 +24,28 @@ object MongoStorage extends MapStorage val KEY = "key" val VALUE = "value" - val db = new Mongo("mydb"); // @fixme: need to externalize val COLLECTION = "akka_coll" + val MONGODB_SERVER_HOSTNAME = + config.getString("akka.storage.mongodb.hostname", "127.0.0.1") + val MONGODB_SERVER_DBNAME = + config.getString("akka.storage.mongodb.dbname", "testdb") + val MONGODB_SERVER_PORT = + config.getInt("akka.storage.mongodb.port", 27017) + + val db = new Mongo(MONGODB_SERVER_HOSTNAME, + MONGODB_SERVER_PORT, MONGODB_SERVER_DBNAME) val coll = db.getCollection(COLLECTION) - + // @fixme: make this pluggable private[this] val serializer: Serializer = Serializer.ScalaJSON - override def insertMapStorageEntryFor(name: String, key: AnyRef, value: AnyRef) { + override def insertMapStorageEntryFor(name: String, + key: AnyRef, value: AnyRef) { insertMapStorageEntriesFor(name, List((key, value))) } - override def insertMapStorageEntriesFor(name: String, entries: List[Tuple2[AnyRef, AnyRef]]) { + override def insertMapStorageEntriesFor(name: String, + entries: List[Tuple2[AnyRef, AnyRef]]) { import java.util.{Map, HashMap} val m: Map[AnyRef, AnyRef] = new HashMap @@ -79,7 +90,8 @@ object MongoStorage extends MapStorage } } - override def getMapStorageEntryFor(name: String, key: AnyRef): Option[AnyRef] = { + override def getMapStorageEntryFor(name: String, + key: AnyRef): Option[AnyRef] = { getValueForKey(name, key.asInstanceOf[String]) } @@ -206,7 +218,8 @@ object MongoStorage extends MapStorage } } - override def getVectorStorageRangeFor(name: String, start: Option[Int], finish: Option[Int], count: Int): List[AnyRef] = { + override def getVectorStorageRangeFor(name: String, + start: Option[Int], finish: Option[Int], count: Int): List[AnyRef] = { try { val o = nullSafeFindOne(name) match {