Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create cinnamon examples for akka actors
- Loading branch information
1 parent
28afb63
commit 94b0239
Showing
8 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
name := "akka-cinammon" | ||
|
||
version := "1.0" | ||
|
||
scalaVersion := "2.11.8" | ||
|
||
val akkaVersion = "2.4.17" | ||
|
||
lazy val `akka-cinammon` = project in file(".") enablePlugins (Cinnamon) | ||
|
||
// Add the Cinnamon Agent for run and test | ||
cinnamon in run := true | ||
cinnamon in test := true | ||
|
||
// Set the Cinnamon Agent log level | ||
cinnamonLogLevel := "INFO" | ||
|
||
libraryDependencies ++= Seq( | ||
Cinnamon.library.cinnamonCHMetrics, | ||
Cinnamon.library.cinnamonAkka, | ||
"com.typesafe.akka" %% "akka-actor" % akkaVersion, | ||
"com.typesafe.akka" %% "akka-testkit" % akkaVersion, | ||
"org.scalatest" %% "scalatest" % "3.0.1" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version = 0.13.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
credentials += Credentials(Path.userHome / ".lightbend" / "commercial.credentials") | ||
|
||
resolvers += Resolver.url("lightbend-commercial", | ||
url("https://repo.lightbend.com/commercial-releases"))(Resolver.ivyStylePatterns) | ||
|
||
addSbtPlugin("com.lightbend.cinnamon" % "sbt-cinnamon" % "2.4.2") | ||
|
||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-RC6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cinnamon.akka { | ||
actors { | ||
"/user/*" { | ||
report-by = instance | ||
} | ||
} | ||
} | ||
cinnamon.chmetrics { | ||
reporters += "console-reporter" | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/scala/com/harmeetsingh13/actors/HelloWorldActor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.harmeetsingh13.actors | ||
|
||
import akka.actor.{Actor, ActorLogging, ActorSystem, Props} | ||
|
||
/** | ||
* Created by Harmeet Singh(Taara) on 1/7/17. | ||
*/ | ||
class HelloWorldActor extends Actor with ActorLogging { | ||
|
||
override def receive: Receive = { | ||
case any => | ||
Thread.sleep(1000) | ||
log.info(s"Hello $any") | ||
} | ||
} | ||
|
||
object HelloWorldActor extends App { | ||
|
||
val system = ActorSystem("HelloWorldSystem") | ||
val ref1 = system.actorOf(Props[HelloWorldSelectionActor]) | ||
|
||
for (i <- 1 to 10000) ref1 ! "James" | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/scala/com/harmeetsingh13/actors/HelloWorldPoolActor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.harmeetsingh13.actors | ||
|
||
import akka.actor.{Actor, ActorLogging, ActorSystem, Props} | ||
import akka.routing.RoundRobinPool | ||
|
||
/** | ||
* Created by Harmeet Singh(Taara) on 1/7/17. | ||
*/ | ||
class HelloWorldPoolActor extends Actor with ActorLogging { | ||
|
||
override def receive: Receive = { | ||
case any => | ||
Thread.sleep(1000) | ||
log.info(s"Hello $any") | ||
} | ||
} | ||
|
||
object HelloWorldPoolActor extends App { | ||
val system = ActorSystem("HelloWorldPoolSystem") | ||
val ref1 = system.actorOf(RoundRobinPool(5).props(Props[HelloWorldPoolActor]), "HelloPool") | ||
|
||
for (i <- 1 to 10000) ref1 ! "James" | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/scala/com/harmeetsingh13/actors/HelloWorldSelectionActor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.harmeetsingh13.actors | ||
|
||
import akka.actor.{Actor, ActorLogging, ActorSystem, Props} | ||
import akka.util.Timeout | ||
|
||
import scala.concurrent.duration.DurationInt | ||
import scala.concurrent.ExecutionContext.Implicits.global | ||
import scala.concurrent.Future | ||
|
||
/** | ||
* Created by Harmeet Singh(Taara) on 1/7/17. | ||
*/ | ||
class HelloWorldSelectionActor extends Actor with ActorLogging { | ||
|
||
override def receive: Receive = { | ||
case any => | ||
Thread.sleep(1000) | ||
log.info(s"Hello $any") | ||
} | ||
} | ||
|
||
object HelloWorldSelectionActor extends App { | ||
|
||
val system = ActorSystem("HelloWorldSelectionSystem") | ||
val ref1 = system.actorOf(Props[HelloWorldSelectionActor]) | ||
val ref2 = system.actorSelection(ref1.path) | ||
val ref3 = system.actorSelection(ref1.path) | ||
val ref4 = system.actorSelection(ref1.path) | ||
val ref5 = system.actorSelection(ref1.path) | ||
|
||
Future { for (i <- 1 to 10000) ref1 ! "James" } | ||
Future { for (i <- 1 to 10000) ref2 ! "Jimmy" } | ||
Future { for (i <- 1 to 10000) ref3 ! "Foo" } | ||
Future { for (i <- 1 to 10000) ref4 ! "Bar" } | ||
Future { for (i <- 1 to 10000) ref5 ! "FooBar" } | ||
} |