merged master into spring
This commit is contained in:
commit
581b968d0f
112 changed files with 961 additions and 2638 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,5 +1,9 @@
|
|||
*~
|
||||
*#
|
||||
project/boot/*
|
||||
*/project/build/target
|
||||
*/project/boot
|
||||
lib_managed
|
||||
etags
|
||||
TAGS
|
||||
reports
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-amqp</artifactId>
|
||||
<name>Akka AMQP Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rabbitmq</groupId>
|
||||
<artifactId>amqp-client</artifactId>
|
||||
<version>1.7.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-cluster-jgroups</artifactId>
|
||||
<name>Akka Cluster JGroups Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>jgroups</groupId>
|
||||
<artifactId>jgroups</artifactId>
|
||||
<version>2.8.0.CR7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,15 +1,17 @@
|
|||
package se.scalablesolutions.akka.remote
|
||||
package se.scalablesolutions.akka.cluster.jgroups
|
||||
|
||||
import org.jgroups.{JChannel, View => JG_VIEW, Address, Message => JG_MSG, ExtendedMembershipListener, Receiver}
|
||||
|
||||
import se.scalablesolutions.akka.remote.ClusterActor._
|
||||
import se.scalablesolutions.akka.remote.BasicClusterActor
|
||||
|
||||
import org.scala_tools.javautils.Imports._
|
||||
|
||||
/**
|
||||
* Clustering support via JGroups.
|
||||
* @Author Viktor Klang
|
||||
*/
|
||||
class JGroupsClusterActor extends BasicClusterActor {
|
||||
import ClusterActor._
|
||||
import org.scala_tools.javautils.Imports._
|
||||
|
||||
type ADDR_T = Address
|
||||
|
||||
@volatile private var isActive = false
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-cluster-shoal</artifactId>
|
||||
<name>Akka Cluster Shoal Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<!--dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>shoal</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency-->
|
||||
<dependency>
|
||||
<groupId>shoal-jxta</groupId>
|
||||
<artifactId>shoal</artifactId>
|
||||
<version>1.1-20090818</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>shoal-jxta</groupId>
|
||||
<artifactId>jxta</artifactId>
|
||||
<version>1.1-20090818</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,29 +1,16 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
package se.scalablesolutions.akka.remote
|
||||
package se.scalablesolutions.akka.cluster.shoal
|
||||
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import java.util.Properties
|
||||
|
||||
import com.sun.enterprise.ee.cms.core.{CallBack,
|
||||
GMSConstants,
|
||||
GMSFactory,
|
||||
GroupManagementService,
|
||||
MessageSignal,
|
||||
Signal,
|
||||
GMSException,
|
||||
SignalAcquireException,
|
||||
SignalReleaseException,
|
||||
JoinNotificationSignal,
|
||||
FailureSuspectedSignal,
|
||||
FailureNotificationSignal }
|
||||
import com.sun.enterprise.ee.cms.impl.client.{FailureNotificationActionFactoryImpl,
|
||||
FailureSuspectedActionFactoryImpl,
|
||||
JoinNotificationActionFactoryImpl,
|
||||
MessageActionFactoryImpl,
|
||||
PlannedShutdownActionFactoryImpl
|
||||
}
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
import se.scalablesolutions.akka.remote.{ClusterActor, BasicClusterActor, RemoteServer}
|
||||
|
||||
import com.sun.enterprise.ee.cms.core._
|
||||
import com.sun.enterprise.ee.cms.impl.client._
|
||||
|
||||
/**
|
||||
* Clustering support via Shoal.
|
||||
*/
|
||||
|
|
@ -67,9 +54,9 @@ class ShoalClusterActor extends BasicClusterActor {
|
|||
* Adds callbacks and boots up the cluster
|
||||
*/
|
||||
protected def createGMS : GroupManagementService = {
|
||||
|
||||
val g = GMSFactory.startGMSModule(serverName,name, GroupManagementService.MemberType.CORE, properties()).asInstanceOf[GroupManagementService]
|
||||
|
||||
val g = GMSFactory
|
||||
.startGMSModule(serverName,name, GroupManagementService.MemberType.CORE, properties())
|
||||
.asInstanceOf[GroupManagementService]
|
||||
val callback = createCallback
|
||||
g.addActionFactory(new JoinNotificationActionFactoryImpl(callback))
|
||||
g.addActionFactory(new FailureSuspectedActionFactoryImpl(callback))
|
||||
|
|
@ -102,8 +89,8 @@ class ShoalClusterActor extends BasicClusterActor {
|
|||
}
|
||||
signal.release()
|
||||
} catch {
|
||||
case e : SignalAcquireException => log.warning(e,"SignalAcquireException")
|
||||
case e : SignalReleaseException => log.warning(e,"SignalReleaseException")
|
||||
case e : SignalAcquireException => log.warning(e,"SignalAcquireException")
|
||||
case e : SignalReleaseException => log.warning(e,"SignalReleaseException")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-cluster-tribes</artifactId>
|
||||
<name>Akka Cluster Tribes Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tribes</artifactId>
|
||||
<version>6.0.20</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<name>Akka Cluster Modules</name>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>akka-cluster-jgroups</module>
|
||||
<!--module>akka-cluster-tribes</module-->
|
||||
<module>akka-cluster-shoal</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- For Testing -->
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-comet</artifactId>
|
||||
<name>Akka Comet Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-rest</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For the Bootable -->
|
||||
<dependency>
|
||||
<groupId>com.sun.grizzly</groupId>
|
||||
<artifactId>grizzly-comet-webserver</artifactId>
|
||||
<version>${grizzly.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Atmosphere -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-annotations</artifactId>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-jersey</artifactId>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-runtime</artifactId>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
package se.scalablesolutions.akka.comet
|
||||
|
||||
import se.scalablesolutions.akka.actor.{Actor}
|
||||
import se.scalablesolutions.akka.remote.{Cluster}
|
||||
import scala.reflect.{BeanProperty}
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
import se.scalablesolutions.akka.remote.Cluster
|
||||
import scala.reflect.BeanProperty
|
||||
import org.atmosphere.cpr.{BroadcastFilter, ClusterBroadcastFilter, Broadcaster}
|
||||
|
||||
sealed trait ClusterCometMessageType
|
||||
case class ClusterCometBroadcast(val name : String, val msg : AnyRef) extends ClusterCometMessageType
|
||||
case class ClusterCometBroadcast(name: String, msg: AnyRef) extends ClusterCometMessageType
|
||||
|
||||
/**
|
||||
* Enables explicit clustering of Atmosphere (Comet) resources
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka
|
||||
package se.scalablesolutions.akka.comet
|
||||
|
||||
import com.sun.grizzly.http.SelectorThread
|
||||
import com.sun.grizzly.http.servlet.ServletAdapter
|
||||
import com.sun.grizzly.standalone.StaticStreamAlgorithm
|
||||
|
||||
import javax.ws.rs.core.UriBuilder
|
||||
import se.scalablesolutions.akka.comet.AkkaServlet
|
||||
|
||||
import se.scalablesolutions.akka.actor.BootableActorLoaderService
|
||||
import se.scalablesolutions.akka.util.{Bootable,Logging}
|
||||
import se.scalablesolutions.akka.util.{Bootable, Logging}
|
||||
|
||||
/**
|
||||
* Handles the Akka Comet Support (load/unload)
|
||||
|
|
@ -19,16 +19,17 @@ import se.scalablesolutions.akka.util.{Bootable,Logging}
|
|||
trait BootableCometActorService extends Bootable with Logging {
|
||||
self : BootableActorLoaderService =>
|
||||
|
||||
import Config._
|
||||
import config.Config._
|
||||
|
||||
val REST_HOSTNAME = config.getString("akka.rest.hostname", "localhost")
|
||||
val REST_URL = "http://" + REST_HOSTNAME
|
||||
val REST_PORT = config.getInt("akka.rest.port", 9998)
|
||||
|
||||
protected var jerseySelectorThread: Option[SelectorThread] = None
|
||||
|
||||
abstract override def onLoad = {
|
||||
super.onLoad
|
||||
if(config.getBool("akka.rest.service", true)){
|
||||
if (config.getBool("akka.rest.service", true)) {
|
||||
|
||||
val uri = UriBuilder.fromUri(REST_URL).port(REST_PORT).build()
|
||||
|
||||
|
|
@ -42,8 +43,7 @@ trait BootableCometActorService extends Bootable with Logging {
|
|||
adapter.setHandleStaticResources(true)
|
||||
adapter.setServletInstance(new AkkaServlet)
|
||||
adapter.setContextPath(uri.getPath)
|
||||
//Using autodetection for now
|
||||
//adapter.addInitParameter("cometSupport", "org.atmosphere.container.GrizzlyCometSupport")
|
||||
adapter.addInitParameter("cometSupport", "org.atmosphere.container.GrizzlyCometSupport")
|
||||
if (HOME.isDefined) adapter.setRootFolder(HOME.get + "/deploy/root")
|
||||
log.info("REST service root path [%s] and context path [%s]", adapter.getRootFolder, adapter.getContextPath)
|
||||
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-core</artifactId>
|
||||
<name>Akka Core - Actors, Remote Actors, Transactors and STM Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-util-java</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-util</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>${scala.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.aspectwerkz</groupId>
|
||||
<artifactId>aspectwerkz-nodeps-jdk5</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.aspectwerkz</groupId>
|
||||
<artifactId>aspectwerkz-jdk5</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.netty</groupId>
|
||||
<artifactId>netty</artifactId>
|
||||
<version>3.2.0.ALPHA3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.multiverse</groupId>
|
||||
<artifactId>multiverse-alpha</artifactId>
|
||||
<version>0.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-tools</groupId>
|
||||
<artifactId>javautils</artifactId>
|
||||
<version>2.7.4-0.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Protocol/Serialization -->
|
||||
<dependency>
|
||||
<groupId>voldemort.store.compress</groupId>
|
||||
<artifactId>h2-lzf</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>sbinary</groupId>
|
||||
<artifactId>sbinary</artifactId>
|
||||
<version>0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.databinder</groupId>
|
||||
<artifactId>dispatch-json_2.7.7</artifactId>
|
||||
<version>0.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.databinder</groupId>
|
||||
<artifactId>dispatch-http_2.7.7</artifactId>
|
||||
<version>0.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>sjson.json</groupId>
|
||||
<artifactId>sjson</artifactId>
|
||||
<version>0.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Testing -->
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import se.scalablesolutions.akka.Config._
|
||||
import se.scalablesolutions.akka.dispatch._
|
||||
import se.scalablesolutions.akka.config.Config._
|
||||
import se.scalablesolutions.akka.config.{AllForOneStrategy, OneForOneStrategy, FaultHandlingStrategy}
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.stm.Transaction._
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ package se.scalablesolutions.akka.actor
|
|||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
|
||||
import se.scalablesolutions.akka.util.{Bootable,Logging}
|
||||
import se.scalablesolutions.akka.Config._
|
||||
import se.scalablesolutions.akka.util.{Bootable, Logging}
|
||||
import se.scalablesolutions.akka.config.Config._
|
||||
|
||||
/**
|
||||
* Handles all modules in the deploy directory (load and unload)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import java.util.concurrent._
|
|||
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.config.{AllForOneStrategy, OneForOneStrategy, FaultHandlingStrategy}
|
||||
import se.scalablesolutions.akka.util.{Logging}
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
import org.scala_tools.javautils.Imports._
|
||||
|
||||
|
|
|
|||
|
|
@ -4,231 +4,71 @@
|
|||
|
||||
package se.scalablesolutions.akka.config
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
import se.scalablesolutions.akka.dispatch.MessageDispatcher
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
sealed abstract class FaultHandlingStrategy
|
||||
case class AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Int) extends FaultHandlingStrategy
|
||||
case class OneForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Int) extends FaultHandlingStrategy
|
||||
|
||||
/**
|
||||
* Configuration classes - not to be used as messages.
|
||||
*
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object ScalaConfig {
|
||||
sealed abstract class ConfigElement
|
||||
|
||||
abstract class Server extends ConfigElement
|
||||
abstract class FailOverScheme extends ConfigElement
|
||||
abstract class Scope extends ConfigElement
|
||||
|
||||
case class SupervisorConfig(restartStrategy: RestartStrategy, worker: List[Server]) extends Server
|
||||
|
||||
class Supervise(val actor: Actor, val lifeCycle: LifeCycle, _remoteAddress: RemoteAddress) extends Server {
|
||||
val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress)
|
||||
}
|
||||
object Supervise {
|
||||
def apply(actor: Actor, lifeCycle: LifeCycle, remoteAddress: RemoteAddress) = new Supervise(actor, lifeCycle, remoteAddress)
|
||||
def apply(actor: Actor, lifeCycle: LifeCycle) = new Supervise(actor, lifeCycle, null)
|
||||
def unapply(supervise: Supervise) = Some((supervise.actor, supervise.lifeCycle, supervise.remoteAddress))
|
||||
}
|
||||
|
||||
case class RestartStrategy(
|
||||
scheme: FailOverScheme,
|
||||
maxNrOfRetries: Int,
|
||||
withinTimeRange: Int,
|
||||
trapExceptions: List[Class[_ <: Throwable]]) extends ConfigElement
|
||||
|
||||
case object AllForOne extends FailOverScheme
|
||||
case object OneForOne extends FailOverScheme
|
||||
|
||||
case class LifeCycle(scope: Scope, callbacks: Option[RestartCallbacks]) extends ConfigElement
|
||||
object LifeCycle {
|
||||
def apply(scope: Scope) = new LifeCycle(scope, None)
|
||||
}
|
||||
case class RestartCallbacks(preRestart: String, postRestart: String) {
|
||||
if ((preRestart eq null) || (postRestart eq null)) throw new IllegalArgumentException("Restart callback methods can't be null")
|
||||
}
|
||||
|
||||
case object Permanent extends Scope
|
||||
case object Temporary extends Scope
|
||||
|
||||
case class RemoteAddress(val hostname: String, val port: Int) extends ConfigElement
|
||||
|
||||
class Component(_intf: Class[_],
|
||||
val target: Class[_],
|
||||
val lifeCycle: LifeCycle,
|
||||
val timeout: Int,
|
||||
val transactionRequired: Boolean,
|
||||
_dispatcher: MessageDispatcher, // optional
|
||||
_remoteAddress: RemoteAddress // optional
|
||||
) extends Server {
|
||||
val intf: Option[Class[_]] = if (_intf eq null) None else Some(_intf)
|
||||
val dispatcher: Option[MessageDispatcher] = if (_dispatcher eq null) None else Some(_dispatcher)
|
||||
val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress)
|
||||
}
|
||||
object Component {
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
new Component(null, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
new Component(null, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, dispatcher, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, false, dispatcher, remoteAddress)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress)
|
||||
}
|
||||
}
|
||||
import net.lag.configgy.{Configgy, ParseException}
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object JavaConfig {
|
||||
import scala.reflect.BeanProperty
|
||||
object Config extends Logging {
|
||||
val VERSION = "0.7-SNAPSHOT"
|
||||
|
||||
sealed abstract class ConfigElement
|
||||
// Set Multiverse options for max speed
|
||||
System.setProperty("org.multiverse.MuliverseConstants.sanityChecks", "false")
|
||||
System.setProperty("org.multiverse.api.GlobalStmInstance.factorymethod", "org.multiverse.stms.alpha.AlphaStm.createFast")
|
||||
|
||||
class RestartStrategy(
|
||||
@BeanProperty val scheme: FailOverScheme,
|
||||
@BeanProperty val maxNrOfRetries: Int,
|
||||
@BeanProperty val withinTimeRange: Int,
|
||||
@BeanProperty val trapExceptions: Array[Class[_ <: Throwable]]) extends ConfigElement {
|
||||
def transform = se.scalablesolutions.akka.config.ScalaConfig.RestartStrategy(
|
||||
scheme.transform, maxNrOfRetries, withinTimeRange, trapExceptions.toList)
|
||||
val HOME = {
|
||||
val systemHome = System.getenv("AKKA_HOME")
|
||||
if (systemHome == null || systemHome.length == 0 || systemHome == ".") {
|
||||
val optionHome = System.getProperty("akka.home", "")
|
||||
if (optionHome.length != 0) Some(optionHome)
|
||||
else None
|
||||
} else Some(systemHome)
|
||||
}
|
||||
|
||||
class LifeCycle(@BeanProperty val scope: Scope, @BeanProperty val callbacks: RestartCallbacks) extends ConfigElement {
|
||||
def this(scope: Scope) = this(scope, null)
|
||||
def transform = {
|
||||
val callbackOption = if (callbacks eq null) None else Some(callbacks.transform)
|
||||
se.scalablesolutions.akka.config.ScalaConfig.LifeCycle(scope.transform, callbackOption)
|
||||
|
||||
val config = {
|
||||
if (HOME.isDefined) {
|
||||
try {
|
||||
val configFile = HOME.get + "/config/akka.conf"
|
||||
Configgy.configure(configFile)
|
||||
log.info("AKKA_HOME is defined to [%s], config loaded from [%s].", HOME.get, configFile)
|
||||
} catch {
|
||||
case e: ParseException => throw new IllegalStateException(
|
||||
"'akka.conf' config file can not be found in [" + HOME + "/config/akka.conf] aborting." +
|
||||
"\n\tEither add it in the 'config' directory or add it to the classpath.")
|
||||
}
|
||||
} else if (System.getProperty("akka.config", "") != "") {
|
||||
val configFile = System.getProperty("akka.config", "")
|
||||
try {
|
||||
Configgy.configure(configFile)
|
||||
log.info("Config loaded from -Dakka.config=%s", configFile)
|
||||
} catch {
|
||||
case e: ParseException => throw new IllegalStateException(
|
||||
"Config could not be loaded from -Dakka.config=" + configFile)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Configgy.configureFromResource("akka.conf", getClass.getClassLoader)
|
||||
log.info("Config loaded from the application classpath.")
|
||||
} catch {
|
||||
case e: ParseException => throw new IllegalStateException(
|
||||
"\nCan't find 'akka.conf' configuration file." +
|
||||
"\nOne of the three ways of locating the 'akka.conf' file needs to be defined:" +
|
||||
"\n\t1. Define 'AKKA_HOME' environment variable to the root of the Akka distribution." +
|
||||
"\n\t2. Define the '-Dakka.config=...' system property option." +
|
||||
"\n\t3. Put the 'akka.conf' file on the classpath." +
|
||||
"\nI have no way of finding the 'akka.conf' configuration file." +
|
||||
"\nAborting.")
|
||||
}
|
||||
}
|
||||
Configgy.config
|
||||
}
|
||||
|
||||
class RestartCallbacks(@BeanProperty val preRestart: String, @BeanProperty val postRestart: String) {
|
||||
def transform = se.scalablesolutions.akka.config.ScalaConfig.RestartCallbacks(preRestart, postRestart)
|
||||
}
|
||||
val CONFIG_VERSION = config.getString("akka.version", "0")
|
||||
if (VERSION != CONFIG_VERSION) throw new IllegalStateException(
|
||||
"Akka JAR version [" + VERSION + "] is different than the provided config ('akka.conf') version [" + CONFIG_VERSION + "]")
|
||||
val startTime = System.currentTimeMillis
|
||||
|
||||
abstract class Scope extends ConfigElement {
|
||||
def transform: se.scalablesolutions.akka.config.ScalaConfig.Scope
|
||||
}
|
||||
class Permanent extends Scope {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.Permanent
|
||||
}
|
||||
class Temporary extends Scope {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.Temporary
|
||||
}
|
||||
|
||||
abstract class FailOverScheme extends ConfigElement {
|
||||
def transform: se.scalablesolutions.akka.config.ScalaConfig.FailOverScheme
|
||||
}
|
||||
class AllForOne extends FailOverScheme {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.AllForOne
|
||||
}
|
||||
class OneForOne extends FailOverScheme {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.OneForOne
|
||||
}
|
||||
|
||||
class RemoteAddress(@BeanProperty val hostname: String, @BeanProperty val port: Int)
|
||||
|
||||
abstract class Server extends ConfigElement
|
||||
class Component(@BeanProperty val intf: Class[_],
|
||||
@BeanProperty val target: Class[_],
|
||||
@BeanProperty val lifeCycle: LifeCycle,
|
||||
@BeanProperty val timeout: Int,
|
||||
@BeanProperty val transactionRequired: Boolean, // optional
|
||||
@BeanProperty val dispatcher: MessageDispatcher, // optional
|
||||
@BeanProperty val remoteAddress: RemoteAddress // optional
|
||||
) extends Server {
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
this(intf, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
this(null, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
this(intf, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
this(intf, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
this(null, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, false, dispatcher, remoteAddress)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
this(intf, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
this(intf, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
this(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress)
|
||||
|
||||
def transform =
|
||||
se.scalablesolutions.akka.config.ScalaConfig.Component(
|
||||
intf, target, lifeCycle.transform, timeout, transactionRequired, dispatcher,
|
||||
if (remoteAddress ne null) se.scalablesolutions.akka.config.ScalaConfig.RemoteAddress(remoteAddress.hostname, remoteAddress.port) else null)
|
||||
|
||||
def newSupervised(actor: Actor) =
|
||||
se.scalablesolutions.akka.config.ScalaConfig.Supervise(actor, lifeCycle.transform)
|
||||
}
|
||||
|
||||
}
|
||||
def uptime = (System.currentTimeMillis - startTime) / 1000
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package se.scalablesolutions.akka.config
|
|||
|
||||
import scala.collection.mutable.HashSet
|
||||
|
||||
import util.Logging
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
object ConfiguratorRepository extends Logging {
|
||||
|
||||
|
|
|
|||
234
akka-core/src/main/scala/config/SupervisionConfig.scala
Normal file
234
akka-core/src/main/scala/config/SupervisionConfig.scala
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.config
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
import se.scalablesolutions.akka.dispatch.MessageDispatcher
|
||||
|
||||
sealed abstract class FaultHandlingStrategy
|
||||
case class AllForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Int) extends FaultHandlingStrategy
|
||||
case class OneForOneStrategy(maxNrOfRetries: Int, withinTimeRange: Int) extends FaultHandlingStrategy
|
||||
|
||||
/**
|
||||
* Configuration classes - not to be used as messages.
|
||||
*
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object ScalaConfig {
|
||||
sealed abstract class ConfigElement
|
||||
|
||||
abstract class Server extends ConfigElement
|
||||
abstract class FailOverScheme extends ConfigElement
|
||||
abstract class Scope extends ConfigElement
|
||||
|
||||
case class SupervisorConfig(restartStrategy: RestartStrategy, worker: List[Server]) extends Server
|
||||
|
||||
class Supervise(val actor: Actor, val lifeCycle: LifeCycle, _remoteAddress: RemoteAddress) extends Server {
|
||||
val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress)
|
||||
}
|
||||
object Supervise {
|
||||
def apply(actor: Actor, lifeCycle: LifeCycle, remoteAddress: RemoteAddress) = new Supervise(actor, lifeCycle, remoteAddress)
|
||||
def apply(actor: Actor, lifeCycle: LifeCycle) = new Supervise(actor, lifeCycle, null)
|
||||
def unapply(supervise: Supervise) = Some((supervise.actor, supervise.lifeCycle, supervise.remoteAddress))
|
||||
}
|
||||
|
||||
case class RestartStrategy(
|
||||
scheme: FailOverScheme,
|
||||
maxNrOfRetries: Int,
|
||||
withinTimeRange: Int,
|
||||
trapExceptions: List[Class[_ <: Throwable]]) extends ConfigElement
|
||||
|
||||
case object AllForOne extends FailOverScheme
|
||||
case object OneForOne extends FailOverScheme
|
||||
|
||||
case class LifeCycle(scope: Scope, callbacks: Option[RestartCallbacks]) extends ConfigElement
|
||||
object LifeCycle {
|
||||
def apply(scope: Scope) = new LifeCycle(scope, None)
|
||||
}
|
||||
case class RestartCallbacks(preRestart: String, postRestart: String) {
|
||||
if ((preRestart eq null) || (postRestart eq null)) throw new IllegalArgumentException("Restart callback methods can't be null")
|
||||
}
|
||||
|
||||
case object Permanent extends Scope
|
||||
case object Temporary extends Scope
|
||||
|
||||
case class RemoteAddress(val hostname: String, val port: Int) extends ConfigElement
|
||||
|
||||
class Component(_intf: Class[_],
|
||||
val target: Class[_],
|
||||
val lifeCycle: LifeCycle,
|
||||
val timeout: Int,
|
||||
val transactionRequired: Boolean,
|
||||
_dispatcher: MessageDispatcher, // optional
|
||||
_remoteAddress: RemoteAddress // optional
|
||||
) extends Server {
|
||||
val intf: Option[Class[_]] = if (_intf eq null) None else Some(_intf)
|
||||
val dispatcher: Option[MessageDispatcher] = if (_dispatcher eq null) None else Some(_dispatcher)
|
||||
val remoteAddress: Option[RemoteAddress] = if (_remoteAddress eq null) None else Some(_remoteAddress)
|
||||
}
|
||||
object Component {
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
new Component(null, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
new Component(null, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, false, dispatcher, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, false, dispatcher, remoteAddress)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def apply(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress)
|
||||
|
||||
def apply(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
new Component(null, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object JavaConfig {
|
||||
import scala.reflect.BeanProperty
|
||||
|
||||
sealed abstract class ConfigElement
|
||||
|
||||
class RestartStrategy(
|
||||
@BeanProperty val scheme: FailOverScheme,
|
||||
@BeanProperty val maxNrOfRetries: Int,
|
||||
@BeanProperty val withinTimeRange: Int,
|
||||
@BeanProperty val trapExceptions: Array[Class[_ <: Throwable]]) extends ConfigElement {
|
||||
def transform = se.scalablesolutions.akka.config.ScalaConfig.RestartStrategy(
|
||||
scheme.transform, maxNrOfRetries, withinTimeRange, trapExceptions.toList)
|
||||
}
|
||||
|
||||
class LifeCycle(@BeanProperty val scope: Scope, @BeanProperty val callbacks: RestartCallbacks) extends ConfigElement {
|
||||
def this(scope: Scope) = this(scope, null)
|
||||
def transform = {
|
||||
val callbackOption = if (callbacks eq null) None else Some(callbacks.transform)
|
||||
se.scalablesolutions.akka.config.ScalaConfig.LifeCycle(scope.transform, callbackOption)
|
||||
}
|
||||
}
|
||||
|
||||
class RestartCallbacks(@BeanProperty val preRestart: String, @BeanProperty val postRestart: String) {
|
||||
def transform = se.scalablesolutions.akka.config.ScalaConfig.RestartCallbacks(preRestart, postRestart)
|
||||
}
|
||||
|
||||
abstract class Scope extends ConfigElement {
|
||||
def transform: se.scalablesolutions.akka.config.ScalaConfig.Scope
|
||||
}
|
||||
class Permanent extends Scope {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.Permanent
|
||||
}
|
||||
class Temporary extends Scope {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.Temporary
|
||||
}
|
||||
|
||||
abstract class FailOverScheme extends ConfigElement {
|
||||
def transform: se.scalablesolutions.akka.config.ScalaConfig.FailOverScheme
|
||||
}
|
||||
class AllForOne extends FailOverScheme {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.AllForOne
|
||||
}
|
||||
class OneForOne extends FailOverScheme {
|
||||
override def transform = se.scalablesolutions.akka.config.ScalaConfig.OneForOne
|
||||
}
|
||||
|
||||
class RemoteAddress(@BeanProperty val hostname: String, @BeanProperty val port: Int)
|
||||
|
||||
abstract class Server extends ConfigElement
|
||||
class Component(@BeanProperty val intf: Class[_],
|
||||
@BeanProperty val target: Class[_],
|
||||
@BeanProperty val lifeCycle: LifeCycle,
|
||||
@BeanProperty val timeout: Int,
|
||||
@BeanProperty val transactionRequired: Boolean, // optional
|
||||
@BeanProperty val dispatcher: MessageDispatcher, // optional
|
||||
@BeanProperty val remoteAddress: RemoteAddress // optional
|
||||
) extends Server {
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
this(intf, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int) =
|
||||
this(null, target, lifeCycle, timeout, false, null, null)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
this(intf, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, false, null, remoteAddress)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
this(intf, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher) =
|
||||
this(null, target, lifeCycle, timeout, false, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, false, dispatcher, remoteAddress)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
this(intf, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, null, null)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
this(intf, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, null, remoteAddress)
|
||||
|
||||
def this(intf: Class[_], target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
this(intf, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, dispatcher, null)
|
||||
|
||||
def this(target: Class[_], lifeCycle: LifeCycle, timeout: Int, transactionRequired: Boolean, dispatcher: MessageDispatcher, remoteAddress: RemoteAddress) =
|
||||
this(null, target, lifeCycle, timeout, transactionRequired, dispatcher, remoteAddress)
|
||||
|
||||
def transform =
|
||||
se.scalablesolutions.akka.config.ScalaConfig.Component(
|
||||
intf, target, lifeCycle.transform, timeout, transactionRequired, dispatcher,
|
||||
if (remoteAddress ne null) se.scalablesolutions.akka.config.ScalaConfig.RemoteAddress(remoteAddress.hostname, remoteAddress.port) else null)
|
||||
|
||||
def newSupervised(actor: Actor) =
|
||||
se.scalablesolutions.akka.config.ScalaConfig.Supervise(actor, lifeCycle.transform)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
package se.scalablesolutions.akka.remote
|
||||
|
||||
import se.scalablesolutions.akka.actor.BootableActorLoaderService
|
||||
import se.scalablesolutions.akka.util.{Bootable,Logging}
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.util.{Bootable, Logging}
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
/**
|
||||
* This bundle/service is responsible for booting up and shutting down the remote actors facility
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package se.scalablesolutions.akka.remote
|
||||
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.serialization.Serializer
|
||||
import se.scalablesolutions.akka.actor.{Supervisor, SupervisorFactory, Actor, ActorRegistry}
|
||||
|
|
@ -73,20 +73,20 @@ trait ClusterActor extends Actor with Cluster {
|
|||
*
|
||||
* @author Viktor Klang
|
||||
*/
|
||||
private[remote] object ClusterActor {
|
||||
private[akka] object ClusterActor {
|
||||
sealed trait ClusterMessage
|
||||
|
||||
private[remote] case class RelayedMessage(actorClassFQN: String, msg: AnyRef) extends ClusterMessage
|
||||
private[remote] case class Message[ADDR_T](sender: ADDR_T, msg: Array[Byte])
|
||||
private[remote] case object PapersPlease extends ClusterMessage
|
||||
private[remote] case class Papers(addresses: List[RemoteAddress]) extends ClusterMessage
|
||||
private[remote] case object Block extends ClusterMessage
|
||||
private[remote] case object Unblock extends ClusterMessage
|
||||
private[remote] case class View[ADDR_T](othersPresent: Set[ADDR_T]) extends ClusterMessage
|
||||
private[remote] case class Zombie[ADDR_T](address: ADDR_T) extends ClusterMessage
|
||||
private[remote] case class RegisterLocalNode(server: RemoteAddress) extends ClusterMessage
|
||||
private[remote] case class DeregisterLocalNode(server: RemoteAddress) extends ClusterMessage
|
||||
private[remote] case class Node(endpoints: List[RemoteAddress])
|
||||
private[akka] case class RelayedMessage(actorClassFQN: String, msg: AnyRef) extends ClusterMessage
|
||||
private[akka] case class Message[ADDR_T](sender: ADDR_T, msg: Array[Byte])
|
||||
private[akka] case object PapersPlease extends ClusterMessage
|
||||
private[akka] case class Papers(addresses: List[RemoteAddress]) extends ClusterMessage
|
||||
private[akka] case object Block extends ClusterMessage
|
||||
private[akka] case object Unblock extends ClusterMessage
|
||||
private[akka] case class View[ADDR_T](othersPresent: Set[ADDR_T]) extends ClusterMessage
|
||||
private[akka] case class Zombie[ADDR_T](address: ADDR_T) extends ClusterMessage
|
||||
private[akka] case class RegisterLocalNode(server: RemoteAddress) extends ClusterMessage
|
||||
private[akka] case class DeregisterLocalNode(server: RemoteAddress) extends ClusterMessage
|
||||
private[akka] case class Node(endpoints: List[RemoteAddress])
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -256,7 +256,7 @@ object Cluster extends Cluster with Logging {
|
|||
}
|
||||
}
|
||||
|
||||
private[remote] def createSupervisor(actor: ClusterActor): Option[Supervisor] = {
|
||||
private[akka] def createSupervisor(actor: ClusterActor): Option[Supervisor] = {
|
||||
val sup = SupervisorFactory(
|
||||
SupervisorConfig(
|
||||
RestartStrategy(OneForOne, 5, 1000, List(classOf[Exception])),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.{RemoteRequest,
|
|||
import se.scalablesolutions.akka.actor.{Exit, Actor}
|
||||
import se.scalablesolutions.akka.dispatch.{DefaultCompletableFuture, CompletableFuture}
|
||||
import se.scalablesolutions.akka.util.{UUID, Logging}
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import org.jboss.netty.channel._
|
||||
import group.DefaultChannelGroup
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import java.util.{Map => JMap}
|
|||
import se.scalablesolutions.akka.actor._
|
||||
import se.scalablesolutions.akka.util._
|
||||
import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.{RemoteReply, RemoteRequest}
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap
|
||||
import org.jboss.netty.channel._
|
||||
|
|
|
|||
|
|
@ -5,10 +5,15 @@
|
|||
package se.scalablesolutions.akka.serialization
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper
|
||||
|
||||
import com.google.protobuf.Message
|
||||
import reflect.Manifest
|
||||
|
||||
import scala.reflect.Manifest
|
||||
|
||||
import sbinary.DefaultProtocol
|
||||
|
||||
import java.io.{StringWriter, ByteArrayOutputStream, ObjectOutputStream}
|
||||
|
||||
import sjson.json.{Serializer=>SJSONSerializer}
|
||||
|
||||
object SerializationProtocol {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.stm
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import java.util.concurrent.{ConcurrentLinkedQueue, LinkedBlockingQueue}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
**/
|
||||
|
||||
package se.scalablesolutions.akka.collection
|
||||
package se.scalablesolutions.akka.stm
|
||||
|
||||
trait PersistentDataStructure
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ object HashTrie {
|
|||
// nodes
|
||||
|
||||
@serializable
|
||||
private[collection] sealed trait Node[K, +V] {
|
||||
private[stm] sealed trait Node[K, +V] {
|
||||
val size: Int
|
||||
|
||||
def apply(key: K, hash: Int): Option[V]
|
||||
|
|
@ -90,7 +90,7 @@ private[collection] sealed trait Node[K, +V] {
|
|||
}
|
||||
|
||||
@serializable
|
||||
private[collection] class EmptyNode[K] extends Node[K, Nothing] {
|
||||
private[stm] class EmptyNode[K] extends Node[K, Nothing] {
|
||||
val size = 0
|
||||
|
||||
def apply(key: K, hash: Int) = None
|
||||
|
|
@ -106,12 +106,12 @@ private[collection] class EmptyNode[K] extends Node[K, Nothing] {
|
|||
}
|
||||
}
|
||||
|
||||
private[collection] abstract class SingleNode[K, +V] extends Node[K, V] {
|
||||
private[stm] abstract class SingleNode[K, +V] extends Node[K, V] {
|
||||
val hash: Int
|
||||
}
|
||||
|
||||
|
||||
private[collection] class LeafNode[K, +V](key: K, val hash: Int, value: V) extends SingleNode[K, V] {
|
||||
private[stm] class LeafNode[K, +V](key: K, val hash: Int, value: V) extends SingleNode[K, V] {
|
||||
val size = 1
|
||||
|
||||
def apply(key: K, hash: Int) = if (this.key == key) Some(value) else None
|
||||
|
|
@ -141,7 +141,7 @@ private[collection] class LeafNode[K, +V](key: K, val hash: Int, value: V) exten
|
|||
}
|
||||
|
||||
|
||||
private[collection] class CollisionNode[K, +V](val hash: Int, bucket: List[(K, V)]) extends SingleNode[K, V] {
|
||||
private[stm] class CollisionNode[K, +V](val hash: Int, bucket: List[(K, V)]) extends SingleNode[K, V] {
|
||||
lazy val size = bucket.length
|
||||
|
||||
def this(hash: Int, pairs: (K, V)*) = this(hash, pairs.toList)
|
||||
|
|
@ -185,7 +185,7 @@ private[collection] class CollisionNode[K, +V](val hash: Int, bucket: List[(K, V
|
|||
override def toString = "CollisionNode(" + bucket.toString + ")"
|
||||
}
|
||||
|
||||
private[collection] class BitmappedNode[K, +V](shift: Int)(table: Array[Node[K, V]], bits: Int) extends Node[K, V] {
|
||||
private[stm] class BitmappedNode[K, +V](shift: Int)(table: Array[Node[K, V]], bits: Int) extends Node[K, V] {
|
||||
lazy val size = {
|
||||
val sizes = for {
|
||||
n <- table
|
||||
|
|
@ -284,7 +284,7 @@ private[collection] class BitmappedNode[K, +V](shift: Int)(table: Array[Node[K,
|
|||
}
|
||||
|
||||
|
||||
private[collection] object BitmappedNode {
|
||||
private[stm] object BitmappedNode {
|
||||
def apply[K, V](shift: Int)(node: SingleNode[K, V], key: K, hash: Int, value: V) = {
|
||||
val table = new Array[Node[K, V]](Math.max((hash >>> shift) & 0x01f, (node.hash >>> shift) & 0x01f) + 1)
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ private[collection] object BitmappedNode {
|
|||
}
|
||||
|
||||
|
||||
private[collection] class FullNode[K, +V](shift: Int)(table: Array[Node[K, V]]) extends Node[K, V] {
|
||||
private[stm] class FullNode[K, +V](shift: Int)(table: Array[Node[K, V]]) extends Node[K, V] {
|
||||
lazy val size = table.foldLeft(0) { _ + _.size }
|
||||
|
||||
def apply(key: K, hash: Int) = table((hash >>> shift) & 0x01f)(key, hash)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.util
|
||||
|
||||
import stm.Transaction
|
||||
package se.scalablesolutions.akka.stm
|
||||
|
||||
/**
|
||||
* Reference that can hold either a typed value or an exception.
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ package se.scalablesolutions.akka.stm
|
|||
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
import se.scalablesolutions.akka.state.Committable
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
import org.multiverse.api.{Transaction => MultiverseTransaction}
|
||||
|
|
@ -18,7 +18,6 @@ import org.multiverse.api.ThreadLocalTransaction._
|
|||
import org.multiverse.templates.{TransactionTemplate, OrElseTemplate}
|
||||
import org.multiverse.utils.backoff.ExponentialBackoffPolicy
|
||||
import org.multiverse.stms.alpha.AlphaStm
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class NoTransactionInScopeException extends RuntimeException
|
||||
class TransactionRetryException(message: String) extends RuntimeException(message)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class TransactionAwareWrapperException(val cause: Throwable, val tx: Option[Tran
|
|||
}
|
||||
|
||||
object TransactionManagement extends TransactionManagement {
|
||||
import se.scalablesolutions.akka.Config._
|
||||
import se.scalablesolutions.akka.config.Config._
|
||||
|
||||
val TRANSACTION_ENABLED = new AtomicBoolean(config.getBool("akka.stm.service", false))
|
||||
val FAIR_TRANSACTIONS = config.getBool("akka.stm.fair", true)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.stm
|
||||
|
||||
import se.scalablesolutions.akka.stm.Transaction.atomic
|
||||
import se.scalablesolutions.akka.stm.NoTransactionInScopeException
|
||||
import se.scalablesolutions.akka.collection._
|
||||
import se.scalablesolutions.akka.util.UUID
|
||||
|
||||
import org.multiverse.stms.alpha.AlphaRef
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
POSSIBILITY OF SUCH DAMAGE.
|
||||
**/
|
||||
|
||||
package se.scalablesolutions.akka.collection
|
||||
package se.scalablesolutions.akka.stm
|
||||
|
||||
import Vector._
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ class Vector[+T] private (val length: Int, shift: Int, root: Array[AnyRef], tail
|
|||
* (somewhat dynamically-typed) implementation in place.
|
||||
*/
|
||||
|
||||
private[collection] def this() = this(0, 5, EmptyArray, EmptyArray)
|
||||
private[stm] def this() = this(0, 5, EmptyArray, EmptyArray)
|
||||
|
||||
def apply(i: Int): T = {
|
||||
if (i >= 0 && i < length) {
|
||||
|
|
@ -317,14 +317,14 @@ class Vector[+T] private (val length: Int, shift: Int, root: Array[AnyRef], tail
|
|||
}
|
||||
|
||||
object Vector {
|
||||
private[collection] val EmptyArray = new Array[AnyRef](0)
|
||||
private[stm] val EmptyArray = new Array[AnyRef](0)
|
||||
|
||||
def apply[T](elems: T*) = elems.foldLeft(EmptyVector:Vector[T]) { _ + _ }
|
||||
|
||||
def unapplySeq[T](vec: Vector[T]): Option[Seq[T]] = Some(vec)
|
||||
|
||||
@inline
|
||||
private[collection] def array(elems: AnyRef*) = {
|
||||
private[stm] def array(elems: AnyRef*) = {
|
||||
val back = new Array[AnyRef](elems.length)
|
||||
Array.copy(elems, 0, back, 0, back.length)
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ object Vector {
|
|||
|
||||
object EmptyVector extends Vector[Nothing]
|
||||
|
||||
private[collection] abstract class VectorProjection[+T] extends Vector[T] {
|
||||
private[stm] abstract class VectorProjection[+T] extends Vector[T] {
|
||||
override val length: Int
|
||||
override def apply(i: Int): T
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class RemoteActorSpecActorAsyncSender extends Actor {
|
|||
class ClientInitiatedRemoteActorTest extends JUnitSuite {
|
||||
import Actor.Sender.Self
|
||||
|
||||
akka.Config.config
|
||||
akka.config.Config.config
|
||||
|
||||
val HOSTNAME = "localhost"
|
||||
val PORT1 = 9990
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package se.scalablesolutions.akka.actor
|
|||
import org.scalatest.junit.JUnitSuite
|
||||
import org.junit.Test
|
||||
|
||||
import se.scalablesolutions.akka.state.{TransactionalState, TransactionalMap, TransactionalRef, TransactionalVector}
|
||||
import se.scalablesolutions.akka.stm.{TransactionalState, TransactionalMap, TransactionalRef, TransactionalVector}
|
||||
|
||||
case class GetMapState(key: String)
|
||||
case object GetVectorState
|
||||
|
|
|
|||
|
|
@ -22,9 +22,11 @@ class MemoryFootprintTest extends JUnitSuite {
|
|||
// Actors are put in AspectRegistry when created so they won't be GCd here
|
||||
|
||||
val totalMem = Runtime.getRuntime.totalMemory - Runtime.getRuntime.freeMemory
|
||||
println("Memory before " + totalMem)
|
||||
(1 until NR_OF_ACTORS).foreach(i => new Mem)
|
||||
|
||||
val newTotalMem = Runtime.getRuntime.totalMemory - Runtime.getRuntime.freeMemory
|
||||
println("Memory aftor " + newTotalMem)
|
||||
val memPerActor = (newTotalMem - totalMem) / NR_OF_ACTORS
|
||||
|
||||
println("Memory footprint per actor is : " + memPerActor)
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ class PerformanceTest extends JUnitSuite {
|
|||
|
||||
case class Meet(from: Actor, colour: Colour)
|
||||
case class Change(colour: Colour)
|
||||
case class MeetingCount(count: int)
|
||||
case class MeetingCount(count: Int)
|
||||
case class ExitActor(actor: Actor, reason: String)
|
||||
|
||||
var totalTime = 0L
|
||||
|
||||
class Mall(var nrMeets: int, numChameneos: int) extends Actor {
|
||||
class Mall(var nrMeets: Int, numChameneos: Int) extends Actor {
|
||||
var waitingChameneo: Option[Actor] = None
|
||||
var sumMeetings = 0
|
||||
var numFaded = 0
|
||||
|
|
@ -86,7 +86,7 @@ class PerformanceTest extends JUnitSuite {
|
|||
}
|
||||
}
|
||||
|
||||
case class Chameneo(var mall: Mall, var colour: Colour, cid: int) extends Actor {
|
||||
case class Chameneo(var mall: Mall, var colour: Colour, cid: Int) extends Actor {
|
||||
var meetings = 0
|
||||
|
||||
override def start = {
|
||||
|
|
@ -160,10 +160,10 @@ class PerformanceTest extends JUnitSuite {
|
|||
|
||||
case class Meet(colour: Colour)
|
||||
case class Change(colour: Colour)
|
||||
case class MeetingCount(count: int)
|
||||
case class MeetingCount(count: Int)
|
||||
|
||||
|
||||
class Mall(var n: int, numChameneos: int) extends Actor {
|
||||
class Mall(var n: Int, numChameneos: Int) extends Actor {
|
||||
var waitingChameneo: Option[OutputChannel[Any]] = None
|
||||
var startTime: Long = 0L
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ class PerformanceTest extends JUnitSuite {
|
|||
}
|
||||
}
|
||||
|
||||
case class Chameneo(var mall: Mall, var colour: Colour, id: int) extends Actor {
|
||||
case class Chameneo(var mall: Mall, var colour: Colour, id: Int) extends Actor {
|
||||
var meetings = 0
|
||||
|
||||
def act() {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import Actor.Sender.Self
|
|||
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
import org.junit.Test
|
||||
|
||||
/*
|
||||
class RemoteClientShutdownTest extends JUnitSuite {
|
||||
@Test def shouldShutdownRemoteClient = {
|
||||
RemoteNode.start("localhost", 9999)
|
||||
|
|
@ -28,3 +28,4 @@ class TravelingActor extends RemoteActor("localhost", 9999) {
|
|||
case _ => log.info("message received")
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -74,7 +74,7 @@ object Log {
|
|||
class RemoteSupervisorTest extends JUnitSuite {
|
||||
import Actor.Sender.Self
|
||||
|
||||
akka.Config.config
|
||||
akka.config.Config.config
|
||||
new Thread(new Runnable() {
|
||||
def run = {
|
||||
RemoteNode.start
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class ServerInitiatedRemoteActorTest extends JUnitSuite {
|
|||
import ServerInitiatedRemoteActorTest._
|
||||
|
||||
import Actor.Sender.Self
|
||||
akka.Config.config
|
||||
akka.config.Config.config
|
||||
|
||||
private val unit = TimeUnit.MILLISECONDS
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class ThreadBasedDispatcherTest extends JUnitSuite {
|
|||
})
|
||||
dispatcher.start
|
||||
for (i <- 0 until 100) {
|
||||
dispatcher.dispatch(new MessageInvocation(key1, new Integer(i), None, None, None))
|
||||
dispatcher.dispatch(new MessageInvocation(key1, i, None, None, None))
|
||||
}
|
||||
assert(handleLatch.await(5, TimeUnit.SECONDS))
|
||||
assert(!threadingIssueDetected.get)
|
||||
|
|
|
|||
33
akka-fun-test-java/pom.xml
Normal file → Executable file
33
akka-fun-test-java/pom.xml
Normal file → Executable file
|
|
@ -5,31 +5,43 @@
|
|||
|
||||
<name>Akka Functional Tests in Java</name>
|
||||
<artifactId>akka-fun-test-java</artifactId>
|
||||
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<scala.version>2.7.7</scala.version>
|
||||
<atmosphere.version>0.5.2</atmosphere.version>
|
||||
<jersey.version>1.1.5</jersey.version>
|
||||
<grizzly.version>1.9.18-i</grizzly.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-kernel</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<artifactId>akka-persistence-cassandra</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.2.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.grizzly</groupId>
|
||||
<artifactId>grizzly-servlet-webserver</artifactId>
|
||||
|
|
@ -94,7 +106,6 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/InMemNestedStateTest*</exclude>
|
||||
<exclude>**/*Persistent*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.google.inject.Scopes;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import se.scalablesolutions.akka.Config;
|
||||
import se.scalablesolutions.akka.config.Config;
|
||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||
import se.scalablesolutions.akka.dispatch.*;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
package se.scalablesolutions.akka.api;
|
||||
|
||||
import se.scalablesolutions.akka.Config;
|
||||
import se.scalablesolutions.akka.config.*;
|
||||
import se.scalablesolutions.akka.config.Config;
|
||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||
import se.scalablesolutions.akka.actor.*;
|
||||
import se.scalablesolutions.akka.Kernel;
|
||||
import se.scalablesolutions.akka.kernel.Kernel;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class InMemNestedStateTest extends TestCase {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import se.scalablesolutions.akka.annotation.transactionrequired;
|
|||
import se.scalablesolutions.akka.annotation.prerestart;
|
||||
import se.scalablesolutions.akka.annotation.postrestart;
|
||||
import se.scalablesolutions.akka.annotation.inittransactionalstate;
|
||||
import se.scalablesolutions.akka.state.*;
|
||||
import se.scalablesolutions.akka.stm.*;
|
||||
|
||||
@transactionrequired
|
||||
public class InMemStateful {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
import se.scalablesolutions.akka.annotation.transactionrequired;
|
||||
import se.scalablesolutions.akka.annotation.inittransactionalstate;
|
||||
import se.scalablesolutions.akka.state.*;
|
||||
import se.scalablesolutions.akka.stm.*;
|
||||
|
||||
@transactionrequired
|
||||
public class InMemStatefulNested {
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import se.scalablesolutions.akka.Config;
|
||||
import se.scalablesolutions.akka.config.Config;
|
||||
import se.scalablesolutions.akka.config.*;
|
||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||
|
||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||
|
||||
import se.scalablesolutions.akka.actor.*;
|
||||
import se.scalablesolutions.akka.Kernel;
|
||||
import se.scalablesolutions.akka.kernel.Kernel;
|
||||
|
||||
public class InMemoryStateTest extends TestCase {
|
||||
static String messageLog = "";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ public class PersistenceManager {
|
|||
private static volatile boolean isRunning = false;
|
||||
public static void init() {
|
||||
if (!isRunning) {
|
||||
se.scalablesolutions.akka.Kernel$.MODULE$.startRemoteService();
|
||||
se.scalablesolutions.akka.kernel.Kernel$.MODULE$.startRemoteService();
|
||||
isRunning = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package se.scalablesolutions.akka.api;
|
||||
|
||||
import se.scalablesolutions.akka.state.*;
|
||||
import se.scalablesolutions.akka.persistence.common.*;
|
||||
import se.scalablesolutions.akka.persistence.cassandra.*;
|
||||
import se.scalablesolutions.akka.annotation.inittransactionalstate;
|
||||
|
||||
public class PersistentClasher {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import se.scalablesolutions.akka.config.*;
|
|||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||
import static se.scalablesolutions.akka.config.JavaConfig.*;
|
||||
import se.scalablesolutions.akka.actor.*;
|
||||
import se.scalablesolutions.akka.Kernel;
|
||||
import se.scalablesolutions.akka.kernel.Kernel;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
import se.scalablesolutions.akka.annotation.inittransactionalstate;
|
||||
import se.scalablesolutions.akka.annotation.transactionrequired;
|
||||
import se.scalablesolutions.akka.state.*;
|
||||
import se.scalablesolutions.akka.persistence.common.*;
|
||||
import se.scalablesolutions.akka.persistence.cassandra.*;
|
||||
|
||||
@transactionrequired
|
||||
public class PersistentStateful {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ package se.scalablesolutions.akka.api;
|
|||
|
||||
import se.scalablesolutions.akka.annotation.inittransactionalstate;
|
||||
import se.scalablesolutions.akka.annotation.transactionrequired;
|
||||
import se.scalablesolutions.akka.state.*;
|
||||
import se.scalablesolutions.akka.persistence.common.*;
|
||||
import se.scalablesolutions.akka.persistence.cassandra.*;
|
||||
|
||||
@transactionrequired
|
||||
public class PersistentStatefulNested {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
package se.scalablesolutions.akka.api;
|
||||
|
||||
import se.scalablesolutions.akka.Config;
|
||||
import se.scalablesolutions.akka.config.Config;
|
||||
import se.scalablesolutions.akka.actor.ActiveObject;
|
||||
import se.scalablesolutions.akka.config.ActiveObjectConfigurator;
|
||||
import se.scalablesolutions.akka.remote.RemoteNode;
|
||||
|
|
|
|||
|
|
@ -1,136 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-kernel</artifactId>
|
||||
<name>Akka Kernel Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- akka deps -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-rest</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-amqp</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-security</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-cassandra</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-mongo</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-redis</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-comet</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-cluster-jgroups</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!--dependency>
|
||||
<artifactId>akka-cluster-shoal</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency-->
|
||||
|
||||
<!-- For Atmosphere -->
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-annotations</artifactId>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-jersey</artifactId>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-runtime</artifactId>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>junit:junit</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>se.scalablesolutions.akka.Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="target/akka-kernel-${project.version}.jar"
|
||||
tofile="../dist/akka-${project.version}.jar"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -2,11 +2,13 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka
|
||||
package se.scalablesolutions.akka.kernel
|
||||
|
||||
import se.scalablesolutions.akka.remote.BootableRemoteActorService
|
||||
import se.scalablesolutions.akka.comet.BootableCometActorService
|
||||
import se.scalablesolutions.akka.actor.BootableActorLoaderService
|
||||
import se.scalablesolutions.akka.util.{Logging,Bootable}
|
||||
import se.scalablesolutions.akka.config.Config
|
||||
import se.scalablesolutions.akka.util.{Logging, Bootable}
|
||||
|
||||
import javax.servlet.{ServletContextListener, ServletContextEvent}
|
||||
|
||||
|
|
@ -27,12 +29,15 @@ object Kernel extends Logging {
|
|||
/**
|
||||
* Holds a reference to the services that has been booted
|
||||
*/
|
||||
@volatile private var bundles : Option[Bootable] = None
|
||||
@volatile private var bundles: Option[Bootable] = None
|
||||
|
||||
/**
|
||||
* Boots up the Kernel with default bootables
|
||||
* Boots up the Kernel with default bootables
|
||||
*/
|
||||
def boot : Unit = boot(true, new BootableActorLoaderService with BootableRemoteActorService with BootableCometActorService)
|
||||
def boot: Unit = boot(true,
|
||||
new BootableActorLoaderService
|
||||
with BootableRemoteActorService
|
||||
with BootableCometActorService)
|
||||
|
||||
/**
|
||||
* Boots up the Kernel.
|
||||
|
|
@ -63,8 +68,8 @@ object Kernel extends Logging {
|
|||
}
|
||||
|
||||
//For testing purposes only
|
||||
def startRemoteService : Unit = bundles.foreach( _ match {
|
||||
case x : BootableRemoteActorService => x.startRemoteService
|
||||
def startRemoteService: Unit = bundles.foreach( _ match {
|
||||
case x: BootableRemoteActorService => x.startRemoteService
|
||||
case _ =>
|
||||
})
|
||||
|
||||
|
|
@ -79,16 +84,18 @@ object Kernel extends Logging {
|
|||
(____ /__|_ \__|_ \(____ /
|
||||
\/ \/ \/ \/
|
||||
""")
|
||||
log.info(" Running version %s", Config.VERSION)
|
||||
log.info(" Running version %s", Config.VERSION)
|
||||
log.info("==============================")
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
And this one can be added to web.xml mappings as a listener to boot and shutdown Akka
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class can be added to web.xml mappings as a listener to boot and shutdown Akka.
|
||||
*/
|
||||
class Kernel extends ServletContextListener {
|
||||
def contextDestroyed(e : ServletContextEvent) : Unit = Kernel.shutdown
|
||||
def contextInitialized(e : ServletContextEvent) : Unit = Kernel.boot(true,new BootableActorLoaderService with BootableRemoteActorService)
|
||||
def contextDestroyed(e: ServletContextEvent): Unit =
|
||||
Kernel.shutdown
|
||||
|
||||
def contextInitialized(e: ServletContextEvent): Unit =
|
||||
Kernel.boot(true, new BootableActorLoaderService with BootableRemoteActorService)
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-patterns</artifactId>
|
||||
<name>Akka Patterns Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Testing -->
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,146 +0,0 @@
|
|||
// ScalaAgent
|
||||
//
|
||||
// Copyright © 2008-9 The original author or authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import se.scalablesolutions.akka.state.TransactionalState
|
||||
import se.scalablesolutions.akka.stm.Transaction.atomic
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import java.util.concurrent.{CountDownLatch}
|
||||
|
||||
/**
|
||||
* The Agent class was strongly inspired by the agent principle in Clojure. Essentially, an agent wraps a shared mutable state
|
||||
* and hides it behind a message-passing interface. Agents accept messages and process them on behalf of the wrapped state.
|
||||
* Typically agents accept functions / commands as messages and ensure the submitted commands are executed against the internal
|
||||
* agent's state in a thread-safe manner (sequentially).
|
||||
* The submitted functions / commands take the internal state as a parameter and their output becomes the new internal state value.
|
||||
* The code that is submitted to an agent doesn't need to pay attention to threading or synchronization, the agent will
|
||||
* provide such guarantees by itself.
|
||||
* See the examples of use for more details.
|
||||
*
|
||||
* @author Vaclav Pech
|
||||
* Date: Oct 18, 2009
|
||||
*
|
||||
* AKKA retrofit by
|
||||
* @author Viktor Klang
|
||||
* Date: Jan 24 2010
|
||||
*/
|
||||
sealed class Agent[T] private (initialValue: T) extends Actor {
|
||||
import Agent._
|
||||
|
||||
private val value = TransactionalState.newRef[T]
|
||||
|
||||
updateData(initialValue)
|
||||
|
||||
/**
|
||||
* Periodically handles incoming messages
|
||||
*/
|
||||
def receive = {
|
||||
case FunctionHolder(fun: (T => T)) => updateData(fun(value.getOrWait))
|
||||
|
||||
case ValueHolder(x: T) => updateData(x)
|
||||
|
||||
case ProcedureHolder(fun: (T => Unit)) => fun(copyStrategy(value.getOrWait))
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies how a copy of the value is made, defaults to using identity
|
||||
*/
|
||||
protected def copyStrategy(t: T): T = t
|
||||
|
||||
|
||||
/**
|
||||
* Updates the internal state with the value provided as a by-name parameter
|
||||
*/
|
||||
private final def updateData(newData: => T): Unit = value.swap(newData)
|
||||
|
||||
/**
|
||||
* Submits a request to read the internal state.
|
||||
* A copy of the internal state will be returned, depending on the underlying effective copyStrategy.
|
||||
* Internally leverages the asynchronous getValue() method and then waits for its result on a CountDownLatch.
|
||||
*/
|
||||
final def get: T = {
|
||||
val ref = new AtomicReference[T]
|
||||
val latch = new CountDownLatch(1)
|
||||
get((x: T) => {ref.set(x); latch.countDown})
|
||||
latch.await
|
||||
ref.get
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously submits a request to read the internal state. The supplied function will be executed on the returned internal state value.
|
||||
* A copy of the internal state will be used, depending on the underlying effective copyStrategy.
|
||||
*/
|
||||
final def get(message: (T => Unit)): Unit = this ! ProcedureHolder(message)
|
||||
|
||||
/**
|
||||
* Submits a request to read the internal state.
|
||||
* A copy of the internal state will be returned, depending on the underlying effective copyStrategy.
|
||||
* Internally leverages the asynchronous getValue() method and then waits for its result on a CountDownLatch.
|
||||
*/
|
||||
final def apply(): T = get
|
||||
|
||||
/**
|
||||
* Asynchronously submits a request to read the internal state. The supplied function will be executed on the returned internal state value.
|
||||
* A copy of the internal state will be used, depending on the underlying effective copyStrategy.
|
||||
*/
|
||||
// final def apply(message: (T => Unit)) : Unit = get(message)
|
||||
|
||||
/**
|
||||
* Submits the provided function for execution against the internal agent's state
|
||||
*/
|
||||
final def apply(message: (T => T)): Unit = this ! FunctionHolder(message)
|
||||
|
||||
/**
|
||||
* Submits a new value to be set as the new agent's internal state
|
||||
*/
|
||||
final def apply(message: T): Unit = this ! ValueHolder(message)
|
||||
|
||||
/**
|
||||
* Submits the provided function for execution against the internal agent's state
|
||||
*/
|
||||
final def update(message: (T => T)): Unit = this ! FunctionHolder(message)
|
||||
|
||||
/**
|
||||
* Submits a new value to be set as the new agent's internal state
|
||||
*/
|
||||
final def update(message: T): Unit = this ! ValueHolder(message)
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides factory methods to create Agents.
|
||||
*/
|
||||
object Agent {
|
||||
/**
|
||||
* The internal messages for passing around requests
|
||||
*/
|
||||
private case class ProcedureHolder[T](val fun: ((T) => Unit))
|
||||
private case class FunctionHolder[T](val fun: ((T) => T))
|
||||
private case class ValueHolder[T](val value: T)
|
||||
|
||||
/**
|
||||
* Creates a new Agent of type T with the initial value of value
|
||||
*/
|
||||
def apply[T](value:T): Agent[T] = new Agent(value)
|
||||
|
||||
/**
|
||||
* Creates a new Agent of type T with the initial value of value and with the specified copy function
|
||||
*/
|
||||
def apply[T](value:T, newCopyStrategy: (T) => T) = new Agent(value) {
|
||||
override def copyStrategy(t : T) = newCopyStrategy(t)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.actor.patterns
|
||||
package se.scalablesolutions.akka.patterns
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package se.scalablesolutions.akka.actor
|
||||
package se.scalablesolutions.akka.patterns
|
||||
|
||||
|
||||
import config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
import se.scalablesolutions.akka.actor.Actor._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
import org.scalatest.Suite
|
||||
import patterns.Patterns
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
import org.scalatest.matchers.MustMatchers
|
||||
|
|
@ -14,7 +14,6 @@ import scala.collection.mutable.HashSet
|
|||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class ActorPatternsTest extends junit.framework.TestCase with Suite with MustMatchers with ActorTestUtil with Logging {
|
||||
import Actor._
|
||||
import Patterns._
|
||||
@Test def testDispatcher = verify(new TestActor {
|
||||
def test = {
|
||||
|
|
|
|||
|
|
@ -1,86 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-persistence-cassandra</artifactId>
|
||||
<name>Akka Persistence Cassandra Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-common</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.google-collections</groupId>
|
||||
<artifactId>google-collect</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- For Cassandra -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cassandra</groupId>
|
||||
<artifactId>cassandra</artifactId>
|
||||
<version>0.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cassandra</groupId>
|
||||
<artifactId>high-scale-lib</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cassandra</groupId>
|
||||
<artifactId>clhm-production</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.collections</groupId>
|
||||
<artifactId>google-collections</artifactId>
|
||||
<version>1.0-rc1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.5.8</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.5.8</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.13</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -2,14 +2,15 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.cassandra
|
||||
|
||||
import java.io.{Flushable, Closeable}
|
||||
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.util.Helpers._
|
||||
import se.scalablesolutions.akka.serialization.Serializer
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import scala.collection.mutable.Map
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,18 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.cassandra
|
||||
|
||||
import org.codehaus.aspectwerkz.proxy.Uuid
|
||||
import se.scalablesolutions.akka.util.UUID
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
|
||||
object CassandraStorage extends Storage {
|
||||
type ElementType = Array[Byte]
|
||||
|
||||
def newMap: PersistentMap[ElementType, ElementType] = newMap(Uuid.newUuid.toString)
|
||||
def newVector: PersistentVector[ElementType] = newVector(Uuid.newUuid.toString)
|
||||
def newRef: PersistentRef[ElementType] = newRef(Uuid.newUuid.toString)
|
||||
def newMap: PersistentMap[ElementType, ElementType] = newMap(UUID.newUuid.toString)
|
||||
def newVector: PersistentVector[ElementType] = newVector(UUID.newUuid.toString)
|
||||
def newRef: PersistentRef[ElementType] = newRef(UUID.newUuid.toString)
|
||||
|
||||
def getMap(id: String): PersistentMap[ElementType, ElementType] = newMap(id)
|
||||
def getVector(id: String): PersistentVector[ElementType] = newVector(id)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.cassandra
|
||||
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.util.Helpers._
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import org.apache.cassandra.service._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.cassandra
|
||||
|
||||
import se.scalablesolutions.akka.actor.{Actor, Transactor}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-persistence-common</artifactId>
|
||||
<name>Akka Persistence Common Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.facebook</groupId>
|
||||
<artifactId>thrift</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-pool</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<version>1.5.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.common
|
||||
|
||||
import org.apache.commons.pool._
|
||||
import org.apache.commons.pool.impl._
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.common
|
||||
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.stm.TransactionManagement.transaction
|
||||
import se.scalablesolutions.akka.collection._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
// FIXME move to 'stm' package + add message with more info
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.common
|
||||
|
||||
// abstracts persistence storage
|
||||
trait StorageBackend
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-persistence-mongo</artifactId>
|
||||
<name>Akka Persistence Mongo Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-common</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Mongo -->
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -2,16 +2,18 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.mongo
|
||||
|
||||
import org.codehaus.aspectwerkz.proxy.Uuid
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
import se.scalablesolutions.akka.util.UUID
|
||||
|
||||
object MongoStorage extends Storage {
|
||||
type ElementType = AnyRef
|
||||
|
||||
def newMap: PersistentMap[ElementType, ElementType] = newMap(Uuid.newUuid.toString)
|
||||
def newVector: PersistentVector[ElementType] = newVector(Uuid.newUuid.toString)
|
||||
def newRef: PersistentRef[ElementType] = newRef(Uuid.newUuid.toString)
|
||||
def newMap: PersistentMap[ElementType, ElementType] = newMap(UUID.newUuid.toString)
|
||||
def newVector: PersistentVector[ElementType] = newVector(UUID.newUuid.toString)
|
||||
def newRef: PersistentRef[ElementType] = newRef(UUID.newUuid.toString)
|
||||
|
||||
def getMap(id: String): PersistentMap[ElementType, ElementType] = newMap(id)
|
||||
def getVector(id: String): PersistentVector[ElementType] = newVector(id)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.mongo
|
||||
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import sjson.json.Serializer._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.mongo
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.mongo
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-persistence-redis</artifactId>
|
||||
<name>Akka Persistence Redis Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-common</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Redis -->
|
||||
<dependency>
|
||||
<groupId>com.redis</groupId>
|
||||
<artifactId>redisclient</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
@ -2,17 +2,19 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.redis
|
||||
|
||||
import org.codehaus.aspectwerkz.proxy.Uuid
|
||||
import se.scalablesolutions.akka.util.UUID
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
|
||||
object RedisStorage extends Storage {
|
||||
type ElementType = Array[Byte]
|
||||
|
||||
def newMap: PersistentMap[ElementType, ElementType] = newMap(Uuid.newUuid.toString)
|
||||
def newVector: PersistentVector[ElementType] = newVector(Uuid.newUuid.toString)
|
||||
def newRef: PersistentRef[ElementType] = newRef(Uuid.newUuid.toString)
|
||||
override def newQueue: PersistentQueue[ElementType] = newQueue(Uuid.newUuid.toString)
|
||||
def newMap: PersistentMap[ElementType, ElementType] = newMap(UUID.newUuid.toString)
|
||||
def newVector: PersistentVector[ElementType] = newVector(UUID.newUuid.toString)
|
||||
def newRef: PersistentRef[ElementType] = newRef(UUID.newUuid.toString)
|
||||
override def newQueue: PersistentQueue[ElementType] = newQueue(UUID.newUuid.toString)
|
||||
|
||||
def getMap(id: String): PersistentMap[ElementType, ElementType] = newMap(id)
|
||||
def getVector(id: String): PersistentVector[ElementType] = newVector(id)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.redis
|
||||
|
||||
import se.scalablesolutions.akka.stm._
|
||||
import se.scalablesolutions.akka.persistence.common._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.Config.config
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import com.redis._
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.redis
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.redis
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
|
|
@ -15,9 +15,9 @@ import se.scalablesolutions.akka.actor.{Actor, Transactor}
|
|||
*/
|
||||
|
||||
case class NQ(accountNo: String)
|
||||
case class DQ
|
||||
case object DQ
|
||||
case class MNDQ(accountNos: List[String], noOfDQs: Int, failer: Actor)
|
||||
case class SZ
|
||||
case object SZ
|
||||
|
||||
class QueueActor extends Transactor {
|
||||
private lazy val accounts = RedisStorage.newQueue
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
package se.scalablesolutions.akka.persistence.redis
|
||||
|
||||
import org.scalatest.Spec
|
||||
import org.scalatest.matchers.ShouldMatchers
|
||||
|
|
@ -156,9 +156,6 @@ class RedisStorageBackendSpec extends
|
|||
}
|
||||
}
|
||||
|
||||
describe("atomic increment in ref") {
|
||||
}
|
||||
|
||||
describe("store and query in queue") {
|
||||
it("should give proper queue semantics") {
|
||||
enqueue("T-5", "alan kay".getBytes)
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<name>Akka Persistence Modules</name>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>akka-persistence-common</module>
|
||||
<module>akka-persistence-redis</module>
|
||||
<module>akka-persistence-mongo</module>
|
||||
<module>akka-persistence-cassandra</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- For Testing -->
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-rest</artifactId>
|
||||
<name>Akka REST Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Jersey -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-json</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey.contribs</groupId>
|
||||
<artifactId>jersey-scala</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -7,8 +7,8 @@ package se.scalablesolutions.akka.rest
|
|||
import com.sun.jersey.core.spi.component.ComponentScope
|
||||
import com.sun.jersey.core.spi.component.ioc.IoCFullyManagedComponentProvider
|
||||
|
||||
import config.Configurator
|
||||
import util.Logging
|
||||
import se.scalablesolutions.akka.config.Configurator
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
class ActorComponentProvider(val clazz: Class[_], val configurators: List[Configurator])
|
||||
extends IoCFullyManagedComponentProvider with Logging {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package se.scalablesolutions.akka.rest
|
||||
|
||||
import se.scalablesolutions.akka.config.ConfiguratorRepository
|
||||
import se.scalablesolutions.akka.config.Config.config
|
||||
|
||||
import com.sun.jersey.api.core.ResourceConfig
|
||||
import com.sun.jersey.spi.container.servlet.ServletContainer
|
||||
|
|
@ -20,14 +21,12 @@ class AkkaServlet extends ServletContainer {
|
|||
import org.scala_tools.javautils.Imports._
|
||||
|
||||
override def initiate(resourceConfig: ResourceConfig, webApplication: WebApplication) = {
|
||||
//Kernel.boot // will boot if not already booted by 'main'
|
||||
|
||||
val configurators = ConfiguratorRepository.getConfigurators
|
||||
|
||||
resourceConfig.getClasses.addAll(configurators.flatMap(_.getComponentInterfaces).asJava)
|
||||
resourceConfig.getProperties.put(
|
||||
"com.sun.jersey.spi.container.ResourceFilters",
|
||||
Config.config.getList("akka.rest.filters").mkString(","))
|
||||
config.getList("akka.rest.filters").mkString(","))
|
||||
|
||||
webApplication.initiate(resourceConfig, new ActorComponentProviderFactory(configurators))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-sample-chat</artifactId>
|
||||
<name>Akka Chat Sample Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/scala</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="target/akka-sample-chat-${project.version}.jar"
|
||||
tofile="../../deploy/akka-sample-chat-${project.version}.jar"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -6,12 +6,14 @@ package se.scalablesolutions.akka.sample.chat
|
|||
|
||||
import se.scalablesolutions.akka.actor.{SupervisorFactory, Actor, RemoteActor}
|
||||
import se.scalablesolutions.akka.stm.Transaction._
|
||||
import se.scalablesolutions.akka.persistence.common.PersistentVector
|
||||
import se.scalablesolutions.akka.persistence.redis.RedisStorage
|
||||
import se.scalablesolutions.akka.remote.RemoteServer
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.config.OneForOneStrategy
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
import se.scalablesolutions.akka.state.{PersistentVector, RedisStorage}
|
||||
|
||||
/******************************************************************************
|
||||
To run the sample:
|
||||
|
|
@ -203,4 +205,4 @@ object Runner {
|
|||
|
||||
client.logout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
#####################
|
||||
# Akka Config File #
|
||||
###################
|
||||
|
||||
# This file has all the default settings, so all these could be removed with no visible effect.
|
||||
# Modify as needed.
|
||||
|
||||
<log>
|
||||
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 = ""
|
||||
</log>
|
||||
|
||||
<akka>
|
||||
version = "0.7-SNAPSHOT"
|
||||
|
||||
<actor>
|
||||
timeout = 5000 # default timeout for future based invocations
|
||||
concurrent-mode = off # if turned on, then the same actor instance is allowed to execute concurrently -
|
||||
# e.g. departing from the actor model for better performance
|
||||
serialize-messages = on # does a deep clone of (non-primitive) messages to ensure immutability
|
||||
</actor>
|
||||
|
||||
<stm>
|
||||
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
|
||||
</stm>
|
||||
|
||||
<remote>
|
||||
service = on
|
||||
hostname = "localhost"
|
||||
port = 9999
|
||||
connection-timeout = 1000 # in millis
|
||||
</remote>
|
||||
|
||||
<rest>
|
||||
service = on
|
||||
hostname = "localhost"
|
||||
port = 9998
|
||||
</rest>
|
||||
|
||||
<storage>
|
||||
system = "cassandra" # Options: cassandra (coming: terracotta, redis, tokyo-cabinet, tokyo-tyrant, voldemort, memcached, hazelcast)
|
||||
|
||||
<cassandra>
|
||||
service = on
|
||||
storage-format = "java" # Options: java, scala-json, java-json
|
||||
blocking = false # inserts and queries should be blocking or not
|
||||
|
||||
<thrift-server>
|
||||
service = on
|
||||
pidfile = "akka.pid"
|
||||
</thrift-server>
|
||||
</cassandra>
|
||||
</rest>
|
||||
</akka>
|
||||
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-sample-lift</artifactId>
|
||||
<name>Akka Lift Sample Module</name>
|
||||
|
||||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<lift.version>1.1-M6</lift.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.liftweb</groupId>
|
||||
<artifactId>lift-util</artifactId>
|
||||
<version>${lift.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.liftweb</groupId>
|
||||
<artifactId>lift-webkit</artifactId>
|
||||
<version>${lift.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty</artifactId>
|
||||
<version>[6.1.6,)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -2,7 +2,8 @@ package sample.lift
|
|||
|
||||
import se.scalablesolutions.akka.actor.{Transactor, Actor}
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.state.{CassandraStorage, TransactionalState}
|
||||
import se.scalablesolutions.akka.stm.TransactionalState
|
||||
import se.scalablesolutions.akka.persistence.cassandra.CassandraStorage
|
||||
|
||||
import java.lang.Integer
|
||||
import javax.ws.rs.{GET, Path, Produces}
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-sample-rest-java</artifactId>
|
||||
<name>Akka REST Java Sample Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="target/akka-sample-rest-java-${project.version}.jar"
|
||||
tofile="../../deploy/akka-sample-rest-java-${project.version}.jar"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -11,8 +11,8 @@ import javax.ws.rs.Produces;
|
|||
import se.scalablesolutions.akka.annotation.transactionrequired;
|
||||
import se.scalablesolutions.akka.annotation.prerestart;
|
||||
import se.scalablesolutions.akka.annotation.postrestart;
|
||||
import se.scalablesolutions.akka.state.PersistentMap;
|
||||
import se.scalablesolutions.akka.state.CassandraStorage;
|
||||
import se.scalablesolutions.akka.persistence.common.PersistentMap;
|
||||
import se.scalablesolutions.akka.persistence.cassandra.CassandraStorage;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import javax.ws.rs.Produces;
|
|||
import se.scalablesolutions.akka.annotation.transactionrequired;
|
||||
import se.scalablesolutions.akka.annotation.prerestart;
|
||||
import se.scalablesolutions.akka.annotation.postrestart;
|
||||
import se.scalablesolutions.akka.state.TransactionalState;
|
||||
import se.scalablesolutions.akka.state.TransactionalMap;
|
||||
import se.scalablesolutions.akka.stm.TransactionalState;
|
||||
import se.scalablesolutions.akka.stm.TransactionalMap;
|
||||
|
||||
/**
|
||||
* Try service out by invoking (multiple times):
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-sample-rest-scala</artifactId>
|
||||
<name>Akka REST Scala Sample Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/scala</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="target/akka-sample-rest-scala-${project.version}.jar"
|
||||
tofile="../../deploy/akka-sample-rest-scala-${project.version}.jar"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -5,10 +5,11 @@
|
|||
package sample.scala
|
||||
|
||||
import se.scalablesolutions.akka.actor.{Transactor, SupervisorFactory, Actor}
|
||||
import se.scalablesolutions.akka.state.{CassandraStorage, TransactionalState}
|
||||
import se.scalablesolutions.akka.stm.TransactionalState
|
||||
import se.scalablesolutions.akka.persistence.cassandra.CassandraStorage
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.comet.{AkkaClusterBroadcastFilter}
|
||||
import se.scalablesolutions.akka.comet.AkkaClusterBroadcastFilter
|
||||
|
||||
import java.lang.Integer
|
||||
import java.nio.ByteBuffer
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-sample-security</artifactId>
|
||||
<name>Akka Sample Security Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>jsr250-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/scala</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="target/akka-sample-security-${project.version}.jar"
|
||||
tofile="../../deploy/akka-sample-security-${project.version}.jar"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
####################
|
||||
# Akka Config File #
|
||||
####################
|
||||
|
||||
# This file has all the default settings, so all these could be removed with no visible effect.
|
||||
# Modify as needed.
|
||||
|
||||
<akka>
|
||||
version = "0.7-SNAPSHOT"
|
||||
|
||||
boot = ["se.scalablesolutions.akka.security.samples.Boot"] # FQN to the class doing initial active object/actor
|
||||
# supervisor bootstrap, should be defined in default constructor
|
||||
|
||||
<rest>
|
||||
filters = "se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"
|
||||
|
||||
# only one authenticator can be enabled for the security filter factory
|
||||
authenticator = "se.scalablesolutions.akka.security.samples.BasicAuthenticationService"
|
||||
# authenticator = "se.scalablesolutions.akka.security.samples.DigestAuthenticationService"
|
||||
# authenticator = "se.scalablesolutions.akka.security.samples.SpnegoAuthenticationService"
|
||||
|
||||
#
|
||||
# <kerberos>
|
||||
# servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
|
||||
# keyTabLocation = "URL to keytab"
|
||||
# kerberosDebug = "true"
|
||||
# realm = "EXAMPLE.COM"
|
||||
# </kerberos>
|
||||
|
||||
# service = on
|
||||
# hostname = "localhost"
|
||||
# port = 9998
|
||||
</rest>
|
||||
|
||||
</akka>
|
||||
|
|
@ -8,7 +8,7 @@ import se.scalablesolutions.akka.actor.{SupervisorFactory, Actor}
|
|||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.security.{DigestAuthenticationActor, UserInfo}
|
||||
import se.scalablesolutions.akka.state.TransactionalState
|
||||
import se.scalablesolutions.akka.stm.TransactionalState
|
||||
|
||||
class Boot {
|
||||
val factory = SupervisorFactory(
|
||||
|
|
|
|||
|
|
@ -1,56 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<name>Akka Sample Modules</name>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>akka-sample-chat</module>
|
||||
<module>akka-sample-lift</module>
|
||||
<module>akka-sample-security</module>
|
||||
<module>akka-sample-rest-scala</module>
|
||||
<module>akka-sample-rest-java</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-cassandra</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-persistence-redis</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-rest</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-comet</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>akka-security</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-security</artifactId>
|
||||
<name>Akka Security Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>akka-core</artifactId>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>jsr250-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<version>1.1.3-ea</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.liftweb</groupId>
|
||||
<artifactId>lift-util</artifactId>
|
||||
<version>1.1-M6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Testing -->
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<version>1.8.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -22,20 +22,21 @@
|
|||
|
||||
package se.scalablesolutions.akka.security
|
||||
|
||||
import _root_.se.scalablesolutions.akka.actor.{Scheduler, Actor, ActorRegistry}
|
||||
import _root_.se.scalablesolutions.akka.util.Logging
|
||||
import _root_.se.scalablesolutions.akka.Config
|
||||
import se.scalablesolutions.akka.actor.{Scheduler, Actor, ActorRegistry}
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.config.Config
|
||||
|
||||
import _root_.com.sun.jersey.api.model.AbstractMethod
|
||||
import _root_.com.sun.jersey.spi.container.{ResourceFilterFactory, ContainerRequest, ContainerRequestFilter, ContainerResponse, ContainerResponseFilter, ResourceFilter}
|
||||
import _root_.com.sun.jersey.core.util.Base64
|
||||
import _root_.javax.ws.rs.core.{SecurityContext, Context, Response}
|
||||
import _root_.javax.ws.rs.WebApplicationException
|
||||
import _root_.javax.annotation.security.{DenyAll, PermitAll, RolesAllowed}
|
||||
import _root_.java.security.Principal
|
||||
import _root_.java.util.concurrent.TimeUnit
|
||||
import com.sun.jersey.api.model.AbstractMethod
|
||||
import com.sun.jersey.spi.container.{ResourceFilterFactory, ContainerRequest, ContainerRequestFilter, ContainerResponse, ContainerResponseFilter, ResourceFilter}
|
||||
import com.sun.jersey.core.util.Base64
|
||||
|
||||
import _root_.net.liftweb.util.{SecurityHelpers, StringHelpers, IoHelpers}
|
||||
import javax.ws.rs.core.{SecurityContext, Context, Response}
|
||||
import javax.ws.rs.WebApplicationException
|
||||
import javax.annotation.security.{DenyAll, PermitAll, RolesAllowed}
|
||||
import java.security.Principal
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import net.liftweb.util.{SecurityHelpers, StringHelpers, IoHelpers}
|
||||
|
||||
object Enc extends SecurityHelpers with StringHelpers with IoHelpers
|
||||
|
||||
|
|
@ -86,10 +87,11 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging {
|
|||
override def filter(request: ContainerRequest): ContainerRequest =
|
||||
rolesAllowed match {
|
||||
case Some(roles) => {
|
||||
(authenticator !! (Authenticate(request, roles), 10000)).get.asInstanceOf[AnyRef] match {
|
||||
case OK => request
|
||||
case r if r.isInstanceOf[Response] =>
|
||||
(authenticator.!, 10000)) match {
|
||||
case Some(OK) => request
|
||||
case Some(r) if r.isInstanceOf[Response] =>
|
||||
throw new WebApplicationException(r.asInstanceOf[Response])
|
||||
case None => throw new WebApplicationException(408)
|
||||
case x => {
|
||||
log.error("Authenticator replied with unexpected result [%s]", x);
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR)
|
||||
|
|
@ -329,19 +331,19 @@ trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials] {
|
|||
def noncePurgeInterval = 2 * 60 * 1000 //ms
|
||||
}
|
||||
|
||||
import _root_.java.security.Principal
|
||||
import _root_.java.security.PrivilegedActionException
|
||||
import _root_.java.security.PrivilegedExceptionAction
|
||||
import java.security.Principal
|
||||
import java.security.PrivilegedActionException
|
||||
import java.security.PrivilegedExceptionAction
|
||||
|
||||
import _root_.javax.security.auth.login.AppConfigurationEntry
|
||||
import _root_.javax.security.auth.login.Configuration
|
||||
import _root_.javax.security.auth.login.LoginContext
|
||||
import _root_.javax.security.auth.Subject
|
||||
import _root_.javax.security.auth.kerberos.KerberosPrincipal
|
||||
import javax.security.auth.login.AppConfigurationEntry
|
||||
import javax.security.auth.login.Configuration
|
||||
import javax.security.auth.login.LoginContext
|
||||
import javax.security.auth.Subject
|
||||
import javax.security.auth.kerberos.KerberosPrincipal
|
||||
|
||||
import _root_.org.ietf.jgss.GSSContext
|
||||
import _root_.org.ietf.jgss.GSSCredential
|
||||
import _root_.org.ietf.jgss.GSSManager
|
||||
import org.ietf.jgss.GSSContext
|
||||
import org.ietf.jgss.GSSCredential
|
||||
import org.ietf.jgss.GSSManager
|
||||
|
||||
trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] {
|
||||
override def unauthorized =
|
||||
|
|
@ -349,7 +351,7 @@ trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] {
|
|||
|
||||
// for some reason the jersey Base64 class does not work with kerberos
|
||||
// but the commons Base64 does
|
||||
import _root_.org.apache.commons.codec.binary.Base64
|
||||
import org.apache.commons.codec.binary.Base64
|
||||
override def extractCredentials(r: Req): Option[SpnegoCredentials] = {
|
||||
val AuthHeader = """Negotiate\s(.*)""".r
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ import org.mockito.Mockito._
|
|||
import org.mockito.Matchers._
|
||||
import org.junit.{Before, After, Test}
|
||||
|
||||
import _root_.javax.ws.rs.core.{SecurityContext, Context, Response}
|
||||
import _root_.com.sun.jersey.spi.container.{ResourceFilterFactory, ContainerRequest, ContainerRequestFilter, ContainerResponse, ContainerResponseFilter, ResourceFilter}
|
||||
import _root_.com.sun.jersey.core.util.Base64
|
||||
import javax.ws.rs.core.{SecurityContext, Context, Response}
|
||||
import com.sun.jersey.spi.container.{ResourceFilterFactory, ContainerRequest, ContainerRequestFilter, ContainerResponse, ContainerResponseFilter, ResourceFilter}
|
||||
import com.sun.jersey.core.util.Base64
|
||||
|
||||
class BasicAuthenticatorSpec extends junit.framework.TestCase
|
||||
with Suite with MockitoSugar with MustMatchers {
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>akka-util-java</artifactId>
|
||||
<name>Akka Java Utilities Module</name>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.guiceyfruit</groupId>
|
||||
<artifactId>guice-core</artifactId>
|
||||
<version>2.0-beta-4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
7
akka-util-java/project/build.properties
Normal file
7
akka-util-java/project/build.properties
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
project.organization=se.scalablesolutions.akka
|
||||
project.name=akka-util-java
|
||||
project.version=0.7-SNAPSHOT
|
||||
scala.version=2.7.7
|
||||
sbt.version=0.7.1
|
||||
def.scala.version=2.7.7
|
||||
build.scala.versions=2.7.7
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue