-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
60 lines (49 loc) · 1.35 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"flag"
"reflect"
log "github.com/Sirupsen/logrus"
comm "github.com/icsnju/apt-mesos/communication"
core "github.com/icsnju/apt-mesos/core/impl"
"github.com/icsnju/apt-mesos/fs"
"github.com/icsnju/apt-mesos/scheduler"
schedulerImpl "github.com/icsnju/apt-mesos/scheduler/impl"
)
var (
addr string
master string
strategy string
debug bool
)
func init() {
flag.StringVar(&addr, "addr", "127.0.0.1:3030", "Address to listen on <ip:port>")
flag.StringVar(&master, "master", "127.0.0.1:5050", "Master to connect to <ip:port>")
flag.StringVar(&strategy, "strategy", "fcfs", "Scheduling algorithm, FCFS default")
flag.BoolVar(&debug, "debug", false, "Run in debug mode")
flag.Parse()
}
func main() {
if debug {
log.SetLevel(log.DebugLevel)
}
// create a new scheduler
var schedule scheduler.Scheduler
if strategy == scheduler.FCFS {
schedule = schedulerImpl.NewFCFSScheduler()
} else {
schedule = schedulerImpl.NewDRFScheduler()
}
// start a new core
core := core.NewCore(addr, master, schedule)
// start a new file explorer
fe := fs.NewMfsFileExplorer()
// Start HTTP server
comm.ListenAndServe(addr, core, fe)
log.Infof("Current scheduling stragy is %v", reflect.TypeOf(schedule))
// try to register framework to master
if err := core.Run(); err != nil {
log.Fatal(err)
}
exit := make(chan bool)
<-exit
}