-
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.
finos#989 ignite vuu main to start as server and load test orders
- Loading branch information
Showing
2 changed files
with
51 additions
and
3 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
40 changes: 40 additions & 0 deletions
40
...ache-ignite/src/main/scala/org/finos/vuu/example/ignite/loader/IgniteOrderGenerator.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,40 @@ | ||
package org.finos.vuu.example.ignite.loader | ||
|
||
import com.typesafe.scalalogging.StrictLogging | ||
import org.finos.toolbox.lifecycle.LifecycleContainer | ||
import org.finos.toolbox.time.Clock | ||
import org.finos.vuu.core.module.simul.model.{ChildOrder, OrderStore} | ||
import org.finos.vuu.core.module.simul.provider.{ParentChildOrdersModel, SeededRandomNumbers} | ||
|
||
import java.util.concurrent.Executors | ||
import java.util.concurrent.atomic.LongAdder | ||
|
||
class IgniteOrderGenerator(orderStore: OrderStore) (implicit clock: Clock, lifecycleContainer: LifecycleContainer) extends StrictLogging{ | ||
|
||
implicit val randomNumbers: SeededRandomNumbers = new SeededRandomNumbers(clock.now()) | ||
private val ordersModel = new ParentChildOrdersModel() | ||
private val childOrderCounter = new LongAdder() | ||
private val executor = Executors.newWorkStealingPool() | ||
|
||
def save(): Unit = { | ||
|
||
logger.info("[Ignite] Saving orders to ignite.") | ||
(0 until 4_000).foreach(i => | ||
executor.execute { () => | ||
val parent = ordersModel.createParent() | ||
val childrenToCreate = randomNumbers.seededRand(100, 250) | ||
|
||
val children = (0 until childrenToCreate) | ||
.map(_ => ordersModel.createChild(parent)) | ||
.foldLeft(List[ChildOrder]())((acc, child) => acc :+ child) | ||
|
||
orderStore.storeParentOrderWithChildren(parent, children) | ||
childOrderCounter.add(children.length) | ||
if (i % 1000 == 0) { | ||
println(s"[${Thread.currentThread().getName}] Loaded : $i parent orders and ${childOrderCounter.sum()} child orders") | ||
} | ||
}) | ||
} | ||
|
||
|
||
} |