Add microkernel dist

This commit is contained in:
Peter Vlugter 2011-05-26 16:37:41 +12:00
parent 9567c5e90f
commit b7d0fb6b09
10 changed files with 251 additions and 50 deletions

View file

@ -0,0 +1,27 @@
####################
# Akka Config File #
####################
akka {
version = "2.0-SNAPSHOT"
enabled-modules = ["http"]
time-unit = "seconds"
event-handlers = ["akka.event.EventHandler$DefaultListener"]
boot = ["sample.hello.Boot"]
http {
hostname = "localhost"
port = 9998
connection-close = true
root-actor-id = "_httproot"
root-actor-builtin = true
timeout = 1000
expired-header-name = "Async-Timeout"
expired-header-value = "expired"
}
}

View file

@ -0,0 +1,65 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Set handler -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="AkkaMistHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/</Set>
<Call name="addServlet">
<Arg>akka.http.AkkaMistServlet</Arg>
<Arg>/*</Arg>
</Call>
</New>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
</Configure>

View file

@ -0,0 +1,20 @@
/**
* Copyright (C) 2009-2011 Scalable Solutions AB <http://scalablesolutions.se>
*/
package sample.hello
import akka.actor._
import akka.http._
import akka.config.Supervision._
class Boot {
val factory =
SupervisorFactory(
SupervisorConfig(
OneForOneStrategy(List(classOf[Exception]), 3, 100),
Supervise(Actor.actorOf[RootEndpoint], Permanent) ::
Supervise(Actor.actorOf[HelloEndpoint], Permanent) :: Nil))
factory.newInstance.start
}

View file

@ -0,0 +1,29 @@
/**
* Copyright (C) 2009-2011 Scalable Solutions AB <http://scalablesolutions.se>
*/
package sample.hello
import akka.actor._
import akka.http._
import java.text.DateFormat
import java.util.Date
class HelloEndpoint extends Actor with Endpoint {
self.dispatcher = Endpoint.Dispatcher
lazy val hello = Actor.actorOf(
new Actor {
def time = DateFormat.getTimeInstance.format(new Date)
def receive = {
case get: Get => get OK "Hello at " + time
}
}).start
def hook: Endpoint.Hook = { case _ => hello }
override def preStart = Actor.registry.actorFor(MistSettings.RootActorID).get ! Endpoint.Attach(hook)
def receive = handleHttpRequest
}

View file

@ -598,31 +598,35 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec
}
}
class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info)
class AkkaSampleChatProject(info: ProjectInfo) extends AkkaDefaultProject(info)
class AkkaSampleFSMProject(info: ProjectInfo) extends AkkaDefaultProject(info)
class AkkaSampleHelloProject(info: ProjectInfo) extends AkkaDefaultProject(info)
class AkkaSampleOsgiProject(info: ProjectInfo) extends AkkaDefaultProject(info) with BNDPlugin {
val osgiCore = Dependencies.osgi_core
override protected def bndPrivatePackage = List("sample.osgi.*")
override protected def bndBundleActivator = Some("sample.osgi.Activator")
}
class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info)
class AkkaSamplesParentProject(info: ProjectInfo) extends ParentProject(info) {
override def disableCrossPaths = true
lazy val akka_sample_ants = project("akka-sample-ants", "akka-sample-ants",
new AkkaSampleAntsProject(_), akka_stm)
lazy val akka_sample_fsm = project("akka-sample-fsm", "akka-sample-fsm",
new AkkaSampleFSMProject(_), akka_actor)
// lazy val akka_sample_remote = project("akka-sample-remote", "akka-sample-remote",
// new AkkaSampleRemoteProject(_), akka_remote)
// lazy val akka_sample_chat = project("akka-sample-chat", "akka-sample-chat",
// new AkkaSampleChatProject(_), akka_remote)
lazy val akka_sample_fsm = project("akka-sample-fsm", "akka-sample-fsm",
new AkkaSampleFSMProject(_), akka_actor)
lazy val akka_sample_hello = project("akka-sample-hello", "akka-sample-hello",
new AkkaSampleHelloProject(_), akka_kernel)
lazy val akka_sample_osgi = project("akka-sample-osgi", "akka-sample-osgi",
new AkkaSampleOsgiProject(_), akka_actor)
// lazy val akka_sample_remote = project("akka-sample-remote", "akka-sample-remote",
// new AkkaSampleRemoteProject(_), akka_remote)
lazy val publishRelease = {
val releaseConfiguration = new DefaultPublishConfiguration(localReleaseRepository, "release", false)
@ -784,6 +788,9 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec
lazy val akkaCoreDist = project("core", "akka-dist-core", new AkkaCoreDistProject(_),
akkaActorsDist, akka_remote, akka_http, akka_slf4j, akka_testkit, akka_actor_tests)
lazy val akkaMicrokernelDist = project("microkernel", "akka-dist-microkernel", new AkkaMicrokernelDistProject(_),
akkaCoreDist, akka_kernel, akka_samples)
def doNothing = task { None }
override def publishLocalAction = doNothing
override def deliverLocalAction = doNothing
@ -792,6 +799,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec
class AkkaActorsDistProject(info: ProjectInfo) extends DefaultProject(info) with DistDocProject {
def distName = "akka-actors"
override def distDocName = "akka"
override def distConfigSources = (akkaParent.info.projectPath / "config" ##) * "*"
@ -817,6 +825,51 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec
class AkkaCoreDistProject(info: ProjectInfo)extends DefaultProject(info) with DistProject {
def distName = "akka-core"
}
class AkkaMicrokernelDistProject(info: ProjectInfo) extends DefaultProject(info) with DistProject {
def distName = "akka-microkernel"
override def distScriptSources = akkaParent.info.projectPath / "scripts" / "microkernel" * "*"
override def distClasspath = akka_kernel.runClasspath
override def projectDependencies = akka_kernel.topologicalSort
override def distAction = super.distAction dependsOn (distSamples)
val distSamplesPath = distDocPath / "samples"
lazy val distSamples = task {
val demo = akka_samples.akka_sample_hello.jarPath
val samples = Set(//akka_samples.akka_sample_camel
akka_samples.akka_sample_hello)
//akka_samples.akka_sample_security)
def copySamples[P <: DefaultProject](samples: Set[P]) = {
samples.map { sample =>
val sampleOutputPath = distSamplesPath / sample.name
val binPath = sampleOutputPath / "bin"
val configPath = sampleOutputPath / "config"
val deployPath = sampleOutputPath / "deploy"
val libPath = sampleOutputPath / "lib"
val srcPath = sampleOutputPath / "src"
val confs = sample.info.projectPath / "config" ** "*.*"
val scripts = akkaParent.info.projectPath / "scripts" / "samples" * "*"
val libs = sample.managedClasspath(Configurations.Runtime)
val deployed = sample.jarPath
val sources = sample.packageSourcePaths
copyFiles(confs, configPath) orElse
copyScripts(scripts, binPath) orElse
copyFiles(libs, libPath) orElse
copyFiles(deployed, deployPath) orElse
copyPaths(sources, srcPath)
}.foldLeft(None: Option[String])(_ orElse _)
}
copyFiles(demo, distDeployPath) orElse
copySamples(samples)
} dependsOn (distBase)
}
}
}

View file

@ -4,27 +4,7 @@
import sbt._
trait DistBaseProject extends DefaultProject {
def distOutputPath: Path
def distLibPath: Path
def distSrcPath: Path
def distDocPath: Path
def dist: Task
override def disableCrossPaths = true
def doNothing = task { None }
override def compileAction = doNothing
override def testCompileAction = doNothing
override def testAction = doNothing
override def packageAction = doNothing
override def publishLocalAction = doNothing
override def deliverLocalAction = doNothing
override def publishAction = doNothing
override def deliverAction = doNothing
}
trait DistProject extends DistBaseProject {
trait DistProject extends DefaultProject {
def distName: String
val distFullName = distName + "-" + version
@ -38,7 +18,6 @@ trait DistProject extends DistBaseProject {
val distSrcPath = distOutputPath / "src" / "akka"
val distDocPath = distOutputPath / "doc" / "akka"
val distDocJarsPath = distDocPath / "api" / "jars"
val distSharePath = Path.userHome / ".ivy2" / "dist" / distFullName
val distArchiveName = distFullName + ".zip"
val distArchive = (distOutputBasePath ##) / distArchiveName
@ -58,7 +37,7 @@ trait DistProject extends DistBaseProject {
def distDependencies = {
allProjectDependencies.flatMap( p => p match {
case adp: DistBaseProject => Some(adp)
case dp: DistProject => Some(dp)
case _ => None
})
}
@ -92,8 +71,6 @@ trait DistProject extends DistBaseProject {
def distDocJars = dependencyJars(isDocJar) +++ projectDependencyJars(_.packageDocsJar)
def distShareSources = ((distOutputPath ##) ***)
lazy val dist = (distAction dependsOn (distBase, `package`, packageSrc, packageDocs)
describedAs("Create a distribution."))
@ -116,7 +93,6 @@ trait DistProject extends DistBaseProject {
copyFiles(distDocJars, distDocJarsPath) orElse
copyPaths(distConfigSources, distConfigPath) orElse
copyScripts(distScriptSources, distBinPath) orElse
copyPaths(distShareSources, distSharePath) orElse
FileUtilities.zip(List(distOutputPath), distArchive, true, log) orElse
exclusiveDist
}
@ -136,8 +112,7 @@ trait DistProject extends DistBaseProject {
describedAs "Clean the dist target dir.")
def distCleanAction = task {
FileUtilities.clean(distOutputPath, log) orElse
FileUtilities.clean(distSharePath, log)
FileUtilities.clean(distOutputPath, log)
}
def copyFiles(from: PathFinder, to: Path): Option[String] = {
@ -162,6 +137,18 @@ trait DistProject extends DistBaseProject {
val success = target.asFile.setExecutable(executable, false)
if (success) None else Some("Couldn't set permissions of " + target)
}
override def disableCrossPaths = true
def doNothing = task { None }
override def compileAction = doNothing
override def testCompileAction = doNothing
override def testAction = doNothing
override def packageAction = doNothing
override def publishLocalAction = doNothing
override def deliverLocalAction = doNothing
override def publishAction = doNothing
override def deliverAction = doNothing
}
trait DistDocProject extends DistProject {
@ -197,19 +184,3 @@ trait DistDocProject extends DistProject {
copyPaths(docsPdfSources, docsPdfPath)
} dependsOn (distBase, docParent.docs)
}
/*
* For wiring together akka and akka-modules.
*/
trait DistSharedProject extends DistBaseProject {
def distName: String
val distFullName = distName + "-" + version
val distOutputPath = Path.userHome / ".ivy2" / "dist" / distFullName
val distLibPath = distOutputPath / "lib" / "akka"
val distSrcPath = distOutputPath / "src" / "akka"
val distDocPath = distOutputPath / "doc" / "akka"
lazy val dist = task { None }
}

9
scripts/microkernel/akka Executable file
View file

@ -0,0 +1,9 @@
#!/bin/bash
AKKA_HOME="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)"
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC"
[ -n "$AKKA_CLASSPATH" ] || AKKA_CLASSPATH="$AKKA_HOME/lib/scala-library.jar:$AKKA_HOME/lib/akka/*:$AKKA_HOME/config"
java $JAVA_OPTS -cp "$AKKA_CLASSPATH" -Dakka.home="$AKKA_HOME" akka.kernel.Main

View file

@ -0,0 +1,6 @@
@echo off
set AKKA_HOME=%~dp0..
set JAVA_OPTS=-Xms1024M -Xmx1024M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC
set AKKA_CLASSPATH=%AKKA_HOME%\lib\scala-library.jar;%AKKA_HOME%\lib\akka\*;%AKKA_HOME%\config
java %JAVA_OPTS% -cp "%AKKA_CLASSPATH%" -Dakka.home="%AKKA_HOME%" akka.kernel.Main

13
scripts/samples/start Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
SAMPLE="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)"
AKKA_HOME="$(cd "$SAMPLE"/../../../..; pwd)"
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC"
[ -n "$AKKA_CLASSPATH" ] || AKKA_CLASSPATH="$AKKA_HOME/lib/scala-library.jar:$AKKA_HOME/lib/akka/*"
SAMPLE_CLASSPATH="$AKKA_CLASSPATH:$SAMPLE/lib/*:$SAMPLE/config"
java $JAVA_OPTS -cp "$SAMPLE_CLASSPATH" -Dakka.home="$SAMPLE" akka.kernel.Main

View file

@ -0,0 +1,8 @@
@echo off
set SAMPLE=%~dp0..
set AKKA_HOME=%SAMPLE%\..\..\..\..
set JAVA_OPTS=-Xms1024M -Xmx1024M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC
set AKKA_CLASSPATH=%AKKA_HOME%\lib\scala-library.jar;%AKKA_HOME%\lib\akka\*
set SAMPLE_CLASSPATH=%AKKA_CLASSPATH%;%SAMPLE%\lib\*;%SAMPLE%\config
java %JAVA_OPTS% -cp "%SAMPLE_CLASSPATH%" -Dakka.home="%SAMPLE%" akka.kernel.Main