Commit 39aaad5c authored by Yiannis Tsiouris's avatar Yiannis Tsiouris

Add proper main for setting-up the nodes

parent 5a9af884
...@@ -4,17 +4,16 @@ module Bench( -- sequential benchmarks ...@@ -4,17 +4,16 @@ module Bench( -- sequential benchmarks
, par, par_seq , par, par_seq
-- distributed benhcmarks -- distributed benhcmarks
, dist, dist_seq , dist, dist_seq
, seqTest , main
) where ) where
import Control.Concurrent (threadDelay)
import Control.Distributed.Process import Control.Distributed.Process
import Control.Distributed.Process.Node import Control.Distributed.Process.Node
import qualified Control.Distributed.Process.Backend.SimpleLocalnet as SLN
import Prelude hiding (seq) import Prelude hiding (seq)
import Network.Transport.TCP import System.Environment (getArgs)
import MasterWorker (HostInfo(..), MaybeHosts(..), import MasterWorker
MasterStats, orbit)
import Utils import Utils
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
...@@ -63,11 +62,26 @@ sz (mainStats : _) = ...@@ -63,11 +62,26 @@ sz (mainStats : _) =
Nothing -> "false" Nothing -> "false"
Just s -> "{size," ++ s ++ "}" Just s -> "{size," ++ s ++ "}"
seqTest :: IO () rtable :: RemoteTable
seqTest = do rtable = MasterWorker.__remoteTable initRemoteTable
Right t <- createTransport "127.0.0.1" "10504" defaultTCPParameters
node <- newLocalNode t initRemoteTable main :: IO ()
runProcess node $ do main = do
res <- par gg13 11 2 args <- getArgs
case args of
["master", host, port] -> do
b <- SLN.initializeBackend host port rtable
print $ "Starting master @ " ++ host ++ ":" ++ port ++ " with slaves:"
SLN.startMaster b $ \slaves -> do
liftIO $ print $ " " ++ show slaves
res <- dist gg13 11 2 slaves
liftIO $ print res liftIO $ print res
threadDelay (1 * 1000000) ["slave", host, port] -> do
b <- SLN.initializeBackend host port rtable
print $ "Starting slave @ " ++ host ++ ":" ++ port
SLN.startSlave b
-- 1 second wait. Otherwise the main thread can terminate before
-- our messages reach the logging process or get flushed to stdio
--threadDelay (1 * 1000000)
...@@ -21,6 +21,7 @@ module MasterWorker( -- Master ...@@ -21,6 +21,7 @@ module MasterWorker( -- Master
, tail_idle_from_stat , tail_idle_from_stat
, max_idle_from_stat , max_idle_from_stat
, WorkerStats , WorkerStats
, __remoteTable
) where ) where
import Control.Distributed.Process import Control.Distributed.Process
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment