Merge branch 'master' into 2.8-WIP
This commit is contained in:
commit
634caf52d2
92 changed files with 2305 additions and 2976 deletions
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -1,43 +1,23 @@
|
|||
package se.scalablesolutions.akka.remote
|
||||
|
||||
import org.jgroups.{JChannel, View, Address, Message, ExtendedMembershipListener, Receiver}
|
||||
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.remote.Cluster.{Node, RelayedMessage}
|
||||
import se.scalablesolutions.akka.actor.{ Actor, ActorRegistry}
|
||||
|
||||
import scala.collection.immutable.{Map, HashMap}
|
||||
|
||||
/**
|
||||
* JGroups Internal Cluster messages.
|
||||
*/
|
||||
private[remote] object JGroupsClusterActor {
|
||||
sealed trait JGroupsClusterMessage
|
||||
case object PapersPlease extends JGroupsClusterMessage
|
||||
case class Papers(addresses: List[RemoteAddress]) extends JGroupsClusterMessage
|
||||
case object Block extends JGroupsClusterMessage
|
||||
case object Unblock extends JGroupsClusterMessage
|
||||
case class Zombie(address: Address) extends JGroupsClusterMessage
|
||||
case class RegisterLocalNode(server: RemoteAddress) extends JGroupsClusterMessage
|
||||
case class DeregisterLocalNode(server: RemoteAddress) extends JGroupsClusterMessage
|
||||
}
|
||||
import org.jgroups.{JChannel, View => JG_VIEW, Address, Message => JG_MSG, ExtendedMembershipListener, Receiver}
|
||||
|
||||
/**
|
||||
* Clustering support via JGroups.
|
||||
* @Author Viktor Klang
|
||||
*/
|
||||
class JGroupsClusterActor extends ClusterActor {
|
||||
import JGroupsClusterActor._
|
||||
import org.scala_tools.javautils.Implicits._
|
||||
class JGroupsClusterActor extends BasicClusterActor {
|
||||
import ClusterActor._
|
||||
import org.scala_tools.javautils.Imports._
|
||||
|
||||
type ADDR_T = Address
|
||||
|
||||
@volatile private var isActive = false
|
||||
@volatile private var local: Node = Node(Nil)
|
||||
@volatile private var channel: Option[JChannel] = None
|
||||
@volatile private var remotes: Map[Address, Node] = Map()
|
||||
|
||||
override def init = {
|
||||
super.init
|
||||
log debug "Initiating JGroups-based cluster actor"
|
||||
remotes = new HashMap[Address, Node]
|
||||
val me = this
|
||||
isActive = true
|
||||
|
||||
|
|
@ -48,108 +28,36 @@ class JGroupsClusterActor extends ClusterActor {
|
|||
|
||||
def setState(state: Array[Byte]): Unit = ()
|
||||
|
||||
def receive(msg: Message): Unit = if (isActive) me send msg
|
||||
def receive(m: JG_MSG): Unit =
|
||||
if (isActive && m.getSrc != channel.map(_.getAddress).getOrElse(m.getSrc)) me send Message(m.getSrc,m.getRawBuffer)
|
||||
|
||||
def viewAccepted(view: View): Unit = if (isActive) me send view
|
||||
def viewAccepted(view: JG_VIEW): Unit =
|
||||
if (isActive) me send View(Set[ADDR_T]() ++ view.getMembers.asScala - channel.get.getAddress)
|
||||
|
||||
def suspect(a: Address): Unit = if (isActive) me send Zombie(a)
|
||||
def suspect(a: Address): Unit =
|
||||
if (isActive) me send Zombie(a)
|
||||
|
||||
def block: Unit = if (isActive) me send Block
|
||||
def block: Unit =
|
||||
log debug "UNSUPPORTED: JGroupsClusterActor::block" //TODO HotSwap to a buffering body
|
||||
|
||||
def unblock: Unit = if (isActive) me send Unblock
|
||||
def unblock: Unit =
|
||||
log debug "UNSUPPORTED: JGroupsClusterActor::unblock" //TODO HotSwap back and flush the buffer
|
||||
})
|
||||
})
|
||||
channel.map(_.connect(name))
|
||||
}
|
||||
|
||||
def lookup[T](handleRemoteAddress: PartialFunction[RemoteAddress, T]): Option[T] =
|
||||
remotes.values.toList.flatMap(_.endpoints).find(handleRemoteAddress isDefinedAt _).map(handleRemoteAddress)
|
||||
protected def toOneNode(dest : Address, msg: Array[Byte]): Unit =
|
||||
for (c <- channel) c.send(new JG_MSG(dest, null, msg))
|
||||
|
||||
def registerLocalNode(hostname: String, port: Int): Unit =
|
||||
send(RegisterLocalNode(RemoteAddress(hostname, port)))
|
||||
|
||||
def deregisterLocalNode(hostname: String, port: Int): Unit =
|
||||
send(DeregisterLocalNode(RemoteAddress(hostname, port)))
|
||||
|
||||
def relayMessage(to: Class[_ <: Actor], msg: AnyRef): Unit =
|
||||
send(RelayedMessage(to.getName, msg))
|
||||
|
||||
private def broadcast[T <: AnyRef](recipients: Iterable[Address], msg: T): Unit = {
|
||||
lazy val m = Cluster.serializer out msg
|
||||
for (c <- channel; r <- recipients) c.send(new Message(r, null, m))
|
||||
}
|
||||
|
||||
private def broadcast[T <: AnyRef](msg: T): Unit =
|
||||
//Don't broadcast if we are not connected anywhere...
|
||||
if (!remotes.isEmpty) channel.map(_.send(new Message(null, null, Cluster.serializer out msg)))
|
||||
|
||||
def receive = {
|
||||
case Zombie(x) => { //Ask the presumed zombie for papers and prematurely treat it as dead
|
||||
log debug ("Killing Zombie Node: %s", x)
|
||||
broadcast(x :: Nil, PapersPlease)
|
||||
remotes = remotes - x
|
||||
}
|
||||
|
||||
case v: View => {
|
||||
// Not present in the cluster anymore = presumably zombies
|
||||
// Nodes we have no prior knowledge existed = unknowns
|
||||
val members = Set[Address]() ++ v.getMembers.asScala - channel.get.getAddress // Exclude ourselves
|
||||
val zombies = Set[Address]() ++ remotes.keySet -- members
|
||||
val unknown = members -- remotes.keySet
|
||||
|
||||
log debug v.printDetails
|
||||
|
||||
// Tell the zombies and unknowns to provide papers and prematurely treat the zombies as dead
|
||||
broadcast(zombies ++ unknown, PapersPlease)
|
||||
remotes = remotes -- zombies
|
||||
}
|
||||
|
||||
case m: Message => {
|
||||
if (m.getSrc != channel.map(_.getAddress).getOrElse(m.getSrc)) // Handle non-own messages only, and only if we're connected
|
||||
(Cluster.serializer in (m.getRawBuffer, None)) match {
|
||||
|
||||
case PapersPlease => {
|
||||
log debug ("Asked for papers by %s", m.getSrc)
|
||||
broadcast(m.getSrc :: Nil, Papers(local.endpoints))
|
||||
|
||||
if (remotes.get(m.getSrc).isEmpty) // If we were asked for papers from someone we don't know, ask them!
|
||||
broadcast(m.getSrc :: Nil, PapersPlease)
|
||||
}
|
||||
|
||||
case Papers(x) => remotes = remotes + (m.getSrc -> Node(x))
|
||||
|
||||
case RelayedMessage(c, m) => ActorRegistry.actorsFor(c).map(_ send m)
|
||||
|
||||
case unknown => log debug ("Unknown message: %s", unknown.toString)
|
||||
}
|
||||
}
|
||||
|
||||
case rm @ RelayedMessage(_, _) => {
|
||||
log debug ("Relaying message: %s", rm)
|
||||
broadcast(rm)
|
||||
}
|
||||
|
||||
case RegisterLocalNode(s) => {
|
||||
log debug ("RegisterLocalNode: %s", s)
|
||||
local = Node(local.endpoints + s)
|
||||
broadcast(Papers(local.endpoints))
|
||||
}
|
||||
|
||||
case DeregisterLocalNode(s) => {
|
||||
log debug ("DeregisterLocalNode: %s", s)
|
||||
local = Node(local.endpoints - s)
|
||||
broadcast(Papers(local.endpoints))
|
||||
}
|
||||
|
||||
case Block => log debug "UNSUPPORTED: JGroupsClusterActor::block" //TODO HotSwap to a buffering body
|
||||
case Unblock => log debug "UNSUPPORTED: JGroupsClusterActor::unblock" //TODO HotSwap back and flush the buffer
|
||||
}
|
||||
protected def toAllNodes(msg : Array[Byte]) : Unit =
|
||||
for (c <- channel) c.send(new JG_MSG(null, null, msg))
|
||||
|
||||
override def shutdown = {
|
||||
super.shutdown
|
||||
log debug ("Shutting down %s", toString)
|
||||
isActive = false
|
||||
channel.foreach(_.shutdown)
|
||||
remotes = Map()
|
||||
channel = None
|
||||
}
|
||||
}
|
||||
|
|
@ -10,14 +10,24 @@
|
|||
<parent>
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!--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>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
package se.scalablesolutions.akka.remote
|
||||
|
||||
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
|
||||
}
|
||||
/**
|
||||
* Clustering support via Shoal.
|
||||
*/
|
||||
class ShoalClusterActor extends BasicClusterActor {
|
||||
|
||||
type ADDR_T = String
|
||||
|
||||
@volatile protected var gms : Option[GroupManagementService] = None
|
||||
protected lazy val serverName : String = RemoteServer.HOSTNAME + ":" + RemoteServer.PORT
|
||||
@volatile private var isActive = false
|
||||
|
||||
lazy val topic : String = config.getString("akka.remote.cluster.shoal.topic") getOrElse "akka-messages"
|
||||
|
||||
override def init = {
|
||||
super.init
|
||||
gms = Some(createGMS)
|
||||
isActive = true
|
||||
}
|
||||
|
||||
override def shutdown = {
|
||||
super.shutdown
|
||||
isActive = false
|
||||
for(g <- gms) g.shutdown(GMSConstants.shutdownType.INSTANCE_SHUTDOWN)
|
||||
gms = None
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Properties instance with properties designated for the underlying
|
||||
* Shoal cluster transport (JXTA,JGroups)
|
||||
*/
|
||||
protected def properties() : Properties = {
|
||||
config.getConfigMap("akka.remote.cluster.shoal.properties").map( m => {
|
||||
new Properties(){
|
||||
for(key <- m.keys) setProperty(key,m(key))
|
||||
}
|
||||
}).getOrElse(null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a GroupManagementService, provides it with the proper properties
|
||||
* Adds callbacks and boots up the cluster
|
||||
*/
|
||||
protected def createGMS : 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))
|
||||
g.addActionFactory(new FailureNotificationActionFactoryImpl(callback))
|
||||
g.addActionFactory(new PlannedShutdownActionFactoryImpl(callback))
|
||||
g.addActionFactory(new MessageActionFactoryImpl(callback), topic)
|
||||
g.join
|
||||
g
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CallBack instance that deals with the cluster signalling
|
||||
*/
|
||||
protected def createCallback : CallBack = {
|
||||
import org.scala_tools.javautils.Imports._
|
||||
val me = this
|
||||
new CallBack {
|
||||
def processNotification(signal : Signal) {
|
||||
try {
|
||||
signal.acquire()
|
||||
if(isActive) {
|
||||
signal match {
|
||||
case ms : MessageSignal => me send Message(ms.getMemberToken,ms.getMessage)
|
||||
case jns : JoinNotificationSignal => me send View(Set[ADDR_T]() ++ jns.getCurrentCoreMembers.asScala - serverName)
|
||||
case fss : FailureSuspectedSignal => me send Zombie(fss.getMemberToken)
|
||||
case fns : FailureNotificationSignal => me send Zombie(fns.getMemberToken)
|
||||
case _ => log.debug("Unhandled signal: [%s]",signal)
|
||||
}
|
||||
}
|
||||
signal.release()
|
||||
} catch {
|
||||
case e : SignalAcquireException => log.warning(e,"SignalAcquireException")
|
||||
case e : SignalReleaseException => log.warning(e,"SignalReleaseException")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected def toOneNode(dest : ADDR_T, msg : Array[Byte]) : Unit =
|
||||
for(g <- gms) g.getGroupHandle.sendMessage(dest,topic, msg)
|
||||
|
||||
protected def toAllNodes(msg : Array[Byte]) : Unit =
|
||||
for(g <- gms) g.getGroupHandle.sendMessage(topic, msg)
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-cluster-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>akka-cluster-jgroups</module>
|
||||
<!--module>akka-cluster-tribes</module>
|
||||
<module>akka-cluster-shoal</module-->
|
||||
<!--module>akka-cluster-tribes</module-->
|
||||
<module>akka-cluster-shoal</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-annotations</artifactId>
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
<dependency>
|
||||
<groupId>org.atmosphere</groupId>
|
||||
<artifactId>atmosphere-runtime</artifactId>
|
||||
<version>0.5.v20100104</version>
|
||||
<version>${atmosphere.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
27
akka-comet/src/main/scala/AkkaBroadcaster.scala
Normal file
27
akka-comet/src/main/scala/AkkaBroadcaster.scala
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.comet
|
||||
|
||||
import org.atmosphere.cpr.{AtmosphereResourceEvent, AtmosphereResource}
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
|
||||
class AkkaBroadcaster extends org.atmosphere.jersey.JerseyBroadcaster {
|
||||
name = classOf[AkkaBroadcaster].getName
|
||||
|
||||
val caster = new Actor {
|
||||
def receive = { case f : Function0[_] => f() }
|
||||
|
||||
start
|
||||
}
|
||||
|
||||
override def destroy {
|
||||
super.destroy
|
||||
caster.stop
|
||||
}
|
||||
|
||||
protected override def broadcast(r : AtmosphereResource[_,_], e : AtmosphereResourceEvent[_,_]) = {
|
||||
caster.send( () => super.broadcast(r,e) )
|
||||
}
|
||||
}
|
||||
|
|
@ -6,8 +6,8 @@ package se.scalablesolutions.akka.comet
|
|||
|
||||
import se.scalablesolutions.akka.actor.{Actor}
|
||||
import se.scalablesolutions.akka.remote.{Cluster}
|
||||
import org.atmosphere.cpr.{ClusterBroadcastFilter,Broadcaster}
|
||||
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
|
||||
|
|
@ -34,14 +34,14 @@ class AkkaClusterBroadcastFilter extends Actor with ClusterBroadcastFilter[AnyRe
|
|||
* ClusterCometBroadcasts are not broadcasted because they originate from the cluster,
|
||||
* otherwise we'd start a chain reaction.
|
||||
*/
|
||||
def filter(o : AnyRef) : AnyRef = o match {
|
||||
def filter(o : AnyRef) = new BroadcastFilter.BroadcastAction(o match {
|
||||
case ClusterCometBroadcast(_,m) => m //Do not re-broadcast, just unbox and pass along
|
||||
|
||||
case m : AnyRef => { //Relay message to the cluster and pass along
|
||||
Cluster.relayMessage(classOf[AkkaClusterBroadcastFilter],ClusterCometBroadcast(clusterName,m))
|
||||
m
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
def receive = {
|
||||
//Only handle messages intended for this particular instance
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
|||
import org.atmosphere.container.GrizzlyCometSupport
|
||||
import org.atmosphere.cpr.{AtmosphereServlet, AtmosphereServletProcessor, AtmosphereResource, AtmosphereResourceEvent,CometSupport,CometSupportResolver,DefaultCometSupportResolver}
|
||||
import org.atmosphere.handler.{ReflectorServletProcessor, AbstractReflectorAtmosphereHandler}
|
||||
import org.atmosphere.jersey.JerseyBroadcaster
|
||||
|
||||
/**
|
||||
* Akka's Comet servlet to be used when deploying actors exposed as Comet (and REST) services in a
|
||||
|
|
@ -51,8 +50,8 @@ class AkkaServlet extends org.atmosphere.cpr.AtmosphereServlet with Logging {
|
|||
*/
|
||||
override def loadConfiguration(sc: ServletConfig) {
|
||||
config = new AtmosphereConfig { supportSession = false }
|
||||
setDefaultBroadcasterClassName(classOf[JerseyBroadcaster].getName)
|
||||
atmosphereHandlers.put("/*", new AtmosphereServlet.AtmosphereHandlerWrapper(servlet, new JerseyBroadcaster))
|
||||
setDefaultBroadcasterClassName(classOf[AkkaBroadcaster].getName)
|
||||
atmosphereHandlers.put("/*", new AtmosphereServlet.AtmosphereHandlerWrapper(servlet, new AkkaBroadcaster))
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss.netty</groupId>
|
||||
<artifactId>netty</artifactId>
|
||||
<version>3.2.0.ALPHA2</version>
|
||||
<version>3.2.0.ALPHA3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-tools</groupId>
|
||||
|
|
@ -91,7 +91,7 @@
|
|||
<dependency>
|
||||
<groupId>sjson.json</groupId>
|
||||
<artifactId>sjson</artifactId>
|
||||
<version>0.3</version>
|
||||
<version>0.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For Testing -->
|
||||
|
|
|
|||
0
akka-core/src/main/resources/META-INF/aop.xml
Executable file → Normal file
0
akka-core/src/main/resources/META-INF/aop.xml
Executable file → Normal file
|
|
@ -4,10 +4,9 @@
|
|||
|
||||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import java.net.InetSocketAddress
|
||||
|
||||
import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.RemoteRequest
|
||||
import se.scalablesolutions.akka.remote.{RemoteProtocolBuilder, RemoteClient, RemoteRequestIdFactory}
|
||||
import se.scalablesolutions.akka.dispatch.{MessageDispatcher, FutureResult}
|
||||
import se.scalablesolutions.akka.config.ScalaConfig._
|
||||
import se.scalablesolutions.akka.serialization.Serializer
|
||||
import se.scalablesolutions.akka.util._
|
||||
|
|
@ -16,8 +15,8 @@ import org.codehaus.aspectwerkz.joinpoint.{MethodRtti, JoinPoint}
|
|||
import org.codehaus.aspectwerkz.proxy.Proxy
|
||||
import org.codehaus.aspectwerkz.annotation.{Aspect, Around}
|
||||
|
||||
import java.net.InetSocketAddress
|
||||
import java.lang.reflect.{InvocationTargetException, Method}
|
||||
import se.scalablesolutions.akka.dispatch.{Dispatchers, MessageDispatcher, FutureResult}
|
||||
|
||||
object Annotations {
|
||||
import se.scalablesolutions.akka.annotation._
|
||||
|
|
@ -234,6 +233,7 @@ private[akka] sealed case class AspectInit(
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
@Aspect("perInstance")
|
||||
// TODO: add @shutdown callback to ActiveObject in which we get the Aspect through 'Aspects.aspectOf(MyAspect.class, targetInstance)' and shuts down the Dispatcher actor
|
||||
private[akka] sealed class ActiveObjectAspect {
|
||||
@volatile private var isInitialized = false
|
||||
private var target: Class[_] = _
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import se.scalablesolutions.akka.stm.Transaction._
|
|||
import se.scalablesolutions.akka.stm.TransactionManagement._
|
||||
import se.scalablesolutions.akka.stm.{StmException, TransactionManagement}
|
||||
import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.RemoteRequest
|
||||
import se.scalablesolutions.akka.remote.{RemoteProtocolBuilder,RemoteServer, RemoteClient, RemoteRequestIdFactory}
|
||||
import se.scalablesolutions.akka.remote.{RemoteProtocolBuilder, RemoteClient, RemoteRequestIdFactory}
|
||||
import se.scalablesolutions.akka.serialization.Serializer
|
||||
import se.scalablesolutions.akka.util.{HashCode, Logging, UUID}
|
||||
|
||||
|
|
@ -72,18 +72,8 @@ object Actor extends Logging {
|
|||
val HOSTNAME = config.getString("akka.remote.server.hostname", "localhost")
|
||||
val PORT = config.getInt("akka.remote.server.port", 9999)
|
||||
|
||||
object Sender extends Actor {
|
||||
object Sender{
|
||||
implicit val Self: Option[Actor] = None
|
||||
|
||||
def receive = {
|
||||
case unknown =>
|
||||
Actor.log.error(
|
||||
"Actor.Sender can't process messages. Received message [%s]." +
|
||||
"This error could occur if you either:" +
|
||||
"\n\t- Explicitly send a message to the Actor.Sender object." +
|
||||
"\n\t- Invoking the 'reply(..)' method or sending a message to the 'sender' reference " +
|
||||
"\n\t when you have sent the original request from a instance *not* being an actor.", unknown)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -145,11 +135,15 @@ object Actor extends Logging {
|
|||
* }
|
||||
* </pre>
|
||||
*/
|
||||
def spawn(body: => Unit): Actor = new Actor() {
|
||||
start
|
||||
body
|
||||
def receive = {
|
||||
case _ => throw new IllegalArgumentException("Actors created with 'actor(body: => Unit)' do not respond to messages.")
|
||||
def spawn(body: => Unit): Actor = {
|
||||
case object Spawn
|
||||
new Actor() {
|
||||
start
|
||||
send(Spawn)
|
||||
def receive = {
|
||||
case Spawn => body
|
||||
case _ => throw new IllegalArgumentException("Actors created with 'actor(body: => Unit)' do not respond to messages.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +219,7 @@ trait Actor extends TransactionManagement {
|
|||
private[akka] var _remoteAddress: Option[InetSocketAddress] = None
|
||||
private[akka] var _linkedActors: Option[HashSet[Actor]] = None
|
||||
private[akka] var _supervisor: Option[Actor] = None
|
||||
private[akka] var _contactAddress: Option[InetSocketAddress] = None
|
||||
private[akka] var _replyToAddress: Option[InetSocketAddress] = None
|
||||
private[akka] val _mailbox: Queue[MessageInvocation] = new ConcurrentLinkedQueue[MessageInvocation]
|
||||
|
||||
// ====================================
|
||||
|
|
@ -445,6 +439,7 @@ trait Actor extends TransactionManagement {
|
|||
_isShutDown = true
|
||||
shutdown
|
||||
ActorRegistry.unregister(this)
|
||||
_remoteAddress.foreach(address => RemoteClient.unregister(address.getHostName, address.getPort, uuid))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -480,7 +475,7 @@ trait Actor extends TransactionManagement {
|
|||
* </pre>
|
||||
*/
|
||||
def !(message: Any)(implicit sender: Option[Actor]) = {
|
||||
//FIXME 2.8 def !(message: Any)(implicit sender: Option[Actor] = None) = {
|
||||
//FIXME 2.8 def !(message: Any)(implicit sender: Option[Actor] = None) = {
|
||||
if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages")
|
||||
if (_isRunning) postMessageToMailbox(message, sender)
|
||||
else throw new IllegalStateException("Actor has not been started, you need to invoke 'actor.start' before using it")
|
||||
|
|
@ -492,8 +487,7 @@ trait Actor extends TransactionManagement {
|
|||
def send(message: Any) = {
|
||||
if (_isKilled) throw new ActorKilledException("Actor [" + toString + "] has been killed, can't respond to messages")
|
||||
if (_isRunning) postMessageToMailbox(message, None)
|
||||
else throw new IllegalStateException(
|
||||
"Actor has not been started, you need to invoke 'actor.start' before using it")
|
||||
else throw new IllegalStateException("Actor has not been started, you need to invoke 'actor.start' before using it")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -596,7 +590,7 @@ trait Actor extends TransactionManagement {
|
|||
"\n\t\t2. Send a message from an instance that is *not* an actor" +
|
||||
"\n\t\t3. Send a message to an Active Object annotated with the '@oneway' annotation? " +
|
||||
"\n\tIf so, switch to '!!' (or remove '@oneway') which passes on an implicit future" +
|
||||
"\n\tthat will be bound by the argument passed to 'reply'. Alternatively, you can use setContactAddress to make sure the actor can be contacted over the network.")
|
||||
"\n\tthat will be bound by the argument passed to 'reply'. Alternatively, you can use setReplyToAddress to make sure the actor can be contacted over the network.")
|
||||
case Some(future) =>
|
||||
future.completeWithResult(message)
|
||||
}
|
||||
|
|
@ -634,18 +628,18 @@ trait Actor extends TransactionManagement {
|
|||
def makeRemote(address: InetSocketAddress): Unit =
|
||||
if (_isRunning) throw new IllegalStateException("Can't make a running actor remote. Make sure you call 'makeRemote' before 'start'.")
|
||||
else {
|
||||
_remoteAddress = Some(address)
|
||||
if(_contactAddress.isEmpty)
|
||||
setContactAddress(RemoteServer.HOSTNAME,RemoteServer.PORT)
|
||||
_remoteAddress = Some(address)
|
||||
RemoteClient.register(address.getHostName, address.getPort, uuid)
|
||||
if (_replyToAddress.isEmpty) setReplyToAddress(Actor.HOSTNAME, Actor.PORT)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the contact address for this actor. This is used for replying to messages sent asynchronously when no reply channel exists.
|
||||
*/
|
||||
def setContactAddress(hostname: String, port: Int): Unit = setContactAddress(new InetSocketAddress(hostname, port))
|
||||
def setReplyToAddress(hostname: String, port: Int): Unit = setReplyToAddress(new InetSocketAddress(hostname, port))
|
||||
|
||||
def setContactAddress(address: InetSocketAddress): Unit = _contactAddress = Some(address)
|
||||
def setReplyToAddress(address: InetSocketAddress): Unit = _replyToAddress = Some(address)
|
||||
|
||||
/**
|
||||
* Invoking 'makeTransactionRequired' means that the actor will **start** a new transaction if non exists.
|
||||
|
|
@ -793,7 +787,7 @@ trait Actor extends TransactionManagement {
|
|||
actor
|
||||
}
|
||||
|
||||
private def postMessageToMailbox(message: Any, sender: Option[Actor]): Unit = {
|
||||
protected[akka] def postMessageToMailbox(message: Any, sender: Option[Actor]): Unit = {
|
||||
if (_remoteAddress.isDefined) {
|
||||
val requestBuilder = RemoteRequest.newBuilder
|
||||
.setId(RemoteRequestIdFactory.nextId)
|
||||
|
|
@ -803,26 +797,24 @@ trait Actor extends TransactionManagement {
|
|||
.setIsActor(true)
|
||||
.setIsOneWay(true)
|
||||
.setIsEscaped(false)
|
||||
|
||||
val id = registerSupervisorAsRemoteActor
|
||||
if (id.isDefined) requestBuilder.setSupervisorUuid(id.get)
|
||||
if(id.isDefined)
|
||||
requestBuilder.setSupervisorUuid(id.get)
|
||||
|
||||
// set the source fields used to reply back to the original sender
|
||||
// (i.e. not the remote proxy actor)
|
||||
if (sender.isDefined) {
|
||||
requestBuilder.setSourceTarget(sender.get.getClass.getName)
|
||||
requestBuilder.setSourceUuid(sender.get.uuid)
|
||||
log.debug("Setting sending actor as %s, %s", sender.get.getClass.getName, _contactAddress)
|
||||
if(sender.isDefined) {
|
||||
val s = sender.get
|
||||
requestBuilder.setSourceTarget(s.getClass.getName)
|
||||
requestBuilder.setSourceUuid(s.uuid)
|
||||
|
||||
if (sender.get._contactAddress.isDefined) {
|
||||
val addr = sender.get._contactAddress.get
|
||||
requestBuilder.setSourceHostname(addr.getHostName())
|
||||
requestBuilder.setSourcePort(addr.getPort())
|
||||
} else {
|
||||
// set the contact address to the default values from the
|
||||
// configuration file
|
||||
requestBuilder.setSourceHostname(Actor.HOSTNAME)
|
||||
requestBuilder.setSourcePort(Actor.PORT)
|
||||
}
|
||||
val (host,port) = s._replyToAddress.map(a => (a.getHostName,a.getPort)).getOrElse((Actor.HOSTNAME,Actor.PORT))
|
||||
|
||||
log.debug("Setting sending actor as %s @ %s:%s", s.getClass.getName, host, port)
|
||||
|
||||
requestBuilder.setSourceHostname(host)
|
||||
requestBuilder.setSourcePort(port)
|
||||
}
|
||||
RemoteProtocolBuilder.setMessage(message, requestBuilder)
|
||||
RemoteClient.clientFor(_remoteAddress.get).send(requestBuilder.build, None)
|
||||
|
|
@ -831,11 +823,13 @@ trait Actor extends TransactionManagement {
|
|||
if (_isEventBased) {
|
||||
_mailbox.add(invocation)
|
||||
if (_isSuspended) invocation.send
|
||||
} else invocation.send
|
||||
}
|
||||
else
|
||||
invocation.send
|
||||
}
|
||||
}
|
||||
|
||||
private def postMessageToMailboxAndCreateFutureResultWithTimeout(
|
||||
protected[akka] def postMessageToMailboxAndCreateFutureResultWithTimeout(
|
||||
message: Any,
|
||||
timeout: Long,
|
||||
senderFuture: Option[CompletableFutureResult]): CompletableFutureResult = {
|
||||
|
|
@ -926,7 +920,7 @@ trait Actor extends TransactionManagement {
|
|||
if (senderFuture.isEmpty) throw new StmException(
|
||||
"Can't continue transaction in a one-way fire-forget message send" +
|
||||
"\n\tE.g. using Actor '!' method or Active Object 'void' method" +
|
||||
"\n\tPlease use the Actor '!!', '!?' methods or Active Object method with non-void return type")
|
||||
"\n\tPlease use the Actor '!!' method or Active Object method with non-void return type")
|
||||
atomic {
|
||||
proceed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ package se.scalablesolutions.akka.actor
|
|||
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.collection.mutable.{ListBuffer, HashMap}
|
||||
import scala.reflect.Manifest
|
||||
|
||||
/**
|
||||
* Registry holding all actor instances, mapped by class and the actor's id field (which can be set by user-code).
|
||||
|
|
@ -17,6 +18,30 @@ object ActorRegistry extends Logging {
|
|||
private val actorsByClassName = new HashMap[String, List[Actor]]
|
||||
private val actorsById = new HashMap[String, List[Actor]]
|
||||
|
||||
/**
|
||||
* Returns all actors in the system.
|
||||
*/
|
||||
def actors: List[Actor] = synchronized {
|
||||
val all = new ListBuffer[Actor]
|
||||
actorsById.values.foreach(all ++= _)
|
||||
all.toList
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes a function for all actors.
|
||||
*/
|
||||
def foreach(f: (Actor) => Unit) = actors.foreach(f)
|
||||
|
||||
/**
|
||||
* Finds all actors that are subtypes of the class passed in as the Manifest argument.
|
||||
*/
|
||||
def actorsFor[T <: Actor](implicit manifest: Manifest[T]): List[T] = synchronized {
|
||||
for (actor <- actors; if manifest.erasure.isAssignableFrom(actor.getClass)) yield actor.asInstanceOf[T]
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all actors of the exact type specified by the class passed in as the Class argument.
|
||||
*/
|
||||
def actorsFor[T <: Actor](clazz: Class[T]): List[T] = synchronized {
|
||||
actorsByClassName.get(clazz.getName) match {
|
||||
case None => Nil
|
||||
|
|
@ -24,6 +49,9 @@ object ActorRegistry extends Logging {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all actors that has a specific id.
|
||||
*/
|
||||
def actorsFor(id : String): List[Actor] = synchronized {
|
||||
actorsById.get(id) match {
|
||||
case None => Nil
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ import se.scalablesolutions.akka.Config._
|
|||
trait BootableActorLoaderService extends Bootable with Logging {
|
||||
|
||||
val BOOT_CLASSES = config.getList("akka.boot")
|
||||
var applicationLoader: Option[ClassLoader] = None
|
||||
lazy val applicationLoader: Option[ClassLoader] = createApplicationClassLoader
|
||||
|
||||
protected def runApplicationBootClasses : Option[ClassLoader] = {
|
||||
val loader =
|
||||
protected def createApplicationClassLoader : Option[ClassLoader] = {
|
||||
Some(
|
||||
if (HOME.isDefined) {
|
||||
val CONFIG = HOME.get + "/config"
|
||||
val DEPLOY = HOME.get + "/deploy"
|
||||
|
|
@ -30,24 +30,21 @@ trait BootableActorLoaderService extends Bootable with Logging {
|
|||
}
|
||||
val toDeploy = for (f <- DEPLOY_DIR.listFiles().toArray.toList.asInstanceOf[List[File]]) yield f.toURL
|
||||
log.info("Deploying applications from [%s]: [%s]", DEPLOY, toDeploy.toArray.toList)
|
||||
new URLClassLoader(toDeploy.toArray, getClass.getClassLoader)
|
||||
new URLClassLoader(toDeploy.toArray, ClassLoader.getSystemClassLoader)
|
||||
} else if (getClass.getClassLoader.getResourceAsStream("akka.conf") ne null) {
|
||||
getClass.getClassLoader
|
||||
} else throw new IllegalStateException(
|
||||
"AKKA_HOME is not defined and no 'akka.conf' can be found on the classpath, aborting")
|
||||
for (clazz <- BOOT_CLASSES) {
|
||||
)
|
||||
}
|
||||
|
||||
abstract override def onLoad = {
|
||||
for (loader <- applicationLoader; clazz <- BOOT_CLASSES) {
|
||||
log.info("Loading boot class [%s]", clazz)
|
||||
loader.loadClass(clazz).newInstance
|
||||
}
|
||||
Some(loader)
|
||||
}
|
||||
|
||||
abstract override def onLoad = {
|
||||
applicationLoader = runApplicationBootClasses
|
||||
super.onLoad
|
||||
super.onLoad
|
||||
}
|
||||
|
||||
abstract override def onUnload = {
|
||||
ActorRegistry.shutdownAll
|
||||
}
|
||||
abstract override def onUnload = ActorRegistry.shutdownAll
|
||||
}
|
||||
|
|
@ -23,22 +23,26 @@ trait BootableRemoteActorService extends Bootable with Logging {
|
|||
def startRemoteService = remoteServerThread.start
|
||||
|
||||
abstract override def onLoad = {
|
||||
super.onLoad //Make sure the actors facility is loaded before we load the remote service
|
||||
if(config.getBool("akka.remote.server.service", true)){
|
||||
log.info("Starting up Cluster Service")
|
||||
Cluster.start
|
||||
super.onLoad //Initialize BootableActorLoaderService before remote service
|
||||
log.info("Initializing Remote Actors Service...")
|
||||
startRemoteService
|
||||
log.info("Remote Actors Service initialized!")
|
||||
}
|
||||
else
|
||||
super.onLoad
|
||||
|
||||
}
|
||||
|
||||
abstract override def onUnload = {
|
||||
super.onUnload
|
||||
if (remoteServerThread.isAlive) {
|
||||
super.onUnload
|
||||
if (remoteServerThread.isAlive) {
|
||||
log.info("Shutting down Remote Actors Service")
|
||||
RemoteNode.shutdown
|
||||
log.info("Shutting down Cluster Service")
|
||||
Cluster.shutdown
|
||||
remoteServerThread.join(1000)
|
||||
}
|
||||
Cluster.shutdown
|
||||
}
|
||||
}
|
||||
|
|
@ -26,53 +26,220 @@ trait Cluster {
|
|||
def relayMessage(to: Class[_ <: Actor], msg: AnyRef): Unit
|
||||
|
||||
def lookup[T](pf: PartialFunction[RemoteAddress, T]): Option[T]
|
||||
|
||||
def foreach(f : (RemoteAddress) => Unit) : Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for cluster actor implementations.
|
||||
* Base trait for Cluster implementations
|
||||
*
|
||||
* @author Viktor Klang
|
||||
*/
|
||||
abstract class ClusterActor extends Actor with Cluster {
|
||||
trait ClusterActor extends Actor with Cluster {
|
||||
val name = config.getString("akka.remote.cluster.name") getOrElse "default"
|
||||
}
|
||||
|
||||
/**
|
||||
* A singleton representing the Cluster.
|
||||
* Companion object to ClusterActor that defines some common messages
|
||||
*
|
||||
* @author Viktor Klang
|
||||
*/
|
||||
private[remote] object ClusterActor {
|
||||
sealed trait ClusterMessage
|
||||
|
||||
private[remote] case class RelayedMessage(actorClassFQN: String, msg: AnyRef) extends ClusterMessage
|
||||
|
||||
private[remote] case class Node(endpoints: List[RemoteAddress])
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for cluster actor implementations.
|
||||
* Provides most of the behavior out of the box
|
||||
* only needs to be gives hooks into the underlaying cluster impl.
|
||||
*/
|
||||
abstract class BasicClusterActor extends ClusterActor {
|
||||
import ClusterActor._
|
||||
|
||||
case class Message(sender : ADDR_T,msg : Array[Byte])
|
||||
case object PapersPlease extends ClusterMessage
|
||||
case class Papers(addresses: List[RemoteAddress]) extends ClusterMessage
|
||||
case object Block extends ClusterMessage
|
||||
case object Unblock extends ClusterMessage
|
||||
case class View(othersPresent : Set[ADDR_T]) extends ClusterMessage
|
||||
case class Zombie(address: ADDR_T) extends ClusterMessage
|
||||
case class RegisterLocalNode(server: RemoteAddress) extends ClusterMessage
|
||||
case class DeregisterLocalNode(server: RemoteAddress) extends ClusterMessage
|
||||
|
||||
type ADDR_T
|
||||
|
||||
|
||||
@volatile private var local: Node = Node(Nil)
|
||||
@volatile private var remotes: Map[ADDR_T, Node] = Map()
|
||||
|
||||
override def init = {
|
||||
remotes = new HashMap[ADDR_T, Node]
|
||||
}
|
||||
|
||||
override def shutdown = {
|
||||
remotes = Map()
|
||||
}
|
||||
|
||||
def receive = {
|
||||
case v @ View(members) => {
|
||||
// Not present in the cluster anymore = presumably zombies
|
||||
// Nodes we have no prior knowledge existed = unknowns
|
||||
val zombies = Set[ADDR_T]() ++ remotes.keySet -- members
|
||||
val unknown = members -- remotes.keySet
|
||||
|
||||
log debug ("Updating view")
|
||||
log debug ("Other memebers: [%s]",members)
|
||||
log debug ("Zombies: [%s]",zombies)
|
||||
log debug ("Unknowns: [%s]",unknown)
|
||||
|
||||
// Tell the zombies and unknowns to provide papers and prematurely treat the zombies as dead
|
||||
broadcast(zombies ++ unknown, PapersPlease)
|
||||
remotes = remotes -- zombies
|
||||
}
|
||||
|
||||
case Zombie(x) => { //Ask the presumed zombie for papers and prematurely treat it as dead
|
||||
log debug ("Killing Zombie Node: %s", x)
|
||||
broadcast(x :: Nil, PapersPlease)
|
||||
remotes = remotes - x
|
||||
}
|
||||
|
||||
case rm @ RelayedMessage(_, _) => {
|
||||
log debug ("Relaying message: %s", rm)
|
||||
broadcast(rm)
|
||||
}
|
||||
|
||||
case m @ Message(src,msg) => {
|
||||
(Cluster.serializer in (msg, None)) match {
|
||||
|
||||
case PapersPlease => {
|
||||
log debug ("Asked for papers by %s", src)
|
||||
broadcast(src :: Nil, Papers(local.endpoints))
|
||||
|
||||
if (remotes.get(src).isEmpty) // If we were asked for papers from someone we don't know, ask them!
|
||||
broadcast(src :: Nil, PapersPlease)
|
||||
}
|
||||
|
||||
case Papers(x) => remotes = remotes + (src -> Node(x))
|
||||
|
||||
case RelayedMessage(c, m) => ActorRegistry.actorsFor(c).foreach(_ send m)
|
||||
|
||||
case unknown => log debug ("Unknown message: %s", unknown.toString)
|
||||
}
|
||||
}
|
||||
|
||||
case RegisterLocalNode(s) => {
|
||||
log debug ("RegisterLocalNode: %s", s)
|
||||
local = Node(local.endpoints + s)
|
||||
broadcast(Papers(local.endpoints))
|
||||
}
|
||||
|
||||
case DeregisterLocalNode(s) => {
|
||||
log debug ("DeregisterLocalNode: %s", s)
|
||||
local = Node(local.endpoints - s)
|
||||
broadcast(Papers(local.endpoints))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement this in a subclass to add node-to-node messaging
|
||||
*/
|
||||
protected def toOneNode(dest : ADDR_T, msg : Array[Byte]) : Unit
|
||||
|
||||
/**
|
||||
* Implement this in a subclass to add node-to-many-nodes messaging
|
||||
*/
|
||||
protected def toAllNodes(msg : Array[Byte]) : Unit
|
||||
|
||||
/**
|
||||
* Sends the specified message to the given recipients using the serializer
|
||||
* that's been set in the akka-conf
|
||||
*/
|
||||
protected def broadcast[T <: AnyRef](recipients: Iterable[ADDR_T], msg: T): Unit = {
|
||||
lazy val m = Cluster.serializer out msg
|
||||
for (r <- recipients) toOneNode(r,m)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the specified message toall other nodes using the serializer
|
||||
* that's been set in the akka-conf
|
||||
*/
|
||||
protected def broadcast[T <: AnyRef](msg: T): Unit =
|
||||
if (!remotes.isEmpty) toAllNodes(Cluster.serializer out msg)
|
||||
|
||||
/**
|
||||
* Applies the given PartialFunction to all known RemoteAddresses
|
||||
*/
|
||||
def lookup[T](handleRemoteAddress: PartialFunction[RemoteAddress, T]): Option[T] =
|
||||
remotes.values.toList.flatMap(_.endpoints).find(handleRemoteAddress isDefinedAt _).map(handleRemoteAddress)
|
||||
|
||||
/**
|
||||
* Applies the given function to all remote addresses known
|
||||
*/
|
||||
def foreach(f : (RemoteAddress) => Unit) : Unit = remotes.values.toList.flatMap(_.endpoints).foreach(f)
|
||||
|
||||
/**
|
||||
* Registers a local endpoint
|
||||
*/
|
||||
def registerLocalNode(hostname: String, port: Int): Unit =
|
||||
send(RegisterLocalNode(RemoteAddress(hostname, port)))
|
||||
|
||||
/**
|
||||
* Deregisters a local endpoint
|
||||
*/
|
||||
def deregisterLocalNode(hostname: String, port: Int): Unit =
|
||||
send(DeregisterLocalNode(RemoteAddress(hostname, port)))
|
||||
|
||||
/**
|
||||
* Broadcasts the specified message to all Actors of type Class on all known Nodes
|
||||
*/
|
||||
def relayMessage(to: Class[_ <: Actor], msg: AnyRef): Unit =
|
||||
send(RelayedMessage(to.getName, msg))
|
||||
}
|
||||
|
||||
/**
|
||||
* A singleton representing the Cluster.
|
||||
* <p/>
|
||||
* Loads a specified ClusterActor and delegates to that instance.
|
||||
*/
|
||||
object Cluster extends Cluster with Logging {
|
||||
private[remote] sealed trait ClusterMessage
|
||||
private[remote] case class Node(endpoints: List[RemoteAddress]) extends ClusterMessage
|
||||
private[remote] case class RelayedMessage(actorClassFQN: String, msg: AnyRef) extends ClusterMessage
|
||||
|
||||
private[remote] val clusterActor: Option[ClusterActor] = {
|
||||
val name = config.getString("akka.remote.cluster.actor","not defined")
|
||||
try {
|
||||
val a = Class.forName(name).newInstance.asInstanceOf[ClusterActor]
|
||||
a.start
|
||||
Some(a)
|
||||
}
|
||||
catch {
|
||||
case e => log.error(e,"Couldn't load Cluster provider: [%s]",name)
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
private[remote] val supervisor: Option[Supervisor] = if (clusterActor.isDefined) {
|
||||
val sup = SupervisorFactory(
|
||||
SupervisorConfig(
|
||||
RestartStrategy(OneForOne, 5, 1000, List(classOf[Exception])),
|
||||
Supervise(clusterActor.get, LifeCycle(Permanent)) :: Nil)
|
||||
).newInstance
|
||||
sup.start
|
||||
Some(sup)
|
||||
} else None
|
||||
@volatile private[remote] var clusterActor: Option[ClusterActor] = None
|
||||
@volatile private[remote] var supervisor: Option[Supervisor] = None
|
||||
|
||||
private[remote] lazy val serializer: Serializer = {
|
||||
val className = config.getString("akka.remote.cluster.serializer", Serializer.Java.getClass.getName)
|
||||
Class.forName(className).newInstance.asInstanceOf[Serializer]
|
||||
}
|
||||
|
||||
private[remote] def createClusterActor : Option[ClusterActor] = {
|
||||
val name = config.getString("akka.remote.cluster.actor")
|
||||
|
||||
try {
|
||||
name map { fqn =>
|
||||
val a = Class.forName(fqn).newInstance.asInstanceOf[ClusterActor]
|
||||
a.start
|
||||
a
|
||||
}
|
||||
}
|
||||
catch {
|
||||
case e => log.error(e,"Couldn't load Cluster provider: [%s]",name.getOrElse("Not specified")); None
|
||||
}
|
||||
}
|
||||
|
||||
private[remote] def createSupervisor(actor : ClusterActor) : Option[Supervisor] = {
|
||||
val sup = SupervisorFactory(
|
||||
SupervisorConfig(
|
||||
RestartStrategy(OneForOne, 5, 1000, List(classOf[Exception])),
|
||||
Supervise(actor, LifeCycle(Permanent)) :: Nil)
|
||||
).newInstance
|
||||
sup.start
|
||||
Some(sup)
|
||||
}
|
||||
|
||||
|
||||
def name = clusterActor.map(_.name).getOrElse("No cluster")
|
||||
|
||||
def lookup[T](pf: PartialFunction[RemoteAddress, T]): Option[T] = clusterActor.flatMap(_.lookup(pf))
|
||||
|
|
@ -82,6 +249,22 @@ object Cluster extends Cluster with Logging {
|
|||
def deregisterLocalNode(hostname: String, port: Int): Unit = clusterActor.foreach(_.deregisterLocalNode(hostname, port))
|
||||
|
||||
def relayMessage(to: Class[_ <: Actor], msg: AnyRef): Unit = clusterActor.foreach(_.relayMessage(to, msg))
|
||||
|
||||
def foreach(f : (RemoteAddress) => Unit) : Unit = clusterActor.foreach(_.foreach(f))
|
||||
|
||||
def shutdown = supervisor.foreach(_.stop)
|
||||
def start : Unit = synchronized {
|
||||
if(supervisor.isEmpty) {
|
||||
for(actor <- createClusterActor;
|
||||
sup <- createSupervisor(actor)) {
|
||||
clusterActor = Some(actor)
|
||||
supervisor = Some(sup)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def shutdown : Unit = synchronized {
|
||||
supervisor.foreach(_.stop)
|
||||
supervisor = None
|
||||
clusterActor = None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
package se.scalablesolutions.akka.remote
|
||||
|
||||
import scala.collection.mutable.HashMap
|
||||
|
||||
import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.{RemoteRequest, RemoteReply}
|
||||
import se.scalablesolutions.akka.actor.{Exit, Actor}
|
||||
import se.scalablesolutions.akka.dispatch.{DefaultCompletableFutureResult, CompletableFutureResult}
|
||||
|
|
@ -13,6 +11,7 @@ import se.scalablesolutions.akka.util.{UUID, Logging}
|
|||
import se.scalablesolutions.akka.Config.config
|
||||
|
||||
import org.jboss.netty.channel._
|
||||
import group.DefaultChannelGroup
|
||||
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory
|
||||
import org.jboss.netty.bootstrap.ClientBootstrap
|
||||
import org.jboss.netty.handler.codec.frame.{LengthFieldBasedFrameDecoder, LengthFieldPrepender}
|
||||
|
|
@ -25,12 +24,15 @@ import java.net.{SocketAddress, InetSocketAddress}
|
|||
import java.util.concurrent.{TimeUnit, Executors, ConcurrentMap, ConcurrentHashMap}
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
import scala.collection.mutable.{HashSet, HashMap}
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object RemoteRequestIdFactory {
|
||||
private val nodeId = UUID.newUuid
|
||||
private val id = new AtomicLong
|
||||
|
||||
def nextId: Long = id.getAndIncrement + nodeId
|
||||
}
|
||||
|
||||
|
|
@ -41,27 +43,121 @@ object RemoteClient extends Logging {
|
|||
val READ_TIMEOUT = config.getInt("akka.remote.client.read-timeout", 10000)
|
||||
val RECONNECT_DELAY = config.getInt("akka.remote.client.reconnect-delay", 5000)
|
||||
|
||||
private val clients = new HashMap[String, RemoteClient]
|
||||
private val remoteClients = new HashMap[String, RemoteClient]
|
||||
private val remoteActors = new HashMap[RemoteServer.Address, HashSet[String]]
|
||||
|
||||
// FIXME: simplify overloaded methods when we have Scala 2.8
|
||||
|
||||
def actorFor(className: String, hostname: String, port: Int): Actor =
|
||||
actorFor(className, className, 5000L, hostname, port)
|
||||
|
||||
def actorFor(actorId: String, className: String, hostname: String, port: Int): Actor =
|
||||
actorFor(actorId, className, 5000L, hostname, port)
|
||||
|
||||
def actorFor(className: String, timeout: Long, hostname: String, port: Int): Actor =
|
||||
actorFor(className, className, timeout, hostname, port)
|
||||
|
||||
def actorFor(actorId: String, className: String, timeout: Long, hostname: String, port: Int): Actor = {
|
||||
new Actor {
|
||||
start
|
||||
val remoteClient = RemoteClient.clientFor(hostname, port)
|
||||
|
||||
override def postMessageToMailbox(message: Any, sender: Option[Actor]): Unit = {
|
||||
val requestBuilder = RemoteRequest.newBuilder
|
||||
.setId(RemoteRequestIdFactory.nextId)
|
||||
.setTarget(className)
|
||||
.setTimeout(timeout)
|
||||
.setUuid(actorId)
|
||||
.setIsActor(true)
|
||||
.setIsOneWay(true)
|
||||
.setIsEscaped(false)
|
||||
if (sender.isDefined) {
|
||||
val s = sender.get
|
||||
requestBuilder.setSourceTarget(s.getClass.getName)
|
||||
requestBuilder.setSourceUuid(s.uuid)
|
||||
val (host, port) = s._replyToAddress.map(a => (a.getHostName, a.getPort)).getOrElse((Actor.HOSTNAME, Actor.PORT))
|
||||
requestBuilder.setSourceHostname(host)
|
||||
requestBuilder.setSourcePort(port)
|
||||
}
|
||||
RemoteProtocolBuilder.setMessage(message, requestBuilder)
|
||||
remoteClient.send(requestBuilder.build, None)
|
||||
}
|
||||
|
||||
override def postMessageToMailboxAndCreateFutureResultWithTimeout(
|
||||
message: Any,
|
||||
timeout: Long,
|
||||
senderFuture: Option[CompletableFutureResult]): CompletableFutureResult = {
|
||||
val requestBuilder = RemoteRequest.newBuilder
|
||||
.setId(RemoteRequestIdFactory.nextId)
|
||||
.setTarget(className)
|
||||
.setTimeout(timeout)
|
||||
.setUuid(actorId)
|
||||
.setIsActor(true)
|
||||
.setIsOneWay(false)
|
||||
.setIsEscaped(false)
|
||||
RemoteProtocolBuilder.setMessage(message, requestBuilder)
|
||||
val future = remoteClient.send(requestBuilder.build, senderFuture)
|
||||
if (future.isDefined) future.get
|
||||
else throw new IllegalStateException("Expected a future from remote call to actor " + toString)
|
||||
}
|
||||
|
||||
def receive = {case _ => {}}
|
||||
}
|
||||
}
|
||||
|
||||
def clientFor(hostname: String, port: Int): RemoteClient = clientFor(new InetSocketAddress(hostname, port))
|
||||
|
||||
def clientFor(address: InetSocketAddress): RemoteClient = synchronized {
|
||||
val hostname = address.getHostName
|
||||
val port = address.getPort
|
||||
val hash = hostname + ':' + port
|
||||
if (clients.contains(hash)) clients(hash)
|
||||
if (remoteClients.contains(hash)) remoteClients(hash)
|
||||
else {
|
||||
val client = new RemoteClient(hostname, port)
|
||||
client.connect
|
||||
clients += hash -> client
|
||||
remoteClients += hash -> client
|
||||
client
|
||||
}
|
||||
}
|
||||
|
||||
def shutdownClientFor(address: InetSocketAddress) = synchronized {
|
||||
val hostname = address.getHostName
|
||||
val port = address.getPort
|
||||
val hash = hostname + ':' + port
|
||||
if (remoteClients.contains(hash)) {
|
||||
val client = remoteClients(hash)
|
||||
client.shutdown
|
||||
remoteClients - hash
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean-up all open connections.
|
||||
*/
|
||||
def shutdownAll() = synchronized {
|
||||
clients.foreach({case (addr, client) => client.shutdown})
|
||||
clients.clear
|
||||
def shutdownAll = synchronized {
|
||||
remoteClients.foreach({case (addr, client) => client.shutdown})
|
||||
remoteClients.clear
|
||||
}
|
||||
|
||||
private[akka] def register(hostname: String, port: Int, uuid: String) = synchronized {
|
||||
actorsFor(RemoteServer.Address(hostname, port)) + uuid
|
||||
}
|
||||
|
||||
// TODO: add RemoteClient.unregister for ActiveObject, but first need a @shutdown callback
|
||||
private[akka] def unregister(hostname: String, port: Int, uuid: String) = synchronized {
|
||||
val set = actorsFor(RemoteServer.Address(hostname, port))
|
||||
set - uuid
|
||||
if (set.isEmpty) shutdownClientFor(new InetSocketAddress(hostname, port))
|
||||
}
|
||||
|
||||
private[akka] def actorsFor(remoteServerAddress: RemoteServer.Address): HashSet[String] = {
|
||||
val set = remoteActors.get(remoteServerAddress)
|
||||
if (set.isDefined && (set.get ne null)) set.get
|
||||
else {
|
||||
val remoteActorSet = new HashSet[String]
|
||||
remoteActors.put(remoteServerAddress, remoteActorSet)
|
||||
remoteActorSet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,9 +165,9 @@ object RemoteClient extends Logging {
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
class RemoteClient(hostname: String, port: Int) extends Logging {
|
||||
val name = "RemoteClient@" + hostname
|
||||
|
||||
@volatile private var isRunning = false
|
||||
val name = "RemoteClient@" + hostname + "::" + port
|
||||
|
||||
@volatile private[remote] var isRunning = false
|
||||
private val futures = new ConcurrentHashMap[Long, CompletableFutureResult]
|
||||
private val supervisors = new ConcurrentHashMap[String, Actor]
|
||||
|
||||
|
|
@ -80,6 +176,7 @@ class RemoteClient(hostname: String, port: Int) extends Logging {
|
|||
Executors.newCachedThreadPool)
|
||||
|
||||
private val bootstrap = new ClientBootstrap(channelFactory)
|
||||
private val openChannels = new DefaultChannelGroup(classOf[RemoteClient].getName);
|
||||
|
||||
private val timer = new HashedWheelTimer
|
||||
private val remoteAddress = new InetSocketAddress(hostname, port)
|
||||
|
|
@ -93,20 +190,22 @@ class RemoteClient(hostname: String, port: Int) extends Logging {
|
|||
if (!isRunning) {
|
||||
connection = bootstrap.connect(remoteAddress)
|
||||
log.info("Starting remote client connection to [%s:%s]", hostname, port)
|
||||
|
||||
// Wait until the connection attempt succeeds or fails.
|
||||
connection.awaitUninterruptibly
|
||||
if (!connection.isSuccess) log.error(connection.getCause, "Remote connection to [%s:%s] has failed", hostname, port)
|
||||
val channel = connection.awaitUninterruptibly.getChannel
|
||||
openChannels.add(channel)
|
||||
if (!connection.isSuccess) log.error(connection.getCause, "Remote client connection to [%s:%s] has failed", hostname, port)
|
||||
isRunning = true
|
||||
}
|
||||
}
|
||||
|
||||
def shutdown = synchronized {
|
||||
if (!isRunning) {
|
||||
connection.getChannel.getCloseFuture.awaitUninterruptibly
|
||||
channelFactory.releaseExternalResources
|
||||
if (isRunning) {
|
||||
isRunning = false
|
||||
openChannels.close.awaitUninterruptibly
|
||||
bootstrap.releaseExternalResources
|
||||
timer.stop
|
||||
log.info("%s has been shut down", name)
|
||||
}
|
||||
timer.stop
|
||||
}
|
||||
|
||||
def send(request: RemoteRequest, senderFuture: Option[CompletableFutureResult]): Option[CompletableFutureResult] = if (isRunning) {
|
||||
|
|
@ -116,11 +215,11 @@ class RemoteClient(hostname: String, port: Int) extends Logging {
|
|||
} else {
|
||||
futures.synchronized {
|
||||
val futureResult = if (senderFuture.isDefined) senderFuture.get
|
||||
else new DefaultCompletableFutureResult(request.getTimeout)
|
||||
else new DefaultCompletableFutureResult(request.getTimeout)
|
||||
futures.put(request.getId, futureResult)
|
||||
connection.getChannel.write(request)
|
||||
Some(futureResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else throw new IllegalStateException("Remote client is not running, make sure you have invoked 'RemoteClient.connect' before using it.")
|
||||
|
||||
|
|
@ -131,14 +230,14 @@ class RemoteClient(hostname: String, port: Int) extends Logging {
|
|||
def deregisterSupervisorForActor(actor: Actor) =
|
||||
if (!actor._supervisor.isDefined) throw new IllegalStateException("Can't unregister supervisor for " + actor + " since it is not under supervision")
|
||||
else supervisors.remove(actor._supervisor.get.uuid)
|
||||
|
||||
|
||||
def deregisterSupervisorWithUuid(uuid: String) = supervisors.remove(uuid)
|
||||
}
|
||||
|
||||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
class RemoteClientPipelineFactory(name: String,
|
||||
class RemoteClientPipelineFactory(name: String,
|
||||
futures: ConcurrentMap[Long, CompletableFutureResult],
|
||||
supervisors: ConcurrentMap[String, Actor],
|
||||
bootstrap: ClientBootstrap,
|
||||
|
|
@ -146,21 +245,21 @@ class RemoteClientPipelineFactory(name: String,
|
|||
timer: HashedWheelTimer,
|
||||
client: RemoteClient) extends ChannelPipelineFactory {
|
||||
def getPipeline: ChannelPipeline = {
|
||||
val timeout = new ReadTimeoutHandler(timer, RemoteClient.READ_TIMEOUT)
|
||||
val lenDec = new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4)
|
||||
val lenPrep = new LengthFieldPrepender(4)
|
||||
val protobufDec = new ProtobufDecoder(RemoteReply.getDefaultInstance)
|
||||
val protobufEnc = new ProtobufEncoder
|
||||
val timeout = new ReadTimeoutHandler(timer, RemoteClient.READ_TIMEOUT)
|
||||
val lenDec = new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4)
|
||||
val lenPrep = new LengthFieldPrepender(4)
|
||||
val protobufDec = new ProtobufDecoder(RemoteReply.getDefaultInstance)
|
||||
val protobufEnc = new ProtobufEncoder
|
||||
val zipCodec = RemoteServer.COMPRESSION_SCHEME match {
|
||||
case "zlib" => Some(Codec(new ZlibEncoder(RemoteServer.ZLIB_COMPRESSION_LEVEL), new ZlibDecoder))
|
||||
case "zlib" => Some(Codec(new ZlibEncoder(RemoteServer.ZLIB_COMPRESSION_LEVEL), new ZlibDecoder))
|
||||
//case "lzf" => Some(Codec(new LzfEncoder, new LzfDecoder))
|
||||
case _ => None
|
||||
}
|
||||
val remoteClient = new RemoteClientHandler(name, futures, supervisors, bootstrap, remoteAddress, timer, client)
|
||||
|
||||
val stages: Array[ChannelHandler] =
|
||||
zipCodec.map(codec => Array(timeout, codec.decoder, lenDec, protobufDec, codec.encoder, lenPrep, protobufEnc, remoteClient))
|
||||
.getOrElse(Array(timeout, lenDec, protobufDec, lenPrep, protobufEnc, remoteClient))
|
||||
val stages: Array[ChannelHandler] =
|
||||
zipCodec.map(codec => Array(timeout, codec.decoder, lenDec, protobufDec, codec.encoder, lenPrep, protobufEnc, remoteClient))
|
||||
.getOrElse(Array(timeout, lenDec, protobufDec, lenPrep, protobufEnc, remoteClient))
|
||||
new StaticChannelPipeline(stages: _*)
|
||||
}
|
||||
}
|
||||
|
|
@ -168,7 +267,7 @@ class RemoteClientPipelineFactory(name: String,
|
|||
/**
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
@ChannelPipelineCoverage { val value = "all" }
|
||||
@ChannelPipelineCoverage {val value = "all"}
|
||||
class RemoteClientHandler(val name: String,
|
||||
val futures: ConcurrentMap[Long, CompletableFutureResult],
|
||||
val supervisors: ConcurrentMap[String, Actor],
|
||||
|
|
@ -176,7 +275,7 @@ class RemoteClientHandler(val name: String,
|
|||
val remoteAddress: SocketAddress,
|
||||
val timer: HashedWheelTimer,
|
||||
val client: RemoteClient)
|
||||
extends SimpleChannelUpstreamHandler with Logging {
|
||||
extends SimpleChannelUpstreamHandler with Logging {
|
||||
import Actor.Sender.Self
|
||||
|
||||
override def handleUpstream(ctx: ChannelHandlerContext, event: ChannelEvent) = {
|
||||
|
|
@ -214,9 +313,9 @@ class RemoteClientHandler(val name: String,
|
|||
log.error("Unexpected exception in remote client handler: %s", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override def channelClosed(ctx: ChannelHandlerContext, event: ChannelStateEvent) = {
|
||||
override def channelClosed(ctx: ChannelHandlerContext, event: ChannelStateEvent) = if (client.isRunning) {
|
||||
timer.newTimeout(new TimerTask() {
|
||||
def run(timeout: Timeout) = {
|
||||
log.debug("Remote client reconnecting to [%s]", remoteAddress)
|
||||
|
|
@ -245,7 +344,7 @@ class RemoteClientHandler(val name: String,
|
|||
val exceptionType = Class.forName(exception.substring(0, exception.indexOf('$')))
|
||||
val exceptionMessage = exception.substring(exception.indexOf('$') + 1, exception.length)
|
||||
exceptionType
|
||||
.getConstructor(Array[Class[_]](classOf[String]): _*)
|
||||
.newInstance(exceptionMessage).asInstanceOf[Throwable]
|
||||
.getConstructor(Array[Class[_]](classOf[String]): _*)
|
||||
.newInstance(exceptionMessage).asInstanceOf[Throwable]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,11 @@ import org.jboss.netty.handler.codec.compression.{ZlibEncoder, ZlibDecoder}
|
|||
* <pre>
|
||||
* RemoteNode.start(hostname, port)
|
||||
* </pre>
|
||||
*
|
||||
* You can specify the class loader to use to load the remote actors.
|
||||
* <pre>
|
||||
* RemoteNode.start(hostname, port, classLoader)
|
||||
* </pre>
|
||||
*
|
||||
* If you need to create more than one, then you can use the RemoteServer:
|
||||
*
|
||||
|
|
@ -112,8 +117,6 @@ object RemoteServer {
|
|||
|
||||
private[remote] def unregister(hostname: String, port: Int) =
|
||||
remoteServers.remove(Address(hostname, port))
|
||||
|
||||
private[remote] def canShutDownCluster: Boolean = remoteServers.isEmpty
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -179,14 +182,30 @@ class RemoteServer extends Logging {
|
|||
}
|
||||
}
|
||||
|
||||
def shutdown = {
|
||||
def shutdown = if (isRunning) {
|
||||
RemoteServer.unregister(hostname, port)
|
||||
openChannels.disconnect
|
||||
openChannels.unbind
|
||||
openChannels.close.awaitUninterruptibly(1000)
|
||||
openChannels.close.awaitUninterruptibly
|
||||
bootstrap.releaseExternalResources
|
||||
Cluster.deregisterLocalNode(hostname, port)
|
||||
if (RemoteServer.canShutDownCluster) Cluster.shutdown
|
||||
}
|
||||
|
||||
// TODO: register active object in RemoteServer as well
|
||||
|
||||
/**
|
||||
* Register Remote Actor by the Actor's 'id' field.
|
||||
*/
|
||||
def register(actor: Actor) = if (isRunning) {
|
||||
log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, actor.id)
|
||||
RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(actor.id, actor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Remote Actor by a specific 'id' passed as argument.
|
||||
*/
|
||||
def register(id: String, actor: Actor) = if (isRunning) {
|
||||
log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, id)
|
||||
RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(id, actor)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -255,8 +274,7 @@ class RemoteServerHandler(
|
|||
|
||||
override def messageReceived(ctx: ChannelHandlerContext, event: MessageEvent) = {
|
||||
val message = event.getMessage
|
||||
if (message eq null) throw new IllegalStateException(
|
||||
"Message in remote MessageEvent is null: " + event)
|
||||
if (message eq null) throw new IllegalStateException("Message in remote MessageEvent is null: " + event)
|
||||
if (message.isInstanceOf[RemoteRequest]) {
|
||||
handleRemoteRequest(message.asInstanceOf[RemoteRequest], event.getChannel)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,14 @@ object Serializer {
|
|||
// FIXME set ClassLoader on SJSONSerializer.SJSON
|
||||
def in(bytes: Array[Byte], clazz: Option[Class[_]]): AnyRef = SJSONSerializer.SJSON.in(bytes)
|
||||
|
||||
def in(json: String): AnyRef = SJSONSerializer.SJSON.in(json)
|
||||
import scala.reflect.Manifest
|
||||
def in[T](json: String)(implicit m: Manifest[T]): AnyRef = {
|
||||
SJSONSerializer.SJSON.in(json)(m)
|
||||
}
|
||||
|
||||
def in[T](bytes: Array[Byte])(implicit m: Manifest[T]): AnyRef = {
|
||||
SJSONSerializer.SJSON.in(bytes)(m)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -323,12 +323,12 @@ private[collection] class FullNode[K, +V](shift: Int)(table: Array[Node[K, V]])
|
|||
val node = (table(i)(shift + 5, key, hash) = value)
|
||||
|
||||
if (node == table(i)) this else {
|
||||
val newTable = new Array[Node[K, A]](32)
|
||||
Array.copy(table, 0, newTable, 0, 32)
|
||||
|
||||
newTable(i) = node
|
||||
|
||||
new FullNode(shift)(newTable)
|
||||
val newTable = new Array[Node[K, A]](32)
|
||||
Array.copy(table, 0, newTable, 0, 32)
|
||||
|
||||
newTable(i) = node
|
||||
|
||||
new FullNode(shift)(newTable)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ import stm.Transaction
|
|||
*
|
||||
* scala> res0()
|
||||
* java.lang.RuntimeException: Lets see what happens here...
|
||||
* at ResultOrFailure.apply(RefExcept.scala:11)
|
||||
* at .<init>(<console>:6)
|
||||
* at .<clinit>(<console>)
|
||||
* at Re...
|
||||
* at ResultOrFailure.apply(RefExcept.scala:11)
|
||||
* at .<init>(<console>:6)
|
||||
* at .<clinit>(<console>)
|
||||
* at Re...
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
package se.scalablesolutions.akka.state
|
||||
|
||||
import se.scalablesolutions.akka.stm.Transaction.atomic
|
||||
import se.scalablesolutions.akka.stm.NoTransactionInScopeException
|
||||
import se.scalablesolutions.akka.collection._
|
||||
import se.scalablesolutions.akka.util.UUID
|
||||
|
||||
|
|
@ -72,45 +73,87 @@ object TransactionalRef {
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
class TransactionalRef[T] extends Transactional {
|
||||
implicit val txInitName = "TransactionalRef:Init"
|
||||
import org.multiverse.api.ThreadLocalTransaction._
|
||||
|
||||
implicit val txInitName = "TransactionalRef:Init"
|
||||
val uuid = UUID.newUuid.toString
|
||||
|
||||
private[this] val ref: Ref[T] = atomic { new Ref }
|
||||
|
||||
def swap(elem: T) = ref.set(elem)
|
||||
|
||||
def swap(elem: T) = {
|
||||
ensureIsInTransaction
|
||||
ref.set(elem)
|
||||
}
|
||||
|
||||
def get: Option[T] = {
|
||||
ensureIsInTransaction
|
||||
if (ref.isNull) None
|
||||
else Some(ref.get)
|
||||
}
|
||||
|
||||
def getOrWait: T = ref.getOrAwait
|
||||
def getOrWait: T = {
|
||||
ensureIsInTransaction
|
||||
ref.getOrAwait
|
||||
}
|
||||
|
||||
def getOrElse(default: => T): T = {
|
||||
ensureIsInTransaction
|
||||
if (ref.isNull) default
|
||||
else ref.get
|
||||
}
|
||||
|
||||
def isDefined: Boolean = !ref.isNull
|
||||
def isDefined: Boolean = {
|
||||
ensureIsInTransaction
|
||||
!ref.isNull
|
||||
}
|
||||
|
||||
def isEmpty: Boolean = ref.isNull
|
||||
def isEmpty: Boolean = {
|
||||
ensureIsInTransaction
|
||||
ref.isNull
|
||||
}
|
||||
|
||||
def map[B](f: T => B): Option[B] = if (isEmpty) None else Some(f(ref.get))
|
||||
def map[B](f: T => B): Option[B] = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty) None else Some(f(ref.get))
|
||||
}
|
||||
|
||||
def flatMap[B](f: T => Option[B]): Option[B] = if (isEmpty) None else f(ref.get)
|
||||
def flatMap[B](f: T => Option[B]): Option[B] = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty) None else f(ref.get)
|
||||
}
|
||||
|
||||
def filter(p: T => Boolean): Option[T] = if (isEmpty || p(ref.get)) Some(ref.get) else None
|
||||
def filter(p: T => Boolean): Option[T] = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty || p(ref.get)) Some(ref.get) else None
|
||||
}
|
||||
|
||||
def foreach(f: T => Unit) { if (!isEmpty) f(ref.get) }
|
||||
def foreach(f: T => Unit) {
|
||||
ensureIsInTransaction
|
||||
if (!isEmpty) f(ref.get)
|
||||
}
|
||||
|
||||
def elements: Iterator[T] = if (isEmpty) Iterator.empty else Iterator.fromValues(ref.get)
|
||||
def elements: Iterator[T] = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty) Iterator.empty else Iterator.fromValues(ref.get)
|
||||
}
|
||||
|
||||
def toList: List[T] = if (isEmpty) List() else List(ref.get)
|
||||
def toList: List[T] = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty) List() else List(ref.get)
|
||||
}
|
||||
|
||||
def toRight[X](left: => X) = if (isEmpty) Left(left) else Right(ref.get)
|
||||
def toRight[X](left: => X) = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty) Left(left) else Right(ref.get)
|
||||
}
|
||||
|
||||
def toLeft[X](right: => X) = if (isEmpty) Right(right) else Left(ref.get)
|
||||
def toLeft[X](right: => X) = {
|
||||
ensureIsInTransaction
|
||||
if (isEmpty) Right(right) else Left(ref.get)
|
||||
}
|
||||
|
||||
private def ensureIsInTransaction =
|
||||
if (getThreadLocalTransaction eq null) throw new NoTransactionInScopeException
|
||||
}
|
||||
|
||||
object TransactionalMap {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import junit.framework.Test
|
|||
import junit.framework.TestCase
|
||||
import junit.framework.TestSuite
|
||||
|
||||
import se.scalablesolutions.akka.actor.{RemoteActorTest, InMemoryActorTest, ThreadBasedActorTest, SupervisorTest, RemoteSupervisorTest, SchedulerTest}
|
||||
import se.scalablesolutions.akka.actor.{ClientInitiatedRemoteActorTest, InMemoryActorTest, ThreadBasedActorTest, SupervisorTest, RemoteSupervisorTest, SchedulerTest}
|
||||
|
||||
object AllTest extends TestCase {
|
||||
def suite(): Test = {
|
||||
|
|
@ -16,7 +16,7 @@ object AllTest extends TestCase {
|
|||
suite.addTestSuite(classOf[ThreadBasedActorTest])
|
||||
suite.addTestSuite(classOf[ReactorBasedSingleThreadEventDrivenDispatcherTest])
|
||||
suite.addTestSuite(classOf[ReactorBasedThreadPoolEventDrivenDispatcherTest])
|
||||
suite.addTestSuite(classOf[RemoteActorTest])
|
||||
suite.addTestSuite(classOf[ClientInitiatedRemoteActorTest])
|
||||
suite.addTestSuite(classOf[InMemoryActorTest])
|
||||
suite.addTestSuite(classOf[SchedulerTest])
|
||||
//suite.addTestSuite(classOf[TransactionClasherTest])
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class RemoteActorSpecActorAsyncSender extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
class RemoteActorTest extends JUnitSuite {
|
||||
class ClientInitiatedRemoteActorTest extends JUnitSuite {
|
||||
import Actor.Sender.Self
|
||||
|
||||
akka.Config.config
|
||||
|
|
@ -108,7 +108,7 @@ class RemoteActorTest extends JUnitSuite {
|
|||
actor.start
|
||||
|
||||
val sender = new RemoteActorSpecActorAsyncSender
|
||||
sender.setContactAddress(HOSTNAME, PORT1)
|
||||
sender.setReplyToAddress(HOSTNAME, PORT1)
|
||||
sender.start
|
||||
sender.send(actor)
|
||||
Thread.sleep(1000)
|
||||
|
|
@ -116,26 +116,6 @@ class RemoteActorTest extends JUnitSuite {
|
|||
actor.stop
|
||||
}
|
||||
|
||||
/*
|
||||
This test does not throw an exception since the
|
||||
_contactAddress is always defined via the
|
||||
global configuration if not set explicitly.
|
||||
|
||||
@Test
|
||||
def shouldSendRemoteReplyException = {
|
||||
implicit val timeout = 500000000L
|
||||
val actor = new RemoteActorSpecActorBidirectional
|
||||
actor.makeRemote(HOSTNAME, PORT1)
|
||||
actor.start
|
||||
|
||||
val sender = new RemoteActorSpecActorAsyncSender
|
||||
sender.start
|
||||
sender.send(actor)
|
||||
Thread.sleep(500)
|
||||
assert("exception" === Global.remoteReply)
|
||||
actor.stop
|
||||
}
|
||||
*/
|
||||
@Test
|
||||
def shouldSendReceiveException = {
|
||||
implicit val timeout = 500000000L
|
||||
30
akka-core/src/test/scala/RemoteClientShutdownTest.scala
Normal file
30
akka-core/src/test/scala/RemoteClientShutdownTest.scala
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import se.scalablesolutions.akka.remote.RemoteNode
|
||||
import se.scalablesolutions.akka.actor._
|
||||
import Actor.Sender.Self
|
||||
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
import org.junit.Test
|
||||
|
||||
class RemoteClientShutdownTest extends JUnitSuite {
|
||||
@Test def shouldShutdownRemoteClient = {
|
||||
RemoteNode.start("localhost", 9999)
|
||||
|
||||
var remote = new TravelingActor
|
||||
remote.start
|
||||
remote ! "sending a remote message"
|
||||
remote.stop
|
||||
|
||||
Thread.sleep(1000)
|
||||
RemoteNode.shutdown
|
||||
println("======= REMOTE CLIENT SHUT DOWN FINE =======")
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
|
||||
class TravelingActor extends RemoteActor("localhost", 9999) {
|
||||
def receive = {
|
||||
case _ => log.info("message received")
|
||||
}
|
||||
}
|
||||
40
akka-core/src/test/scala/SerializerTest.scala
Normal file
40
akka-core/src/test/scala/SerializerTest.scala
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package se.scalablesolutions.akka.serialization
|
||||
|
||||
import junit.framework.TestCase
|
||||
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
import org.junit.{Test, Before, After}
|
||||
|
||||
import scala.reflect.BeanInfo
|
||||
@BeanInfo
|
||||
case class Foo(foo: String) {
|
||||
def this() = this(null)
|
||||
}
|
||||
|
||||
@BeanInfo
|
||||
case class MyMessage(val id: String, val value: Tuple2[String, Int]) {
|
||||
private def this() = this(null, null)
|
||||
}
|
||||
|
||||
|
||||
class SerializerTest extends JUnitSuite {
|
||||
@Test
|
||||
def shouldSerializeString = {
|
||||
val f = Foo("debasish")
|
||||
val json = Serializer.ScalaJSON.out(f)
|
||||
assert(new String(json) == """{"foo":"debasish"}""")
|
||||
val fo = Serializer.ScalaJSON.in[Foo](new String(json)).asInstanceOf[Foo]
|
||||
assert(fo == f)
|
||||
}
|
||||
|
||||
@Test
|
||||
def shouldSerializeTuple2 = {
|
||||
val message = MyMessage("id", ("hello", 34))
|
||||
val json = Serializer.ScalaJSON.out(message)
|
||||
assert(new String(json) == """{"id":"id","value":{"hello":34}}""")
|
||||
val f = Serializer.ScalaJSON.in[MyMessage](new String(json)).asInstanceOf[MyMessage]
|
||||
assert(f == message)
|
||||
val g = Serializer.ScalaJSON.in[MyMessage](json).asInstanceOf[MyMessage]
|
||||
assert(f == message)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package sample
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
import se.scalablesolutions.akka.remote.{RemoteClient, RemoteNode}
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
|
||||
class HelloWorldActor extends Actor {
|
||||
start
|
||||
def receive = {
|
||||
case "Hello" => reply("World")
|
||||
}
|
||||
}
|
||||
|
||||
object ServerInitiatedRemoteActorServer {
|
||||
|
||||
def run = {
|
||||
RemoteNode.start("localhost", 9999)
|
||||
RemoteNode.register("hello-service", new HelloWorldActor)
|
||||
}
|
||||
|
||||
def main(args: Array[String]) = run
|
||||
}
|
||||
|
||||
object ServerInitiatedRemoteActorClient extends Logging {
|
||||
|
||||
def run = {
|
||||
val actor = RemoteClient.actorFor("hello-service", "localhost", 9999)
|
||||
val result = actor !! "Hello"
|
||||
log.info("Result from Remote Actor: %s", result)
|
||||
}
|
||||
|
||||
def main(args: Array[String]) = run
|
||||
}
|
||||
|
||||
145
akka-core/src/test/scala/ServerInitiatedRemoteActorTest.scala
Normal file
145
akka-core/src/test/scala/ServerInitiatedRemoteActorTest.scala
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
import org.junit.{Test, Before, After}
|
||||
|
||||
import se.scalablesolutions.akka.remote.{RemoteServer, RemoteClient}
|
||||
import se.scalablesolutions.akka.dispatch.Dispatchers
|
||||
|
||||
object ServerInitiatedRemoteActorTest {
|
||||
val HOSTNAME = "localhost"
|
||||
val PORT = 9990
|
||||
var server: RemoteServer = null
|
||||
|
||||
object Global {
|
||||
var oneWay = "nada"
|
||||
var remoteReply = "nada"
|
||||
}
|
||||
|
||||
class RemoteActorSpecActorUnidirectional extends Actor {
|
||||
dispatcher = Dispatchers.newThreadBasedDispatcher(this)
|
||||
start
|
||||
|
||||
def receive = {
|
||||
case "OneWay" =>
|
||||
println("================== ONEWAY")
|
||||
Global.oneWay = "received"
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteActorSpecActorBidirectional extends Actor {
|
||||
start
|
||||
def receive = {
|
||||
case "Hello" =>
|
||||
reply("World")
|
||||
case "Failure" =>
|
||||
throw new RuntimeException("expected")
|
||||
}
|
||||
}
|
||||
|
||||
case class Send(actor: Actor)
|
||||
|
||||
class RemoteActorSpecActorAsyncSender extends Actor {
|
||||
start
|
||||
def receive = {
|
||||
case Send(actor: Actor) =>
|
||||
actor ! "Hello"
|
||||
case "World" =>
|
||||
Global.remoteReply = "replied"
|
||||
}
|
||||
|
||||
def send(actor: Actor) {
|
||||
this ! Send(actor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ServerInitiatedRemoteActorTest extends JUnitSuite {
|
||||
import ServerInitiatedRemoteActorTest._
|
||||
|
||||
import Actor.Sender.Self
|
||||
akka.Config.config
|
||||
|
||||
private val unit = TimeUnit.MILLISECONDS
|
||||
|
||||
@Before
|
||||
def init() {
|
||||
server = new RemoteServer()
|
||||
|
||||
server.start(HOSTNAME, PORT)
|
||||
|
||||
server.register(new RemoteActorSpecActorUnidirectional)
|
||||
server.register(new RemoteActorSpecActorBidirectional)
|
||||
server.register(new RemoteActorSpecActorAsyncSender)
|
||||
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
|
||||
// make sure the servers shutdown cleanly after the test has finished
|
||||
@After
|
||||
def finished() {
|
||||
server.shutdown
|
||||
RemoteClient.shutdownAll
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
|
||||
@Test
|
||||
def shouldSendOneWay = {
|
||||
val actor = RemoteClient.actorFor(
|
||||
"se.scalablesolutions.akka.actor.ServerInitiatedRemoteActorTest$RemoteActorSpecActorUnidirectional",
|
||||
5000L,
|
||||
HOSTNAME, PORT)
|
||||
val result = actor ! "OneWay"
|
||||
Thread.sleep(1000)
|
||||
assert("received" === Global.oneWay)
|
||||
actor.stop
|
||||
}
|
||||
|
||||
@Test
|
||||
def shouldSendReplyAsync = {
|
||||
val actor = RemoteClient.actorFor(
|
||||
"se.scalablesolutions.akka.actor.ServerInitiatedRemoteActorTest$RemoteActorSpecActorBidirectional",
|
||||
5000L,
|
||||
HOSTNAME, PORT)
|
||||
val result = actor !! "Hello"
|
||||
assert("World" === result.get.asInstanceOf[String])
|
||||
actor.stop
|
||||
}
|
||||
|
||||
@Test
|
||||
def shouldSendRemoteReply = {
|
||||
implicit val timeout = 500000000L
|
||||
val actor = RemoteClient.actorFor(
|
||||
"se.scalablesolutions.akka.actor.ServerInitiatedRemoteActorTest$RemoteActorSpecActorBidirectional",
|
||||
timeout,
|
||||
HOSTNAME, PORT)
|
||||
|
||||
val sender = new RemoteActorSpecActorAsyncSender
|
||||
sender.setReplyToAddress(HOSTNAME, PORT)
|
||||
sender.start
|
||||
sender.send(actor)
|
||||
Thread.sleep(1000)
|
||||
assert("replied" === Global.remoteReply)
|
||||
actor.stop
|
||||
}
|
||||
|
||||
@Test
|
||||
def shouldSendReceiveException = {
|
||||
implicit val timeout = 500000000L
|
||||
val actor = RemoteClient.actorFor(
|
||||
"se.scalablesolutions.akka.actor.ServerInitiatedRemoteActorTest$RemoteActorSpecActorBidirectional",
|
||||
timeout,
|
||||
HOSTNAME, PORT)
|
||||
try {
|
||||
actor !! "Failure"
|
||||
fail("Should have thrown an exception")
|
||||
} catch {
|
||||
case e =>
|
||||
assert("expected" === e.getMessage())
|
||||
}
|
||||
actor.stop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
|
|
|||
0
akka-fun-test-java/testng.xml
Executable file → Normal file
0
akka-fun-test-java/testng.xml
Executable file → Normal file
7
akka-kernel/pom.xml
Executable file → Normal file
7
akka-kernel/pom.xml
Executable file → Normal file
|
|
@ -11,7 +11,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- akka deps -->
|
||||
|
|
@ -56,6 +56,11 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
||||
*/
|
||||
|
||||
package se.scalablesolutions.akka.comet
|
||||
package se.scalablesolutions.akka
|
||||
|
||||
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}
|
||||
|
||||
|
|
@ -54,17 +55,17 @@ trait BootableCometActorService extends Bootable with Logging {
|
|||
t.setAdapter(adapter)
|
||||
t.setEnableAsyncExecution(true)
|
||||
t.setAsyncHandler(ah)
|
||||
t.listen
|
||||
t }
|
||||
t.listen
|
||||
t }
|
||||
|
||||
log.info("REST service started successfully. Listening to port [%s]", REST_PORT)
|
||||
}
|
||||
}
|
||||
|
||||
abstract override def onUnload = {
|
||||
super.onUnload
|
||||
|
||||
if (jerseySelectorThread.isDefined) {
|
||||
super.onUnload
|
||||
|
||||
if (jerseySelectorThread.isDefined) {
|
||||
log.info("Shutting down REST service (Jersey)")
|
||||
jerseySelectorThread.get.stopEndpoint
|
||||
}
|
||||
|
|
@ -4,10 +4,9 @@
|
|||
|
||||
package se.scalablesolutions.akka
|
||||
|
||||
import se.scalablesolutions.akka.comet.BootableCometActorService
|
||||
import se.scalablesolutions.akka.remote.BootableRemoteActorService
|
||||
import se.scalablesolutions.akka.actor.BootableActorLoaderService
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import se.scalablesolutions.akka.util.{Logging,Bootable}
|
||||
|
||||
import javax.servlet.{ServletContextListener, ServletContextEvent}
|
||||
|
||||
|
|
@ -24,29 +23,30 @@ object Kernel extends Logging {
|
|||
@volatile private var hasBooted = false
|
||||
|
||||
private val startTime = System.currentTimeMillis
|
||||
|
||||
/**
|
||||
* Holds a reference to the services that has been booted
|
||||
*/
|
||||
@volatile private var bundles : Option[Bootable] = None
|
||||
|
||||
/**
|
||||
* Bundles is what modules are to be loaded with the Kernel, this uses Jonas' AOP style mixin pattern.
|
||||
* Boots up the Kernel with default bootables
|
||||
*/
|
||||
object Bundles extends BootableActorLoaderService with BootableRemoteActorService with BootableCometActorService
|
||||
|
||||
/**
|
||||
* Boots up the Kernel.
|
||||
*/
|
||||
def boot: Unit = boot(true)
|
||||
def boot : Unit = boot(true, new BootableActorLoaderService with BootableRemoteActorService with BootableCometActorService)
|
||||
|
||||
/**
|
||||
* Boots up the Kernel.
|
||||
* If you pass in false as parameter then the Akka banner is not printed out.
|
||||
*/
|
||||
def boot(withBanner: Boolean): Unit = synchronized {
|
||||
def boot(withBanner: Boolean, b : Bootable): Unit = synchronized {
|
||||
if (!hasBooted) {
|
||||
if (withBanner) printBanner
|
||||
log.info("Starting Akka...")
|
||||
Bundles.onLoad
|
||||
b.onLoad
|
||||
Thread.currentThread.setContextClassLoader(getClass.getClassLoader)
|
||||
log.info("Akka started successfully")
|
||||
hasBooted = true
|
||||
bundles = Some(b)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,12 +56,17 @@ object Kernel extends Logging {
|
|||
def shutdown = synchronized {
|
||||
if (hasBooted) {
|
||||
log.info("Shutting down Akka...")
|
||||
Bundles.onUnload
|
||||
bundles.foreach(_.onUnload)
|
||||
bundles = None
|
||||
log.info("Akka succesfully shut down")
|
||||
}
|
||||
}
|
||||
|
||||
def startRemoteService = Bundles.startRemoteService
|
||||
//For testing purposes only
|
||||
def startRemoteService : Unit = bundles.foreach( _ match {
|
||||
case x : BootableRemoteActorService => x.startRemoteService
|
||||
case _ =>
|
||||
})
|
||||
|
||||
private def printBanner = {
|
||||
log.info(
|
||||
|
|
@ -85,5 +90,5 @@ object Kernel extends Logging {
|
|||
|
||||
class Kernel extends ServletContextListener {
|
||||
def contextDestroyed(e : ServletContextEvent) : Unit = Kernel.shutdown
|
||||
def contextInitialized(e : ServletContextEvent) : Unit = Kernel.boot
|
||||
def contextInitialized(e : ServletContextEvent) : Unit = Kernel.boot(true,new BootableActorLoaderService with BootableRemoteActorService)
|
||||
}
|
||||
39
akka-patterns/pom.xml
Normal file
39
akka-patterns/pom.xml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<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>
|
||||
146
akka-patterns/src/main/scala/Agent.scala
Normal file
146
akka-patterns/src/main/scala/Agent.scala
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
// 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)) => atomic { updateData(fun(value.getOrWait)) }
|
||||
|
||||
case ValueHolder(x: T) => updateData(x)
|
||||
|
||||
case ProcedureHolder(fun: (T => Unit)) => atomic { 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 = atomic { 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)
|
||||
}
|
||||
}
|
||||
101
akka-patterns/src/main/scala/Patterns.scala
Normal file
101
akka-patterns/src/main/scala/Patterns.scala
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
package se.scalablesolutions.akka.actor.patterns
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
|
||||
object Patterns {
|
||||
type PF[A,B] = PartialFunction[A,B]
|
||||
|
||||
/**
|
||||
* Creates a new PartialFunction whose isDefinedAt is a combination
|
||||
* of the two parameters, and whose apply is first to call filter.apply and then filtered.apply
|
||||
*/
|
||||
def filter[A,B](filter : PF[A,Unit],filtered : PF[A,B]) : PF[A,B] = {
|
||||
case a : A if filtered.isDefinedAt(a) && filter.isDefinedAt(a) =>
|
||||
filter(a)
|
||||
filtered(a)
|
||||
}
|
||||
|
||||
/**
|
||||
* Interceptor is a filter(x,y) where x.isDefinedAt is considered to be always true
|
||||
*/
|
||||
def intercept[A,B](interceptor : (A) => Unit, interceptee : PF[A,B]) : PF[A,B] = filter(
|
||||
{ case a if a.isInstanceOf[A] => interceptor(a) },
|
||||
interceptee
|
||||
)
|
||||
|
||||
//FIXME 2.8, use default params with CyclicIterator
|
||||
def loadBalancerActor(actors : => InfiniteIterator[Actor]) : Actor = new Actor with LoadBalancer {
|
||||
val seq = actors
|
||||
}
|
||||
|
||||
//FIXME 2.8, use default params with CyclicIterator
|
||||
/*def loadBalancerActor(actors : () => List[Actor]) : Actor = loadBalancerActor(
|
||||
new CyclicIterator(actors())
|
||||
) */
|
||||
|
||||
def dispatcherActor(routing : PF[Any,Actor], msgTransformer : (Any) => Any) : Actor = new Actor with Dispatcher {
|
||||
override def transform(msg : Any) = msgTransformer(msg)
|
||||
def routes = routing
|
||||
}
|
||||
|
||||
def dispatcherActor(routing : PF[Any,Actor]) : Actor = new Actor with Dispatcher {
|
||||
def routes = routing
|
||||
}
|
||||
|
||||
def loggerActor(actorToLog : Actor, logger : (Any) => Unit) : Actor = dispatcherActor (
|
||||
{ case _ => actorToLog },
|
||||
logger
|
||||
)
|
||||
}
|
||||
|
||||
trait Dispatcher { self : Actor =>
|
||||
|
||||
protected def transform(msg : Any) : Any = msg
|
||||
protected def routes : PartialFunction[Any,Actor]
|
||||
|
||||
protected def dispatch : PartialFunction[Any,Unit] = {
|
||||
case a if routes.isDefinedAt(a) => {
|
||||
if(self.sender.isDefined)
|
||||
routes(a) forward transform(a)
|
||||
else
|
||||
routes(a) send transform(a)
|
||||
}
|
||||
}
|
||||
|
||||
def receive = dispatch
|
||||
}
|
||||
|
||||
trait LoadBalancer extends Dispatcher { self : Actor =>
|
||||
protected def seq : InfiniteIterator[Actor]
|
||||
|
||||
protected def routes = { case x if seq.hasNext => seq.next }
|
||||
}
|
||||
|
||||
trait InfiniteIterator[T] extends Iterator[T]
|
||||
|
||||
class CyclicIterator[T](items : List[T]) extends InfiniteIterator[T] {
|
||||
@volatile private[this] var current : List[T] = items
|
||||
def hasNext = items != Nil
|
||||
def next = {
|
||||
val nc = if(current == Nil) items else current
|
||||
current = nc.tail
|
||||
nc.head
|
||||
}
|
||||
}
|
||||
|
||||
//Agent
|
||||
/*
|
||||
val a = agent(startValue)
|
||||
a.set(_ + 5)
|
||||
a.get
|
||||
a.foreach println(_)
|
||||
*/
|
||||
object Agent {
|
||||
sealed trait AgentMessage
|
||||
case class FunMessage[T](f : (T) => T) extends AgentMessage
|
||||
case class ProcMessage[T](f : (T) => Unit) extends AgentMessage
|
||||
case class ValMessage[T](t : T) extends AgentMessage
|
||||
}
|
||||
sealed private[akka] class Agent[T] {
|
||||
|
||||
}
|
||||
87
akka-patterns/src/test/scala/ActorPatternsTest.scala
Normal file
87
akka-patterns/src/test/scala/ActorPatternsTest.scala
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
package se.scalablesolutions.akka.actor
|
||||
|
||||
|
||||
import config.ScalaConfig._
|
||||
|
||||
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
|
||||
import org.junit.{Before, After, Test}
|
||||
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 = {
|
||||
val (testMsg1,testMsg2,testMsg3,testMsg4) = ("test1","test2","test3","test4")
|
||||
|
||||
var targetOk = 0
|
||||
val t1 = actor() receive {
|
||||
case `testMsg1` => targetOk += 2
|
||||
case `testMsg2` => targetOk += 4
|
||||
}
|
||||
|
||||
val t2 = actor() receive {
|
||||
case `testMsg3` => targetOk += 8
|
||||
}
|
||||
|
||||
val d = dispatcherActor {
|
||||
case `testMsg1`|`testMsg2` => t1
|
||||
case `testMsg3` => t2
|
||||
}
|
||||
|
||||
handle(d,t1,t2){
|
||||
d ! testMsg1
|
||||
d ! testMsg2
|
||||
d ! testMsg3
|
||||
Thread.sleep(1000)
|
||||
targetOk must be(14)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@Test def testLogger = verify(new TestActor {
|
||||
def test = {
|
||||
val msgs = new HashSet[Any]
|
||||
val t1 = actor() receive {
|
||||
case _ =>
|
||||
}
|
||||
val l = loggerActor(t1,(x) => msgs += x)
|
||||
handle(t1,l) {
|
||||
val t1 : Any = "foo"
|
||||
val t2 : Any = "bar"
|
||||
l ! t1
|
||||
l ! t2
|
||||
Thread.sleep(1000)
|
||||
msgs must ( have size (2) and contain (t1) and contain (t2) )
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
trait ActorTestUtil {
|
||||
|
||||
def handle[T](actors : Actor*)(test : => T) : T = {
|
||||
for(a <- actors) a.start
|
||||
try {
|
||||
test
|
||||
}
|
||||
finally {
|
||||
for(a <- actors) a.stop
|
||||
}
|
||||
}
|
||||
|
||||
def verify(actor : TestActor) : Unit = handle(actor) {
|
||||
actor.test
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TestActor extends Actor with ActorTestUtil {
|
||||
def test : Unit
|
||||
def receive = { case _ => }
|
||||
}
|
||||
24
akka-patterns/src/test/scala/AgentTest.scala
Normal file
24
akka-patterns/src/test/scala/AgentTest.scala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package se.scalablesolutions.akka.actor
|
||||
|
||||
import org.scalatest.Suite
|
||||
import se.scalablesolutions.akka.util.Logging
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
import org.scalatest.matchers.MustMatchers
|
||||
import org.junit.{Test}
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class AgentTest extends junit.framework.TestCase with Suite with MustMatchers with ActorTestUtil with Logging {
|
||||
@Test def testAgent = verify(new TestActor {
|
||||
def test = {
|
||||
val t = Agent(5)
|
||||
handle(t){
|
||||
t.update( _ + 1 )
|
||||
t.update( _ * 2 )
|
||||
|
||||
val r = t()
|
||||
r must be (12)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.cassandra</groupId>
|
||||
<artifactId>cassandra</artifactId>
|
||||
<version>0.4.1</version>
|
||||
<version>0.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-persistence-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ case class Credit(accountNo: String, amount: BigInt)
|
|||
case object LogSize
|
||||
|
||||
class AccountActor extends Transactor {
|
||||
private val accountState = RedisStorage.newMap
|
||||
private val txnLog = RedisStorage.newVector
|
||||
private lazy val accountState = RedisStorage.newMap
|
||||
private lazy val txnLog = RedisStorage.newVector
|
||||
|
||||
def receive = {
|
||||
// check balance
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ case class MNDQ(accountNos: List[String], noOfDQs: Int, failer: Actor)
|
|||
case class SZ
|
||||
|
||||
class QueueActor extends Transactor {
|
||||
private val accounts = RedisStorage.newQueue
|
||||
private lazy val accounts = RedisStorage.newQueue
|
||||
|
||||
def receive = {
|
||||
// enqueue
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<!-- Core deps -->
|
||||
|
|
@ -27,11 +27,11 @@
|
|||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<version>1.1.5-ea-20100104</version>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
|
|
|
|||
48
akka-samples/akka-sample-chat/Buildfile
Normal file
48
akka-samples/akka-sample-chat/Buildfile
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
require 'buildr/scala'
|
||||
|
||||
VERSION_NUMBER = "0.6"
|
||||
GROUP = "se.scalablesolutions.akka"
|
||||
|
||||
repositories.remote << "http://www.ibiblio.org/maven2/"
|
||||
repositories.remote << "http://www.lag.net/repo"
|
||||
repositories.remote << "http://multiverse.googlecode.com/svn/maven-repository/releases"
|
||||
|
||||
AKKA = group('akka-core', 'akka-comet', 'akka-util','akka-kernel', 'akka-rest', 'akka-util-java',
|
||||
'akka-security','akka-persistence-common', 'akka-persistence-redis',
|
||||
'akka-amqp',
|
||||
:under=> 'se.scalablesolutions.akka',
|
||||
:version => '0.6')
|
||||
ASPECTJ = "org.codehaus.aspectwerkz:aspectwerkz-nodeps-jdk5:jar:2.1"
|
||||
SBINARY = "sbinary:sbinary:jar:0.3"
|
||||
COMMONS_IO = "commons-io:commons-io:jar:1.4"
|
||||
CONFIGGY = "net.lag:configgy:jar:1.4.7"
|
||||
JACKSON = group('jackson-core-asl', 'jackson-mapper-asl',
|
||||
:under=> 'org.codehaus.jackson',
|
||||
:version => '1.2.1')
|
||||
MULTIVERSE = "org.multiverse:multiverse-alpha:jar:jar-with-dependencies:0.3"
|
||||
NETTY = "org.jboss.netty:netty:jar:3.2.0.ALPHA2"
|
||||
PROTOBUF = "com.google.protobuf:protobuf-java:jar:2.2.0"
|
||||
REDIS = "com.redis:redisclient:jar:1.0.1"
|
||||
SJSON = "sjson.json:sjson:jar:0.3"
|
||||
|
||||
Project.local_task "run"
|
||||
|
||||
desc "Akka Chat Sample Module"
|
||||
define "akka-sample-chat" do
|
||||
project.version = VERSION_NUMBER
|
||||
project.group = GROUP
|
||||
|
||||
compile.with AKKA, CONFIGGY
|
||||
|
||||
p artifact(MULTIVERSE).to_s
|
||||
|
||||
package(:jar)
|
||||
|
||||
task "run" do
|
||||
Java.java "scala.tools.nsc.MainGenericRunner",
|
||||
:classpath => [ compile.dependencies, compile.target,
|
||||
ASPECTJ, COMMONS_IO, JACKSON, NETTY, MULTIVERSE, PROTOBUF, REDIS,
|
||||
SBINARY, SJSON],
|
||||
:java_args => ["-server"]
|
||||
end
|
||||
end
|
||||
|
|
@ -12,14 +12,14 @@ Then to run the sample:
|
|||
|
||||
1. Set ‘AKKA_HOME’ environment variable to the root of the Akka distribution.
|
||||
2. Open up a shell and step into the Akka distribution root folder.
|
||||
3. Build Akka by invoking ‘mvn install -Dmaven.test.skip=true’. This will also bulid the sample application and deploy it to the ‘$AKKA_HOME/deploy’ directory.
|
||||
3. Build Akka by invoking ‘mvn install -Dmaven.test.skip=true’. This will also build the sample application and deploy it to the ‘$AKKA_HOME/deploy’ directory.
|
||||
4. Run the microkernel
|
||||
export AKKA_HOME=...
|
||||
cd $AKKA_HOME
|
||||
java -jar ./dist/akka-0.6.jar
|
||||
5. Now start up a new shell and go down into the ‘./akka-samples/akka-sample-chat’ directory.
|
||||
6. Invoke ‘mvn scala:console -o’. This will give you a Scala REPL (interpreter) with the chat application and all its dependency JARs on the classpath.
|
||||
7. Simply paste in the whole code block with the ‘Runner’ object above and invoke ‘Runner.run’. This run a simulated client session that will connect to the running server in the microkernel.
|
||||
7. Simply paste in the whole code block with the ‘Runner’ object above and invoke ‘Runner.run’. This runs a simulated client session that will connect to the running server in the microkernel.
|
||||
8. Invoke ‘Runner.run’ again and again…
|
||||
|
||||
Now you could test client reconnect by killing the running microkernel and start it up again. See the client reconnect take place in the REPL shell.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</log>
|
||||
|
||||
<akka>
|
||||
version = "0.6"
|
||||
version = "0.7-SNAPSHOT"
|
||||
|
||||
<actor>
|
||||
timeout = 5000 # default timeout for future based invocations
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
|||
0
akka-samples/akka-sample-lift/src/main/webapp/WEB-INF/web.xml
Executable file → Normal file
0
akka-samples/akka-sample-lift/src/main/webapp/WEB-INF/web.xml
Executable file → Normal file
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -132,13 +132,7 @@ class Chat extends Actor {
|
|||
@Suspend
|
||||
@GET
|
||||
@Produces(Array("text/html"))
|
||||
def suspend = {
|
||||
val s = new StringBuilder
|
||||
s append "<!-- "
|
||||
for(i <- 1 to 10) s append "Comet is a programming technique that enables web servers to send data to the client without having any need for the client to request it. "
|
||||
s append " -->"
|
||||
s toString
|
||||
}
|
||||
def suspend = ()
|
||||
|
||||
def receive = {
|
||||
case Chat(who, what, msg) => {
|
||||
|
|
@ -174,7 +168,7 @@ class JsonpFilter extends BroadcastFilter[String] with Logging {
|
|||
message = m.substring(m.indexOf("__") + 2)
|
||||
}
|
||||
|
||||
("<script type='text/javascript'>\n (window.app || window.parent.app).update({ name: \"" +
|
||||
new BroadcastFilter.BroadcastAction("<script type='text/javascript'>\n (window.app || window.parent.app).update({ name: \"" +
|
||||
name + "\", message: \"" + message + "\" }); \n</script>\n")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka-samples-parent</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
# Modify as needed.
|
||||
|
||||
<akka>
|
||||
version = "0.6"
|
||||
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
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
2
akka-util-java/pom.xml
Executable file → Normal file
2
akka-util-java/pom.xml
Executable file → Normal file
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<parent>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import net.lag.configgy.{Configgy, ParseException}
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
object Config extends Logging {
|
||||
val VERSION = "0.6"
|
||||
val VERSION = "0.7-SNAPSHOT"
|
||||
|
||||
// Set Multiverse options for max speed
|
||||
System.setProperty("org.multiverse.MuliverseConstants.sanityChecks", "false")
|
||||
|
|
|
|||
5
akka.iml
5
akka.iml
|
|
@ -1,5 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Scala" name="Scala">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
</log>
|
||||
|
||||
<akka>
|
||||
version = "0.6"
|
||||
version = "0.7-SNAPSHOT"
|
||||
|
||||
# FQN to the class doing initial active object/actor
|
||||
# supervisor bootstrap, should be defined in default constructor
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
<cluster>
|
||||
name = "default" # The name of the cluster
|
||||
actor = "se.scalablesolutions.akka.remote.JGroupsClusterActor" # FQN of an implementation of ClusterActor
|
||||
#actor = "se.scalablesolutions.akka.remote.JGroupsClusterActor" # FQN of an implementation of ClusterActor
|
||||
serializer = "se.scalablesolutions.akka.serialization.Serializer$Java" # FQN of the serializer class
|
||||
</cluster>
|
||||
|
||||
|
|
@ -69,7 +69,6 @@
|
|||
<cassandra>
|
||||
hostname = "127.0.0.1" # IP address or hostname of one of the Cassandra cluster's seeds
|
||||
port = 9160
|
||||
storage-format = "scala-json" # Options: java, scala-json, java-json, protobuf
|
||||
consistency-level = "QUORUM" # Options: ZERO, ONE, QUORUM, ALL
|
||||
</cassandra>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,27 +15,43 @@
|
|||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
-->
|
||||
<Storage>
|
||||
<!--======================================================================-->
|
||||
<!-- Basic Configuration -->
|
||||
<!--======================================================================-->
|
||||
|
||||
<!-- The name of this cluster. This is mainly used to prevent machines in
|
||||
one logical cluster from joining any other cluster. -->
|
||||
<!--
|
||||
~ The name of this cluster. This is mainly used to prevent machines in
|
||||
~ one logical cluster from joining another.
|
||||
-->
|
||||
<ClusterName>akka</ClusterName>
|
||||
|
||||
<!-- Keyspaces and ColumnFamilies
|
||||
A ColumnFamily is the Cassandra concept closest to a relational table.
|
||||
Keyspaces are separate groups of ColumnFamilies. Except in very
|
||||
unusual circumstances you will have one Keyspace per application.
|
||||
<!--
|
||||
~ Turn on to make new [non-seed] nodes automatically migrate the right data
|
||||
~ to themselves. (If no InitialToken is specified, they will pick one
|
||||
~ such that they will get half the range of the most-loaded node.)
|
||||
~ If a node starts up without bootstrapping, it will mark itself bootstrapped
|
||||
~ so that you can't subsequently accidently bootstrap a node with
|
||||
~ data on it. (You can reset this by wiping your data and commitlog
|
||||
~ directories.)
|
||||
~
|
||||
~ Off by default so that new clusters and upgraders from 0.4 don't
|
||||
~ bootstrap immediately. You should turn this on when you start adding
|
||||
~ new nodes to a cluster that already has data on it. (If you are upgrading
|
||||
~ from 0.4, start your cluster with it off once before changing it to true.
|
||||
~ Otherwise, no data will be lost but you will incur a lot of unnecessary
|
||||
~ I/O before your cluster starts up.)
|
||||
-->
|
||||
<AutoBootstrap>false</AutoBootstrap>
|
||||
|
||||
There is an implicit keyspace named 'system' for Cassandra internals.
|
||||
<!--
|
||||
~ Keyspaces and ColumnFamilies:
|
||||
~ A ColumnFamily is the Cassandra concept closest to a relational
|
||||
~ table. Keyspaces are separate groups of ColumnFamilies. Except in
|
||||
~ very unusual circumstances you will have one Keyspace per application.
|
||||
|
||||
The default ColumnSort is Time for standard column families.
|
||||
For super column families, specifying ColumnSort is not supported;
|
||||
the supercolumns themselves are always name-sorted and their subcolumns
|
||||
are always time-sorted.
|
||||
~ There is an implicit keyspace named 'system' for Cassandra internals.
|
||||
-->
|
||||
<Keyspaces>
|
||||
<Keyspace Name="akka">
|
||||
|
|
@ -87,183 +103,235 @@ one logical cluster from joining any other cluster. -->
|
|||
</Keyspace>
|
||||
</Keyspaces>
|
||||
|
||||
<!-- Partitioner: any IPartitioner may be used, including your own
|
||||
as long as it is on the classpath. Out of the box,
|
||||
Cassandra provides
|
||||
org.apache.cassandra.dht.RandomPartitioner,
|
||||
org.apache.cassandra.dht.OrderPreservingPartitioner, and
|
||||
org.apache.cassandra.dht.CollatingOrderPreservingPartitioner.
|
||||
(CollatingOPP colates according to EN,US rules, not naive byte ordering.
|
||||
Use this as an example if you need locale-aware collation.)
|
||||
Range queries require using OrderPreservingPartitioner or a subclass.
|
||||
|
||||
Achtung! Changing this parameter requires wiping your data directories,
|
||||
since the partitioner can modify the sstable on-disk format.
|
||||
<!--
|
||||
~ Partitioner: any IPartitioner may be used, including your own as long
|
||||
~ as it is on the classpath. Out of the box, Cassandra provides
|
||||
~ org.apache.cassandra.dht.RandomPartitioner,
|
||||
~ org.apache.cassandra.dht.OrderPreservingPartitioner, and
|
||||
~ org.apache.cassandra.dht.CollatingOrderPreservingPartitioner.
|
||||
~ (CollatingOPP colates according to EN,US rules, not naive byte
|
||||
~ ordering. Use this as an example if you need locale-aware collation.)
|
||||
~ Range queries require using an order-preserving partitioner.
|
||||
~
|
||||
~ Achtung! Changing this parameter requires wiping your data
|
||||
~ directories, since the partitioner can modify the sstable on-disk
|
||||
~ format.
|
||||
-->
|
||||
<Partitioner>org.apache.cassandra.dht.RandomPartitioner</Partitioner>
|
||||
|
||||
<!-- If you are using the OrderPreservingPartitioner and you know your key
|
||||
distribution, you can specify the token for this node to use.
|
||||
(Keys are sent to the node with the "closest" token, so distributing
|
||||
your tokens equally along the key distribution space will spread
|
||||
keys evenly across your cluster.) This setting is only checked the
|
||||
first time a node is started.
|
||||
<!--
|
||||
~ If you are using an order-preserving partitioner and you know your key
|
||||
~ distribution, you can specify the token for this node to use. (Keys
|
||||
~ are sent to the node with the "closest" token, so distributing your
|
||||
~ tokens equally along the key distribution space will spread keys
|
||||
~ evenly across your cluster.) This setting is only checked the first
|
||||
~ time a node is started.
|
||||
|
||||
This can also be useful with RandomPartitioner to force equal
|
||||
spacing of tokens around the hash space, especially for
|
||||
clusters with a small number of nodes. -->
|
||||
~ This can also be useful with RandomPartitioner to force equal spacing
|
||||
~ of tokens around the hash space, especially for clusters with a small
|
||||
~ number of nodes.
|
||||
-->
|
||||
<InitialToken></InitialToken>
|
||||
|
||||
|
||||
<!-- EndPointSnitch: Setting this to the class that implements IEndPointSnitch
|
||||
which will see if two endpoints are in the same data center or on the same rack.
|
||||
Out of the box, Cassandra provides
|
||||
org.apache.cassandra.locator.EndPointSnitch
|
||||
<!--
|
||||
~ EndPointSnitch: Setting this to the class that implements
|
||||
~ IEndPointSnitch which will see if two endpoints are in the same data
|
||||
~ center or on the same rack. Out of the box, Cassandra provides
|
||||
~ org.apache.cassandra.locator.EndPointSnitch
|
||||
-->
|
||||
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
|
||||
|
||||
<!-- Strategy: Setting this to the class that implements IReplicaPlacementStrategy
|
||||
will change the way the node picker works.
|
||||
Out of the box, Cassandra provides
|
||||
org.apache.cassandra.locator.RackUnawareStrategy
|
||||
org.apache.cassandra.locator.RackAwareStrategy
|
||||
(place one replica in a different datacenter, and the
|
||||
others on different racks in the same one.)
|
||||
<!--
|
||||
~ Strategy: Setting this to the class that implements
|
||||
~ IReplicaPlacementStrategy will change the way the node picker works.
|
||||
~ Out of the box, Cassandra provides
|
||||
~ org.apache.cassandra.locator.RackUnawareStrategy and
|
||||
~ org.apache.cassandra.locator.RackAwareStrategy (place one replica in
|
||||
~ a different datacenter, and the others on different racks in the same
|
||||
~ one.)
|
||||
-->
|
||||
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
||||
|
||||
<!-- Number of replicas of the data-->
|
||||
<!-- Number of replicas of the data -->
|
||||
<ReplicationFactor>1</ReplicationFactor>
|
||||
|
||||
<!-- Directories: Specify where Cassandra should store different data on disk
|
||||
Keep the data disks and the CommitLog disks separate for best performance
|
||||
<!--
|
||||
~ Directories: Specify where Cassandra should store different data on
|
||||
~ disk. Keep the data disks and the CommitLog disks separate for best
|
||||
~ performance
|
||||
-->
|
||||
<CommitLogDirectory>cassandra/commitlog</CommitLogDirectory>
|
||||
<DataFileDirectories>
|
||||
<DataFileDirectory>cassandra/data</DataFileDirectory>
|
||||
<DataFileDirectory>cassandra/data</DataFileDirectory>
|
||||
</DataFileDirectories>
|
||||
<CalloutLocation>cassandra/callouts</CalloutLocation>
|
||||
<BootstrapFileDirectory>cassandra/bootstrap</BootstrapFileDirectory>
|
||||
<StagingFileDirectory>cassandra/staging</StagingFileDirectory>
|
||||
|
||||
|
||||
<!-- Addresses of hosts that are deemed contact points. Cassandra nodes use
|
||||
this list of hosts to find each other and learn the topology of the ring.
|
||||
You must change this if you are running multiple nodes!
|
||||
<!--
|
||||
~ Addresses of hosts that are deemed contact points. Cassandra nodes
|
||||
~ use this list of hosts to find each other and learn the topology of
|
||||
~ the ring. You must change this if you are running multiple nodes!
|
||||
-->
|
||||
<Seeds>
|
||||
<Seed>127.0.0.1</Seed>
|
||||
<Seed>127.0.0.1</Seed>
|
||||
</Seeds>
|
||||
|
||||
|
||||
<!-- Miscellaneous -->
|
||||
|
||||
<!-- time to wait for a reply from other nodes before failing the command -->
|
||||
<!-- Time to wait for a reply from other nodes before failing the command -->
|
||||
<RpcTimeoutInMillis>5000</RpcTimeoutInMillis>
|
||||
<!-- size to allow commitlog to grow to before creating a new segment -->
|
||||
<!-- Size to allow commitlog to grow to before creating a new segment -->
|
||||
<CommitLogRotationThresholdInMB>128</CommitLogRotationThresholdInMB>
|
||||
|
||||
|
||||
<!-- Local hosts and ports -->
|
||||
|
||||
<!-- Address to bind to and tell other nodes to connect to.
|
||||
You _must_ change this if you want multiple nodes to be able
|
||||
to communicate!
|
||||
|
||||
Leaving it blank leaves it up to InetAddress.getLocalHost().
|
||||
This will always do the Right Thing *if* the node is properly
|
||||
configured (hostname, name resolution, etc), and the Right
|
||||
Thing is to use the address associated with the hostname (it
|
||||
might not be). -->
|
||||
<!--
|
||||
~ Address to bind to and tell other nodes to connect to. You _must_
|
||||
~ change this if you want multiple nodes to be able to communicate!
|
||||
~
|
||||
~ Leaving it blank leaves it up to InetAddress.getLocalHost(). This
|
||||
~ will always do the Right Thing *if* the node is properly configured
|
||||
~ (hostname, name resolution, etc), and the Right Thing is to use the
|
||||
~ address associated with the hostname (it might not be).
|
||||
-->
|
||||
<ListenAddress>localhost</ListenAddress>
|
||||
<!-- TCP port, for commands and data -->
|
||||
<StoragePort>7000</StoragePort>
|
||||
<!-- UDP port, for membership communications (gossip) -->
|
||||
<ControlPort>7001</ControlPort>
|
||||
|
||||
<!-- The address to bind the Thrift RPC service to. Unlike
|
||||
ListenAddress above, you *can* specify 0.0.0.0 here if you want
|
||||
Thrift to listen on all interfaces.
|
||||
|
||||
Leaving this blank has the same effect it does for ListenAddress,
|
||||
(i.e. it will be based on the configured hostname of the node).
|
||||
<!--
|
||||
~ The address to bind the Thrift RPC service to. Unlike ListenAddress
|
||||
~ above, you *can* specify 0.0.0.0 here if you want Thrift to listen on
|
||||
~ all interfaces.
|
||||
~
|
||||
~ Leaving this blank has the same effect it does for ListenAddress,
|
||||
~ (i.e. it will be based on the configured hostname of the node).
|
||||
-->
|
||||
<ThriftAddress>localhost</ThriftAddress>
|
||||
<!-- Thrift RPC port (the port clients connect to). -->
|
||||
<ThriftPort>9160</ThriftPort>
|
||||
<!--
|
||||
~ Whether or not to use a framed transport for Thrift. If this option
|
||||
~ is set to true then you must also use a framed transport on the
|
||||
~ client-side, (framed and non-framed transports are not compatible).
|
||||
-->
|
||||
<ThriftFramedTransport>false</ThriftFramedTransport>
|
||||
|
||||
|
||||
<!--======================================================================-->
|
||||
<!-- Memory, Disk, and Performance -->
|
||||
<!--======================================================================-->
|
||||
|
||||
<!-- Buffer size to use when flushing memtables to disk.
|
||||
(Only one memtable is ever flushed at a time.)
|
||||
Increase (decrease) the index buffer size relative to the data buffer
|
||||
if you have few (many) columns per key.
|
||||
Bigger is only better _if_ your memtables get large enough to use the space.
|
||||
(Check in your data directory after your app has been running long enough.)
|
||||
<!--
|
||||
~ Buffer size to use when performing contiguous column slices. Increase
|
||||
~ this to the size of the column slices you typically perform.
|
||||
~ (Name-based queries are performed with a buffer size of
|
||||
~ ColumnIndexSizeInKB.)
|
||||
-->
|
||||
<SlicedBufferSizeInKB>64</SlicedBufferSizeInKB>
|
||||
|
||||
<!--
|
||||
~ Buffer size to use when flushing memtables to disk. (Only one
|
||||
~ memtable is ever flushed at a time.) Increase (decrease) the index
|
||||
~ buffer size relative to the data buffer if you have few (many)
|
||||
~ columns per key. Bigger is only better _if_ your memtables get large
|
||||
~ enough to use the space. (Check in your data directory after your
|
||||
~ app has been running long enough.) -->
|
||||
<FlushDataBufferSizeInMB>32</FlushDataBufferSizeInMB>
|
||||
<FlushIndexBufferSizeInMB>8</FlushIndexBufferSizeInMB>
|
||||
|
||||
<!-- Add column indexes to a row after its contents reach this size.
|
||||
Increase if your column values are large, or if you have a very large
|
||||
number of columns. The competing causes are, Cassandra has to
|
||||
deserialize this much of the row to read a single column, so you
|
||||
want it to be small - at least if you do many partial-row reads
|
||||
- but all the index data is read for each access, so
|
||||
you don't want to generate that wastefully either. -->
|
||||
<!--
|
||||
~ Add column indexes to a row after its contents reach this size.
|
||||
~ Increase if your column values are large, or if you have a very large
|
||||
~ number of columns. The competing causes are, Cassandra has to
|
||||
~ deserialize this much of the row to read a single column, so you want
|
||||
~ it to be small - at least if you do many partial-row reads - but all
|
||||
~ the index data is read for each access, so you don't want to generate
|
||||
~ that wastefully either.
|
||||
-->
|
||||
<ColumnIndexSizeInKB>64</ColumnIndexSizeInKB>
|
||||
|
||||
<!--
|
||||
The maximum amount of data to store in memory per ColumnFamily before flushing to
|
||||
disk. Note: There is one memtable per column family, and this threshold
|
||||
is based solely on the amount of data stored, not actual heap memory
|
||||
usage (there is some overhead in indexing the columns).
|
||||
~ The maximum amount of data to store in memory per ColumnFamily before
|
||||
~ flushing to disk. Note: There is one memtable per column family, and
|
||||
~ this threshold is based solely on the amount of data stored, not
|
||||
~ actual heap memory usage (there is some overhead in indexing the
|
||||
~ columns).
|
||||
-->
|
||||
<MemtableSizeInMB>64</MemtableSizeInMB>
|
||||
<!--
|
||||
The maximum number of columns in millions to store in memory per ColumnFamily
|
||||
before flushing to disk. This is also a per-memtable setting.
|
||||
Use with MemtableSizeInMB to tune memory usage.
|
||||
~ The maximum number of columns in millions to store in memory per
|
||||
~ ColumnFamily before flushing to disk. This is also a per-memtable
|
||||
~ setting. Use with MemtableSizeInMB to tune memory usage.
|
||||
-->
|
||||
<MemtableObjectCountInMillions>0.1</MemtableObjectCountInMillions>
|
||||
<!--
|
||||
~ The maximum time to leave a dirty memtable unflushed.
|
||||
~ (While any affected columnfamilies have unflushed data from a
|
||||
~ commit log segment, that segment cannot be deleted.)
|
||||
~ This needs to be large enough that it won't cause a flush storm
|
||||
~ of all your memtables flushing at once because none has hit
|
||||
~ the size or count thresholds yet. For production, a larger
|
||||
~ value such as 1440 is recommended.
|
||||
-->
|
||||
<MemtableFlushAfterMinutes>60</MemtableFlushAfterMinutes>
|
||||
|
||||
<!-- Unlike most systems, in Cassandra writes are faster than
|
||||
reads, so you can afford more of those in parallel.
|
||||
A good rule of thumb is 2 concurrent reads per processor core.
|
||||
Increase ConcurrentWrites to the number of clients writing
|
||||
at once if you enable CommitLogSync + CommitLogSyncDelay. -->
|
||||
<!--
|
||||
~ Unlike most systems, in Cassandra writes are faster than reads, so
|
||||
~ you can afford more of those in parallel. A good rule of thumb is 2
|
||||
~ concurrent reads per processor core. Increase ConcurrentWrites to
|
||||
~ the number of clients writing at once if you enable CommitLogSync +
|
||||
~ CommitLogSyncDelay. -->
|
||||
<ConcurrentReads>8</ConcurrentReads>
|
||||
<ConcurrentWrites>32</ConcurrentWrites>
|
||||
|
||||
<!-- Turn on CommitLogSync to improve durability.
|
||||
When enabled, Cassandra won't ack writes until the commit log
|
||||
has been synced to disk. This is less necessary in Cassandra
|
||||
than in traditional databases since replication reduces the
|
||||
odds of losing data from a failure after writing the log
|
||||
entry but before it actually reaches the disk.
|
||||
-->
|
||||
<CommitLogSync>false</CommitLogSync>
|
||||
<!-- Delay (in microseconds) during which additional commit log
|
||||
entries may be written before fsync. This will increase
|
||||
latency slightly, but can vastly improve throughput where
|
||||
there are many writers. Set to zero to disable
|
||||
(each entry will be synced individually).
|
||||
Reasonable values range from a minimal 100 to even 10000
|
||||
if throughput matters more than latency. (10000us = 10ms
|
||||
write latency isn't even that bad by traditional db
|
||||
standards.)
|
||||
-->
|
||||
<CommitLogSyncDelay>1000</CommitLogSyncDelay>
|
||||
<!--
|
||||
~ CommitLogSync may be either "periodic" or "batch." When in batch
|
||||
~ mode, Cassandra won't ack writes until the commit log has been
|
||||
~ fsynced to disk. It will wait up to CommitLogSyncBatchWindowInMS
|
||||
~ milliseconds for other writes, before performing the sync.
|
||||
|
||||
~ This is less necessary in Cassandra than in traditional databases
|
||||
~ since replication reduces the odds of losing data from a failure
|
||||
~ after writing the log entry but before it actually reaches the disk.
|
||||
~ So the other option is "timed," where writes may be acked immediately
|
||||
~ and the CommitLog is simply synced every CommitLogSyncPeriodInMS
|
||||
~ milliseconds.
|
||||
-->
|
||||
<CommitLogSync>periodic</CommitLogSync>
|
||||
<!--
|
||||
~ Interval at which to perform syncs of the CommitLog in periodic mode.
|
||||
~ Usually the default of 10000ms is fine; increase it if your i/o
|
||||
~ load is such that syncs are taking excessively long times.
|
||||
-->
|
||||
<CommitLogSyncPeriodInMS>10000</CommitLogSyncPeriodInMS>
|
||||
<!--
|
||||
~ Delay (in milliseconds) during which additional commit log entries
|
||||
~ may be written before fsync in batch mode. This will increase
|
||||
~ latency slightly, but can vastly improve throughput where there are
|
||||
~ many writers. Set to zero to disable (each entry will be synced
|
||||
~ individually). Reasonable values range from a minimal 0.1 to 10 or
|
||||
~ even more if throughput matters more than latency.
|
||||
-->
|
||||
<!-- <CommitLogSyncBatchWindowInMS>1</CommitLogSyncBatchWindowInMS> -->
|
||||
|
||||
<!-- Time to wait before garbage-collection deletion markers.
|
||||
Set this to a large enough value that you are confident
|
||||
that the deletion marker will be propagated to all replicas
|
||||
by the time this many seconds has elapsed, even in the
|
||||
face of hardware failures. The default value is ten days.
|
||||
<!--
|
||||
~ Time to wait before garbage-collection deletion markers. Set this to
|
||||
~ a large enough value that you are confident that the deletion marker
|
||||
~ will be propagated to all replicas by the time this many seconds has
|
||||
~ elapsed, even in the face of hardware failures. The default value is
|
||||
~ ten days.
|
||||
-->
|
||||
<GCGraceSeconds>864000</GCGraceSeconds>
|
||||
|
||||
<!--
|
||||
~ The threshold size in megabytes the binary memtable must grow to,
|
||||
~ before it's submitted for flushing to disk.
|
||||
-->
|
||||
<BinaryMemtableSizeInMB>256</BinaryMemtableSizeInMB>
|
||||
|
||||
</Storage>
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 7.8 KiB |
|
|
@ -1,45 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Atmosphere Scala REST Chat</title>
|
||||
<link rel="stylesheet" href="stylesheets/default.css" type="text/css" />
|
||||
<script type="text/javascript" src="javascripts/prototype.js"></script>
|
||||
<script type="text/javascript" src="javascripts/behaviour.js"></script>
|
||||
<script type="text/javascript" src="javascripts/moo.fx.js"></script>
|
||||
<script type="text/javascript" src="javascripts/moo.fx.pack.js"></script>
|
||||
<script type="text/javascript" src="javascripts/application.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="container-inner">
|
||||
<div id="header">
|
||||
<h1>Atmosphere REST Chat</h1>
|
||||
</div>
|
||||
<div id="main">
|
||||
<div id="display">
|
||||
</div>
|
||||
<div id="form">
|
||||
<div id="system-message">Please input your name:</div>
|
||||
<div id="login-form">
|
||||
<input id="login-name" type="text" />
|
||||
<br />
|
||||
<input id="login-button" type="button" value="Login" />
|
||||
</div>
|
||||
<div id="message-form" style="display: none;">
|
||||
<div>
|
||||
<textarea id="message" name="message" rows="2" cols="40"></textarea>
|
||||
<br />
|
||||
<input id="post-button" type="button" value="Post Message" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<iframe id="comet-frame" style="display: none;"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
var count = 0;
|
||||
var app = {
|
||||
url: '/chat',
|
||||
initialize: function() {
|
||||
$('login-name').focus();
|
||||
app.listen();
|
||||
},
|
||||
listen: function() {
|
||||
$('comet-frame').src = app.url + '?' + count;
|
||||
count ++;
|
||||
},
|
||||
login: function() {
|
||||
var name = $F('login-name');
|
||||
if(! name.length > 0) {
|
||||
$('system-message').style.color = 'red';
|
||||
$('login-name').focus();
|
||||
return;
|
||||
}
|
||||
$('system-message').style.color = '#2d2b3d';
|
||||
$('system-message').innerHTML = name + ':';
|
||||
|
||||
$('login-button').disabled = true;
|
||||
$('login-form').style.display = 'none';
|
||||
$('message-form').style.display = '';
|
||||
|
||||
var query =
|
||||
'action=login' +
|
||||
'&name=' + encodeURI($F('login-name'));
|
||||
new Ajax.Request(app.url, {
|
||||
postBody: query,
|
||||
onSuccess: function() {
|
||||
$('message').focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
post: function() {
|
||||
var message = $F('message');
|
||||
if(!message > 0) {
|
||||
return;
|
||||
}
|
||||
$('message').disabled = true;
|
||||
$('post-button').disabled = true;
|
||||
|
||||
var query =
|
||||
'action=post' +
|
||||
'&name=' + encodeURI($F('login-name')) +
|
||||
'&message=' + encodeURI(message);
|
||||
new Ajax.Request(app.url, {
|
||||
postBody: query,
|
||||
onComplete: function() {
|
||||
$('message').disabled = false;
|
||||
$('post-button').disabled = false;
|
||||
$('message').focus();
|
||||
$('message').value = '';
|
||||
}
|
||||
});
|
||||
},
|
||||
update: function(data) {
|
||||
var p = document.createElement('p');
|
||||
p.innerHTML = data.name + ':<br/>' + data.message;
|
||||
|
||||
$('display').appendChild(p);
|
||||
|
||||
new Fx.Scroll('display').down();
|
||||
}
|
||||
};
|
||||
var rules = {
|
||||
'#login-name': function(elem) {
|
||||
Event.observe(elem, 'keydown', function(e) {
|
||||
if(e.keyCode == 13) {
|
||||
$('login-button').focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
'#login-button': function(elem) {
|
||||
elem.onclick = app.login;
|
||||
},
|
||||
'#message': function(elem) {
|
||||
Event.observe(elem, 'keydown', function(e) {
|
||||
if(e.shiftKey && e.keyCode == 13) {
|
||||
$('post-button').focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
'#post-button': function(elem) {
|
||||
elem.onclick = app.post;
|
||||
}
|
||||
};
|
||||
Behaviour.addLoadEvent(app.initialize);
|
||||
Behaviour.register(rules);
|
||||
|
|
@ -1,254 +0,0 @@
|
|||
/*
|
||||
Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
|
||||
of Simon Willison (see comments by Simon below).
|
||||
|
||||
Description:
|
||||
|
||||
Uses css selectors to apply javascript behaviours to enable
|
||||
unobtrusive javascript in html documents.
|
||||
|
||||
Usage:
|
||||
|
||||
var myrules = {
|
||||
'b.someclass' : function(element){
|
||||
element.onclick = function(){
|
||||
alert(this.innerHTML);
|
||||
}
|
||||
},
|
||||
'#someid u' : function(element){
|
||||
element.onmouseover = function(){
|
||||
this.innerHTML = "BLAH!";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Behaviour.register(myrules);
|
||||
|
||||
// Call Behaviour.apply() to re-apply the rules (if you
|
||||
// update the dom, etc).
|
||||
|
||||
License:
|
||||
|
||||
This file is entirely BSD licensed.
|
||||
|
||||
More information:
|
||||
|
||||
http://ripcord.co.nz/behaviour/
|
||||
|
||||
*/
|
||||
|
||||
var Behaviour = {
|
||||
list : new Array,
|
||||
|
||||
register : function(sheet){
|
||||
Behaviour.list.push(sheet);
|
||||
},
|
||||
|
||||
start : function(){
|
||||
Behaviour.addLoadEvent(function(){
|
||||
Behaviour.apply();
|
||||
});
|
||||
},
|
||||
|
||||
apply : function(){
|
||||
for (h=0;sheet=Behaviour.list[h];h++){
|
||||
for (selector in sheet){
|
||||
list = document.getElementsBySelector(selector);
|
||||
|
||||
if (!list){
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i=0;element=list[i];i++){
|
||||
sheet[selector](element);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addLoadEvent : function(func){
|
||||
var oldonload = window.onload;
|
||||
|
||||
if (typeof window.onload != 'function') {
|
||||
window.onload = func;
|
||||
} else {
|
||||
window.onload = function() {
|
||||
oldonload();
|
||||
func();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behaviour.start();
|
||||
|
||||
/*
|
||||
The following code is Copyright (C) Simon Willison 2004.
|
||||
|
||||
document.getElementsBySelector(selector)
|
||||
- returns an array of element objects from the current document
|
||||
matching the CSS selector. Selectors can contain element names,
|
||||
class names and ids and can be nested. For example:
|
||||
|
||||
elements = document.getElementsBySelect('div#main p a.external')
|
||||
|
||||
Will return an array of all 'a' elements with 'external' in their
|
||||
class attribute that are contained inside 'p' elements that are
|
||||
contained inside the 'div' element which has id="main"
|
||||
|
||||
New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
|
||||
See http://www.w3.org/TR/css3-selectors/#attribute-selectors
|
||||
|
||||
Version 0.4 - Simon Willison, March 25th 2003
|
||||
-- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
|
||||
-- Opera 7 fails
|
||||
*/
|
||||
|
||||
function getAllChildren(e) {
|
||||
// Returns all children of element. Workaround required for IE5/Windows. Ugh.
|
||||
return e.all ? e.all : e.getElementsByTagName('*');
|
||||
}
|
||||
|
||||
document.getElementsBySelector = function(selector) {
|
||||
// Attempt to fail gracefully in lesser browsers
|
||||
if (!document.getElementsByTagName) {
|
||||
return new Array();
|
||||
}
|
||||
// Split selector in to tokens
|
||||
var tokens = selector.split(' ');
|
||||
var currentContext = new Array(document);
|
||||
for (var i = 0; i < tokens.length; i++) {
|
||||
token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
|
||||
if (token.indexOf('#') > -1) {
|
||||
// Token is an ID selector
|
||||
var bits = token.split('#');
|
||||
var tagName = bits[0];
|
||||
var id = bits[1];
|
||||
var element = document.getElementById(id);
|
||||
if (tagName && element.nodeName.toLowerCase() != tagName) {
|
||||
// tag with that ID not found, return false
|
||||
return new Array();
|
||||
}
|
||||
// Set currentContext to contain just this element
|
||||
currentContext = new Array(element);
|
||||
continue; // Skip to next token
|
||||
}
|
||||
if (token.indexOf('.') > -1) {
|
||||
// Token contains a class selector
|
||||
var bits = token.split('.');
|
||||
var tagName = bits[0];
|
||||
var className = bits[1];
|
||||
if (!tagName) {
|
||||
tagName = '*';
|
||||
}
|
||||
// Get elements matching tag, filter them for class selector
|
||||
var found = new Array;
|
||||
var foundCount = 0;
|
||||
for (var h = 0; h < currentContext.length; h++) {
|
||||
var elements;
|
||||
if (tagName == '*') {
|
||||
elements = getAllChildren(currentContext[h]);
|
||||
} else {
|
||||
elements = currentContext[h].getElementsByTagName(tagName);
|
||||
}
|
||||
for (var j = 0; j < elements.length; j++) {
|
||||
found[foundCount++] = elements[j];
|
||||
}
|
||||
}
|
||||
currentContext = new Array;
|
||||
var currentContextIndex = 0;
|
||||
for (var k = 0; k < found.length; k++) {
|
||||
if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
|
||||
currentContext[currentContextIndex++] = found[k];
|
||||
}
|
||||
}
|
||||
continue; // Skip to next token
|
||||
}
|
||||
// Code to deal with attribute selectors
|
||||
if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
|
||||
var tagName = RegExp.$1;
|
||||
var attrName = RegExp.$2;
|
||||
var attrOperator = RegExp.$3;
|
||||
var attrValue = RegExp.$4;
|
||||
if (!tagName) {
|
||||
tagName = '*';
|
||||
}
|
||||
// Grab all of the tagName elements within current context
|
||||
var found = new Array;
|
||||
var foundCount = 0;
|
||||
for (var h = 0; h < currentContext.length; h++) {
|
||||
var elements;
|
||||
if (tagName == '*') {
|
||||
elements = getAllChildren(currentContext[h]);
|
||||
} else {
|
||||
elements = currentContext[h].getElementsByTagName(tagName);
|
||||
}
|
||||
for (var j = 0; j < elements.length; j++) {
|
||||
found[foundCount++] = elements[j];
|
||||
}
|
||||
}
|
||||
currentContext = new Array;
|
||||
var currentContextIndex = 0;
|
||||
var checkFunction; // This function will be used to filter the elements
|
||||
switch (attrOperator) {
|
||||
case '=': // Equality
|
||||
checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
|
||||
break;
|
||||
case '~': // Match one of space seperated words
|
||||
checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
|
||||
break;
|
||||
case '|': // Match start with value followed by optional hyphen
|
||||
checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
|
||||
break;
|
||||
case '^': // Match starts with value
|
||||
checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
|
||||
break;
|
||||
case '$': // Match ends with value - fails with "Warning" in Opera 7
|
||||
checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
|
||||
break;
|
||||
case '*': // Match ends with value
|
||||
checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
|
||||
break;
|
||||
default :
|
||||
// Just test for existence of attribute
|
||||
checkFunction = function(e) { return e.getAttribute(attrName); };
|
||||
}
|
||||
currentContext = new Array;
|
||||
var currentContextIndex = 0;
|
||||
for (var k = 0; k < found.length; k++) {
|
||||
if (checkFunction(found[k])) {
|
||||
currentContext[currentContextIndex++] = found[k];
|
||||
}
|
||||
}
|
||||
// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
|
||||
continue; // Skip to next token
|
||||
}
|
||||
|
||||
if (!currentContext[0]){
|
||||
return;
|
||||
}
|
||||
|
||||
// If we get here, token is JUST an element (not a class or ID selector)
|
||||
tagName = token;
|
||||
var found = new Array;
|
||||
var foundCount = 0;
|
||||
for (var h = 0; h < currentContext.length; h++) {
|
||||
var elements = currentContext[h].getElementsByTagName(tagName);
|
||||
for (var j = 0; j < elements.length; j++) {
|
||||
found[foundCount++] = elements[j];
|
||||
}
|
||||
}
|
||||
currentContext = found;
|
||||
}
|
||||
return currentContext;
|
||||
}
|
||||
|
||||
/* That revolting regular expression explained
|
||||
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
|
||||
\---/ \---/\-------------/ \-------/
|
||||
| | | |
|
||||
| | | The value
|
||||
| | ~,|,^,$,* or =
|
||||
| Attribute
|
||||
Tag
|
||||
*/
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
//(c) 2006 Valerio Proietti (http://mad4milk.net). MIT-style license.
|
||||
//moo.fx.js - depends on prototype.js OR prototype.lite.js
|
||||
//version 2.0
|
||||
|
||||
var Fx = fx = {};
|
||||
|
||||
Fx.Base = function(){};
|
||||
Fx.Base.prototype = {
|
||||
|
||||
setOptions: function(options){
|
||||
this.options = Object.extend({
|
||||
onStart: function(){},
|
||||
onComplete: function(){},
|
||||
transition: Fx.Transitions.sineInOut,
|
||||
duration: 500,
|
||||
unit: 'px',
|
||||
wait: true,
|
||||
fps: 50
|
||||
}, options || {});
|
||||
},
|
||||
|
||||
step: function(){
|
||||
var time = new Date().getTime();
|
||||
if (time < this.time + this.options.duration){
|
||||
this.cTime = time - this.time;
|
||||
this.setNow();
|
||||
} else {
|
||||
setTimeout(this.options.onComplete.bind(this, this.element), 10);
|
||||
this.clearTimer();
|
||||
this.now = this.to;
|
||||
}
|
||||
this.increase();
|
||||
},
|
||||
|
||||
setNow: function(){
|
||||
this.now = this.compute(this.from, this.to);
|
||||
},
|
||||
|
||||
compute: function(from, to){
|
||||
var change = to - from;
|
||||
return this.options.transition(this.cTime, from, change, this.options.duration);
|
||||
},
|
||||
|
||||
clearTimer: function(){
|
||||
clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
return this;
|
||||
},
|
||||
|
||||
_start: function(from, to){
|
||||
if (!this.options.wait) this.clearTimer();
|
||||
if (this.timer) return;
|
||||
setTimeout(this.options.onStart.bind(this, this.element), 10);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.time = new Date().getTime();
|
||||
this.timer = setInterval(this.step.bind(this), Math.round(1000/this.options.fps));
|
||||
return this;
|
||||
},
|
||||
|
||||
custom: function(from, to){
|
||||
return this._start(from, to);
|
||||
},
|
||||
|
||||
set: function(to){
|
||||
this.now = to;
|
||||
this.increase();
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function(){
|
||||
return this.set(0);
|
||||
},
|
||||
|
||||
setStyle: function(e, p, v){
|
||||
if (p == 'opacity'){
|
||||
if (v == 0 && e.style.visibility != "hidden") e.style.visibility = "hidden";
|
||||
else if (e.style.visibility != "visible") e.style.visibility = "visible";
|
||||
if (window.ActiveXObject) e.style.filter = "alpha(opacity=" + v*100 + ")";
|
||||
e.style.opacity = v;
|
||||
} else e.style[p] = v+this.options.unit;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Fx.Style = Class.create();
|
||||
Fx.Style.prototype = Object.extend(new Fx.Base(), {
|
||||
|
||||
initialize: function(el, property, options){
|
||||
this.element = $(el);
|
||||
this.setOptions(options);
|
||||
this.property = property.camelize();
|
||||
},
|
||||
|
||||
increase: function(){
|
||||
this.setStyle(this.element, this.property, this.now);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Fx.Styles = Class.create();
|
||||
Fx.Styles.prototype = Object.extend(new Fx.Base(), {
|
||||
|
||||
initialize: function(el, options){
|
||||
this.element = $(el);
|
||||
this.setOptions(options);
|
||||
this.now = {};
|
||||
},
|
||||
|
||||
setNow: function(){
|
||||
for (p in this.from) this.now[p] = this.compute(this.from[p], this.to[p]);
|
||||
},
|
||||
|
||||
custom: function(obj){
|
||||
if (this.timer && this.options.wait) return;
|
||||
var from = {};
|
||||
var to = {};
|
||||
for (p in obj){
|
||||
from[p] = obj[p][0];
|
||||
to[p] = obj[p][1];
|
||||
}
|
||||
return this._start(from, to);
|
||||
},
|
||||
|
||||
increase: function(){
|
||||
for (var p in this.now) this.setStyle(this.element, p, this.now[p]);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Transitions (c) 2003 Robert Penner (http://www.robertpenner.com/easing/), BSD License.
|
||||
|
||||
Fx.Transitions = {
|
||||
linear: function(t, b, c, d) { return c*t/d + b; },
|
||||
sineInOut: function(t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; }
|
||||
};
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
//by Valerio Proietti (http://mad4milk.net). MIT-style license.
|
||||
//moo.fx.pack.js - depends on prototype.js or prototype.lite.js + moo.fx.js
|
||||
//version 2.0
|
||||
|
||||
Fx.Scroll = Class.create();
|
||||
Fx.Scroll.prototype = Object.extend(new Fx.Base(), {
|
||||
|
||||
initialize: function(el, options) {
|
||||
this.element = $(el);
|
||||
this.setOptions(options);
|
||||
this.element.style.overflow = 'hidden';
|
||||
},
|
||||
|
||||
down: function(){
|
||||
return this.custom(this.element.scrollTop, this.element.scrollHeight-this.element.offsetHeight);
|
||||
},
|
||||
|
||||
up: function(){
|
||||
return this.custom(this.element.scrollTop, 0);
|
||||
},
|
||||
|
||||
increase: function(){
|
||||
this.element.scrollTop = this.now;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//fx.Color, originally by Tom Jensen (http://neuemusic.com) MIT-style LICENSE.
|
||||
|
||||
Fx.Color = Class.create();
|
||||
Fx.Color.prototype = Object.extend(new Fx.Base(), {
|
||||
|
||||
initialize: function(el, property, options){
|
||||
this.element = $(el);
|
||||
this.setOptions(options);
|
||||
this.property = property.camelize();
|
||||
this.now = [];
|
||||
},
|
||||
|
||||
custom: function(from, to){
|
||||
return this._start(from.hexToRgb(true), to.hexToRgb(true));
|
||||
},
|
||||
|
||||
setNow: function(){
|
||||
[0,1,2].each(function(i){
|
||||
this.now[i] = Math.round(this.compute(this.from[i], this.to[i]));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
increase: function(){
|
||||
this.element.style[this.property] = "rgb("+this.now[0]+","+this.now[1]+","+this.now[2]+")";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.extend(String.prototype, {
|
||||
|
||||
rgbToHex: function(array){
|
||||
var rgb = this.match(new RegExp('([\\d]{1,3})', 'g'));
|
||||
if (rgb[3] == 0) return 'transparent';
|
||||
var hex = [];
|
||||
for (var i = 0; i < 3; i++){
|
||||
var bit = (rgb[i]-0).toString(16);
|
||||
hex.push(bit.length == 1 ? '0'+bit : bit);
|
||||
}
|
||||
var hexText = '#'+hex.join('');
|
||||
if (array) return hex;
|
||||
else return hexText;
|
||||
},
|
||||
|
||||
hexToRgb: function(array){
|
||||
var hex = this.match(new RegExp('^[#]{0,1}([\\w]{1,2})([\\w]{1,2})([\\w]{1,2})$'));
|
||||
var rgb = [];
|
||||
for (var i = 1; i < hex.length; i++){
|
||||
if (hex[i].length == 1) hex[i] += hex[i];
|
||||
rgb.push(parseInt(hex[i], 16));
|
||||
}
|
||||
var rgbText = 'rgb('+rgb.join(',')+')';
|
||||
if (array) return rgb;
|
||||
else return rgbText;
|
||||
}
|
||||
|
||||
});
|
||||
1781
deploy/root/javascripts/prototype.js
vendored
1781
deploy/root/javascripts/prototype.js
vendored
File diff suppressed because it is too large
Load diff
19
deploy/root/jquery-1.3.2.min.js
vendored
Normal file
19
deploy/root/jquery-1.3.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,54 +0,0 @@
|
|||
body {
|
||||
background-image: url(../images/body-background.png);
|
||||
background-repeat: repeat-x;
|
||||
background-color: #5c8098;
|
||||
}
|
||||
html, body, h1, h2 {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
body, textarea, input {
|
||||
font-size: 12px;
|
||||
font-family: Verdana, Helvetica, Arial, sans-serif;
|
||||
color: #2d2b3d;
|
||||
}
|
||||
#container {
|
||||
text-align:center;
|
||||
}
|
||||
#container-inner {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
text-align: justify;
|
||||
width: 820px;
|
||||
}
|
||||
#header {
|
||||
width: 820px;
|
||||
height: 100px;
|
||||
background-image: url(../images/header-background.png);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#header h1 {
|
||||
display: none;
|
||||
}
|
||||
#main {
|
||||
height: 610px;
|
||||
background-image: url(../images/main-background.png);
|
||||
background-repeat: no-repeat;
|
||||
text-align: left;
|
||||
width: 740px;
|
||||
padding: 30px 40px 20px 40px;
|
||||
}
|
||||
#display {
|
||||
border: 1px solid #5c8098;
|
||||
width: 740px;
|
||||
height: 400px;
|
||||
margin-bottom: 10px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
#login-name {
|
||||
width: 200px;
|
||||
}
|
||||
#message {
|
||||
width: 740px;
|
||||
height: 50px;
|
||||
}
|
||||
Binary file not shown.
263
embedded-repo/shoal-jxta/jxta/1.1-20090818/LICENSE.txt
Normal file
263
embedded-repo/shoal-jxta/jxta/1.1-20090818/LICENSE.txt
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
|
||||
|
||||
1. Definitions.
|
||||
|
||||
1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
|
||||
|
||||
1.2. Contributor Version. means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
|
||||
|
||||
1.3. Covered Software. means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
|
||||
|
||||
1.4. Executable. means the Covered Software in any form other than Source Code.
|
||||
|
||||
1.5. Initial Developer. means the individual or entity that first makes Original Software available under this License.
|
||||
|
||||
1.6. Larger Work. means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
|
||||
|
||||
1.7. License. means this document.
|
||||
|
||||
1.8. Licensable. means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
|
||||
|
||||
1.9. Modifications. means the Source Code and Executable form of any of the following:
|
||||
|
||||
A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
|
||||
|
||||
B. Any new file that contains any part of the Original Software or previous Modification; or
|
||||
|
||||
C. Any new file that is contributed or otherwise made available under the terms of this License.
|
||||
|
||||
1.10. Original Software. means the Source Code and Executable form of computer software code that is originally released under this License.
|
||||
|
||||
1.11. Patent Claims. means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
|
||||
|
||||
1.12. Source Code. means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
|
||||
|
||||
1.13. You. (or .Your.) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, .You. includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, .control. means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
2. License Grants.
|
||||
|
||||
2.1. The Initial Developer Grant.
|
||||
|
||||
Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
|
||||
|
||||
(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
|
||||
|
||||
(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
|
||||
|
||||
2.2. Contributor Grant.
|
||||
|
||||
Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
|
||||
|
||||
(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
|
||||
|
||||
(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Availability of Source Code.
|
||||
Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
|
||||
|
||||
3.2. Modifications.
|
||||
The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
|
||||
|
||||
3.3. Required Notices.
|
||||
You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
|
||||
|
||||
3.4. Application of Additional Terms.
|
||||
You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients. rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
|
||||
|
||||
3.5. Distribution of Executable Versions.
|
||||
You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient.s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
|
||||
|
||||
3.6. Larger Works.
|
||||
You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
|
||||
|
||||
4. Versions of the License.
|
||||
|
||||
4.1. New Versions.
|
||||
Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
|
||||
|
||||
4.2. Effect of New Versions.
|
||||
You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
|
||||
|
||||
4.3. Modified Versions.
|
||||
When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
|
||||
|
||||
5. DISCLAIMER OF WARRANTY.
|
||||
|
||||
COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
|
||||
6. TERMINATION.
|
||||
|
||||
6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
|
||||
|
||||
6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as .Participant.) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
|
||||
|
||||
6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
|
||||
|
||||
7. LIMITATION OF LIABILITY.
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
8. U.S. GOVERNMENT END USERS.
|
||||
|
||||
The Covered Software is a .commercial item,. as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as that term is defined at 48 C.F.R. º 252.227-7014(a)(1)) and .commercial computer software documentation. as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
|
||||
|
||||
9. MISCELLANEOUS.
|
||||
|
||||
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction.s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys. fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
|
||||
|
||||
10. RESPONSIBILITY FOR CLAIMS.
|
||||
|
||||
As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
|
||||
|
||||
NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
|
||||
|
||||
The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
|
||||
|
||||
|
||||
The GNU General Public License (GPL) Version 2, June 1991
|
||||
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
One line to give the program's name and a brief idea of what it does.
|
||||
|
||||
Copyright (C)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
|
||||
|
||||
|
||||
"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
|
||||
|
||||
Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
|
||||
|
||||
"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
|
||||
|
||||
Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
|
||||
BIN
embedded-repo/shoal-jxta/jxta/1.1-20090818/jxta-1.1-20090818.jar
Normal file
BIN
embedded-repo/shoal-jxta/jxta/1.1-20090818/jxta-1.1-20090818.jar
Normal file
Binary file not shown.
8
embedded-repo/shoal-jxta/jxta/1.1-20090818/jxta-1.1-20090818.pom
Executable file
8
embedded-repo/shoal-jxta/jxta/1.1-20090818/jxta-1.1-20090818.pom
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<groupId>shoal-jxta</groupId>
|
||||
<artifactId>jxta</artifactId>
|
||||
<version>1.1-20090818</version>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
263
embedded-repo/shoal-jxta/shoal/1.1-20090818/LICENSE.txt
Normal file
263
embedded-repo/shoal-jxta/shoal/1.1-20090818/LICENSE.txt
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
|
||||
|
||||
1. Definitions.
|
||||
|
||||
1.1. Contributor. means each individual or entity that creates or contributes to the creation of Modifications.
|
||||
|
||||
1.2. Contributor Version. means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor.
|
||||
|
||||
1.3. Covered Software. means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof.
|
||||
|
||||
1.4. Executable. means the Covered Software in any form other than Source Code.
|
||||
|
||||
1.5. Initial Developer. means the individual or entity that first makes Original Software available under this License.
|
||||
|
||||
1.6. Larger Work. means a work which combines Covered Software or portions thereof with code not governed by the terms of this License.
|
||||
|
||||
1.7. License. means this document.
|
||||
|
||||
1.8. Licensable. means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein.
|
||||
|
||||
1.9. Modifications. means the Source Code and Executable form of any of the following:
|
||||
|
||||
A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications;
|
||||
|
||||
B. Any new file that contains any part of the Original Software or previous Modification; or
|
||||
|
||||
C. Any new file that is contributed or otherwise made available under the terms of this License.
|
||||
|
||||
1.10. Original Software. means the Source Code and Executable form of computer software code that is originally released under this License.
|
||||
|
||||
1.11. Patent Claims. means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor.
|
||||
|
||||
1.12. Source Code. means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code.
|
||||
|
||||
1.13. You. (or .Your.) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, .You. includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, .control. means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
2. License Grants.
|
||||
|
||||
2.1. The Initial Developer Grant.
|
||||
|
||||
Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof).
|
||||
|
||||
(c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License.
|
||||
|
||||
(d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices.
|
||||
|
||||
2.2. Contributor Grant.
|
||||
|
||||
Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination).
|
||||
|
||||
(c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party.
|
||||
|
||||
(d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Availability of Source Code.
|
||||
Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange.
|
||||
|
||||
3.2. Modifications.
|
||||
The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License.
|
||||
|
||||
3.3. Required Notices.
|
||||
You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer.
|
||||
|
||||
3.4. Application of Additional Terms.
|
||||
You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients. rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
|
||||
|
||||
3.5. Distribution of Executable Versions.
|
||||
You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient.s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer.
|
||||
|
||||
3.6. Larger Works.
|
||||
You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software.
|
||||
|
||||
4. Versions of the License.
|
||||
|
||||
4.1. New Versions.
|
||||
Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License.
|
||||
|
||||
4.2. Effect of New Versions.
|
||||
You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward.
|
||||
|
||||
4.3. Modified Versions.
|
||||
When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License.
|
||||
|
||||
5. DISCLAIMER OF WARRANTY.
|
||||
|
||||
COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN .AS IS. BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
|
||||
6. TERMINATION.
|
||||
|
||||
6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
|
||||
|
||||
6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as .Participant.) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant.
|
||||
|
||||
6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination.
|
||||
|
||||
7. LIMITATION OF LIABILITY.
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY.S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
8. U.S. GOVERNMENT END USERS.
|
||||
|
||||
The Covered Software is a .commercial item,. as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of .commercial computer software. (as that term is defined at 48 C.F.R. º 252.227-7014(a)(1)) and .commercial computer software documentation. as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License.
|
||||
|
||||
9. MISCELLANEOUS.
|
||||
|
||||
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction.s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys. fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software.
|
||||
|
||||
10. RESPONSIBILITY FOR CLAIMS.
|
||||
|
||||
As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
|
||||
|
||||
NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL)
|
||||
|
||||
The code released under the CDDL shall be governed by the laws of the State of California (excluding conflict-of-law provisions). Any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California and the state courts of the State of California, with venue lying in Santa Clara County, California.
|
||||
|
||||
|
||||
The GNU General Public License (GPL) Version 2, June 1991
|
||||
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
One line to give the program's name and a brief idea of what it does.
|
||||
|
||||
Copyright (C)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
signature of Ty Coon, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.
|
||||
|
||||
|
||||
"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
|
||||
|
||||
Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words
|
||||
|
||||
"Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code."
|
||||
|
||||
Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version.
|
||||
Binary file not shown.
8
embedded-repo/shoal-jxta/shoal/1.1-20090818/shoal-1.1-20090818.pom
Executable file
8
embedded-repo/shoal-jxta/shoal/1.1-20090818/shoal-1.1-20090818.pom
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<groupId>shoal-jxta</groupId>
|
||||
<artifactId>shoal</artifactId>
|
||||
<version>1.1-20090818</version>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
BIN
embedded-repo/sjson/json/sjson/0.4/sjson-0.4.jar
Normal file
BIN
embedded-repo/sjson/json/sjson/0.4/sjson-0.4.jar
Normal file
Binary file not shown.
8
embedded-repo/sjson/json/sjson/0.4/sjson-0.4.pom
Executable file
8
embedded-repo/sjson/json/sjson/0.4/sjson-0.4.pom
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<groupId>sjson.json</groupId>
|
||||
<artifactId>sjson</artifactId>
|
||||
<version>0.4</version>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
71
pom.xml
Executable file → Normal file
71
pom.xml
Executable file → Normal file
|
|
@ -7,7 +7,7 @@
|
|||
<name>Akka Project</name>
|
||||
<artifactId>akka</artifactId>
|
||||
<groupId>se.scalablesolutions.akka</groupId>
|
||||
<version>0.6</version>
|
||||
<version>0.7-SNAPSHOT</version>
|
||||
<inceptionYear>2009</inceptionYear>
|
||||
<url>http://akkasource.org</url>
|
||||
<packaging>pom</packaging>
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
|
||||
<maven.compiler.encoding>${project.build.sourceEncoding}</maven.compiler.encoding>
|
||||
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
|
||||
<atmosphere.version>0.5.v20100104</atmosphere.version>
|
||||
<jersey.version>1.1.5-ea-20100104</jersey.version>
|
||||
<atmosphere.version>0.5.2</atmosphere.version>
|
||||
<jersey.version>1.1.5</jersey.version>
|
||||
<grizzly.version>1.9.18-i</grizzly.version>
|
||||
<scalatest.version>1.0-for-scala-2.8.0-SNAPSHOT</scalatest.version>
|
||||
<dispatch.version>2.8.0.Beta1-RC8</dispatch.version>
|
||||
|
|
@ -59,6 +59,7 @@
|
|||
<module>akka-comet</module>
|
||||
<module>akka-amqp</module>
|
||||
<module>akka-security</module>
|
||||
<module>akka-patterns</module>
|
||||
<module>akka-kernel</module>
|
||||
<module>akka-fun-test-java</module>
|
||||
<module>akka-samples</module>
|
||||
|
|
@ -94,9 +95,7 @@
|
|||
<timezone>+1</timezone>
|
||||
<email>viktor.klang [REMOVE] AT gmail DOT com</email>
|
||||
<roles>
|
||||
<role>Hacker</role>
|
||||
<role>Plumber</role>
|
||||
<role>Comic relief</role>
|
||||
<role>Apostle</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
|
@ -261,6 +260,46 @@
|
|||
<sourceDirectory>src/main/scala</sourceDirectory>
|
||||
<testSourceDirectory>src/test/scala</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-akka-home</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireProperty>
|
||||
<property>env.AKKA_HOME</property>
|
||||
<message>"You must have set AKKA_HOME!"</message>
|
||||
</requireProperty>
|
||||
<requireFilesExist>
|
||||
<files>
|
||||
<file>${env.AKKA_HOME}/embedded-repo</file>
|
||||
</files>
|
||||
</requireFilesExist>
|
||||
</rules>
|
||||
<fail>true</fail>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>enforce-java</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireJavaVersion>
|
||||
<version>1.6.0</version>
|
||||
</requireJavaVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
|
|
@ -359,26 +398,6 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.0-beta-1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-java</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireJavaVersion>
|
||||
<version>1.6.0</version>
|
||||
</requireJavaVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue