-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding MasterSearchActor and TimeMesuare
- Loading branch information
unknown
authored and
unknown
committed
Nov 15, 2014
1 parent
7e04754
commit d794a03
Showing
12 changed files
with
193 additions
and
9 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
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,6 @@ | ||
package auction.helpers | ||
|
||
object RegisteredAuctions { | ||
private var registerdAuctions: Map[Integer, SystemSettings.AuctionPrice] = Map() | ||
|
||
} |
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,84 @@ | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085911 | ||
1416073085921 | ||
1416073085921 | ||
1416073085921 | ||
1416073085921 | ||
1416073085921 | ||
1416073085921 | ||
1416073085921 | ||
1416073085921 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085931 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085941 | ||
1416073085951 | ||
1416073085951 | ||
1416073085952 | ||
1416073085952 | ||
1416073085953 | ||
1416073085955 | ||
1416073085955 | ||
1416073085956 | ||
1416073085957 | ||
1416073085958 | ||
1416073085959 | ||
1416073085959 | ||
1416073085959 | ||
1416073085960 | ||
1416073085961 | ||
1416073085961 | ||
1416073085962 | ||
1416073085963 | ||
1416073085963 | ||
1416073085964 | ||
1416073085964 | ||
1416073085964 | ||
1416073085964 | ||
1416073085966 | ||
1416073085967 | ||
1416073085967 | ||
1416073085968 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085973 | ||
1416073085983 | ||
1416073085983 | ||
1416073085983 | ||
1416073085983 | ||
1416073085983 | ||
1416073085983 | ||
1416073085993 |
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
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,45 @@ | ||
package auction.actors | ||
|
||
import akka.actor.Actor | ||
import akka.actor.Props | ||
import akka.actor.Terminated | ||
import akka.routing.ActorRefRoutee | ||
import akka.routing.RoundRobinRoutingLogic | ||
import akka.routing.Router | ||
import auction.helpers.AuctionSystemLogger | ||
import auction.helpers.GlobalState | ||
import auction.helpers.SystemSettings | ||
import auction.helpers.findAuction | ||
import auction.helpers.registerAuction | ||
import akka.routing.BroadcastRoutingLogic | ||
|
||
class MasterSearchActor extends Actor { | ||
|
||
private val MASTER_SEARCH: String = "MasterSearch" | ||
|
||
var router = { | ||
val routees = Vector.fill(SystemSettings.NUMER_OF_SEARCH_ACTORS) { | ||
val auctionSearch = context.actorOf(Props[AuctionSearchActor]) | ||
context watch auctionSearch | ||
ActorRefRoutee(auctionSearch) | ||
} | ||
Router(RoundRobinRoutingLogic(), routees) | ||
} | ||
|
||
def receive = { | ||
case w: findAuction => { | ||
Router(BroadcastRoutingLogic(), router.routees) | ||
router.route(w, sender()) | ||
} | ||
case Terminated(actorRef) => | ||
router = router.removeRoutee(actorRef) | ||
val r = context.actorOf(Props[AuctionSearchActor]) | ||
context watch r | ||
router = router.addRoutee(r) | ||
case w: registerAuction => { | ||
Router(RoundRobinRoutingLogic(), router.routees) | ||
router.route(w, sender()) | ||
} | ||
} | ||
|
||
} |
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
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
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,5 @@ | ||
package auction.helpers | ||
|
||
object GlobalState { | ||
var registerdAuctions: Map[Integer, SystemSettings.AuctionPrice] = Map() | ||
} |
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
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
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,27 @@ | ||
package auction.helpers | ||
|
||
import java.io._ | ||
import scala.collection.mutable.MutableList | ||
|
||
object TimeMeasure { | ||
var data : List[String] = List(); | ||
|
||
private def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) { | ||
val p = new java.io.PrintWriter(f) | ||
try { op(p) } finally { p.close() } | ||
} | ||
|
||
def addResult(result: String) { | ||
data = data :+ result | ||
} | ||
|
||
def writeResultsToFile() { | ||
printToFile(new File(SystemSettings.RESULTS_OUTPUT_FILE)) { | ||
p => | ||
{ | ||
if (p != null) data.foreach(p.println) | ||
} | ||
} | ||
} | ||
|
||
} |