-
Notifications
You must be signed in to change notification settings - Fork 1
remeniuk/hazelcast-scala
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
DISCLAIMER: EXPERIMENTAL CODE. USE IT ON YOUR OWN RISK API for Hazelcast in Scala that will add abstractions for working in concurrent and distributed environment in a functional manner (distributed dataflow, actors backed with Hazelcast executors), and functional wrappers for Hazelcast distributed collections. ================================================================================================== ================== EXAMPLE. Distributed PI calculation on a cluster. ============================= ================================================================================================== object Pi { val N = 10000 def calculate(start: Int): Double = (start until (start + N)) .map(i => 4.0 * (1 - (i % 2) * 2) / (2 * i + 1)).sum } "Reduce tasks in a parallel (Pi calculation)" in additionalInstance { val result = reduce( HazelcastUtil.clusterMembersList.zipWithIndex.map { case (member, index) => distributedTask { () => Pi.calculate(index * Pi.N) } onMember member } )(_ + _)() result.get must be closeTo (3.141 +/- 0.001) } ================================================================================================== ==================================== EXAMPLE. Chaining tasks ===================================== ================================================================================================== "Join tasks in a parallel" in { val taskA = distributedTask { () => 1 }.onMember(Hazelcast.getCluster.getLocalMember) val taskB = distributedTask { () => "2" }.onMember(Hazelcast.getCluster.getLocalMember) val taskC = distributedTask { () => 1 }.onMember(Hazelcast.getCluster.getLocalMember) taskA .join(taskB)(_.toString + _) .join(taskC)(_.length + _) .map(_.toDouble)().get must be equalTo 3d } ================================================================================================== You can find more exciting examples in specs (https://github.com/remeniuk/hazelcast-scala/tree/master/src/test/scala/org/scalaby/hazelcastwf).
About
Functional wrapper for Hazelcast in Scala
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published