-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reflect suggested request 1. change value name 2. make not to u…
…se file 3. use InetAddress
- Loading branch information
1 parent
f4d94e5
commit b5db92a
Showing
4 changed files
with
25 additions
and
84 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,43 +1,44 @@ | ||
package kr.ac.postech.paranode.master | ||
|
||
import kr.ac.postech.paranode.core.WorkerMetadata | ||
import kr.ac.postech.paranode.master.AuxFunction.getWorkerDetails | ||
import kr.ac.postech.paranode.rpc.MasterServer | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
import java.net._ | ||
|
||
import java.net.URL | ||
import scala.io.Source | ||
import scala.util.Try | ||
|
||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
val requestLimit = Try(args(0).toInt).getOrElse { | ||
val numberOfWorker = Try(args(0).toInt).getOrElse { | ||
println("Invalid command") | ||
return | ||
} | ||
|
||
val server = new MasterServer(scala.concurrent.ExecutionContext.global) | ||
server.startServer() | ||
|
||
while (server.getRequestCount < requestLimit) { | ||
while (server.getWorkerDetails.size < numberOfWorker) { | ||
Thread.sleep(1000) | ||
} | ||
|
||
val workerInfo: List[WorkerMetadata] = getWorkerDetails() | ||
val workerInfo: List[WorkerMetadata] = server.getWorkerDetails | ||
|
||
assert(workerInfo.size == requestLimit) | ||
assert(workerInfo.size == numberOfWorker) | ||
|
||
try { | ||
val url = new URL("http://checkip.amazonaws.com") | ||
val source = Source.fromURL(url) | ||
val publicIpAddress = source.mkString.trim | ||
source.close() | ||
val publicIpAddress = InetAddress.getLocalHost.getHostAddress | ||
|
||
println(publicIpAddress + ":" + server.getPort) | ||
println(workerInfo.map(_.host).mkString(", ")) | ||
} catch { | ||
case e: Exception => e.printStackTrace() | ||
} | ||
// TODO: start WorkerClient | ||
// TODO: save workerInfo and start WorkerClient | ||
|
||
} | ||
|
||
} |
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