Skip to content

Commit

Permalink
fix: execute with another context
Browse files Browse the repository at this point in the history
  • Loading branch information
betarixm committed Nov 27, 2023
1 parent dbf1b68 commit bf0c352
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion master/src/main/scala/Master.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import kr.ac.postech.paranode.rpc.WorkerClient
import org.apache.logging.log4j.scala.Logging

import java.net._
import java.util.concurrent.Executors
import scala.concurrent.ExecutionContext
import scala.concurrent.ExecutionContextExecutor

object Master extends Logging {
Expand Down Expand Up @@ -39,8 +41,13 @@ object Master extends Logging {
s"numberOfWorkers: ${masterArguments.numberOfWorkers}\n"
)

val executionContext = ExecutionContext.fromExecutor(
Executors
.newCachedThreadPool()
)

val server =
new MasterServer(scala.concurrent.ExecutionContext.global, masterPort)
new MasterServer(executionContext, masterPort)

server.start()

Expand Down
9 changes: 8 additions & 1 deletion worker/src/main/scala/Worker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.apache.logging.log4j.scala.Logging

import java.net.InetAddress
import java.net.ServerSocket
import java.util.concurrent.Executors
import scala.concurrent.Await
import scala.concurrent.ExecutionContext
import scala.util.Using

object Worker extends Logging {
Expand All @@ -28,8 +30,13 @@ object Worker extends Logging {
s"outputDirectory: ${workerArguments.outputDirectory}\n"
)

val executionContext = ExecutionContext.fromExecutor(
Executors
.newCachedThreadPool()
)

val server = new WorkerServer(
scala.concurrent.ExecutionContext.global,
executionContext,
workerPort,
workerArguments.inputDirectories,
workerArguments.outputDirectory
Expand Down

0 comments on commit bf0c352

Please sign in to comment.