Skip to content

Commit

Permalink
#989 ignite vuu main to start as server and load test orders
Browse files Browse the repository at this point in the history
  • Loading branch information
naleeha authored and chrisjstevo committed Feb 16, 2024
1 parent 71700fd commit 7b7f5b4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.finos.vuu.core.module.price.PriceModule
import org.finos.vuu.core.module.simul.SimulationModule
import org.finos.vuu.core.module.typeahead.TypeAheadModule
import org.finos.vuu.core.module.vui.VuiStateModule
import org.finos.vuu.example.ignite.loader.IgniteOrderGenerator
import org.finos.vuu.example.ignite.module.IgniteOrderDataModule
import org.finos.vuu.net.auth.AlwaysHappyAuthenticator
import org.finos.vuu.net.http.VuuHttp2ServerOptions
Expand Down Expand Up @@ -54,6 +55,11 @@ object IgniteVuuMain extends App with StrictLogging {
val certPath = defaultConfig.getString("vuu.certPath")
val keyPath = defaultConfig.getString("vuu.keyPath")

logger.info("[Ignite] Starting ignite in server mode")
private val igniteOrderStore = IgniteOrderStore(clientMode = false)
private val igniteOrderGenerator = new IgniteOrderGenerator(igniteOrderStore)
igniteOrderGenerator.save()

val config = VuuServerConfig(
VuuHttp2ServerOptions()
//only specify webroot if we want to load the source locally, we'll load it from the jar
Expand All @@ -75,9 +81,10 @@ object IgniteVuuMain extends App with StrictLogging {
VuuThreadingOptions()
.withViewPortThreads(4)
.withTreeThreads(4)
).withModule(MetricsModule())
.withModule(IgniteOrderDataModule(IgniteOrderStore()))
.withPlugin(VirtualizedTablePlugin)
).withModule(TypeAheadModule())
.withModule(MetricsModule())
.withModule(IgniteOrderDataModule(igniteOrderStore))
.withPlugin(VirtualizedTablePlugin)

val vuuServer = new VuuServer(config)

Expand All @@ -86,4 +93,5 @@ object IgniteVuuMain extends App with StrictLogging {
logger.info("[VUU] Ready.")

vuuServer.join()

}
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")
}
})
}


}

0 comments on commit 7b7f5b4

Please sign in to comment.